Adds unicode support in fpspreadsheet

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@683 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2009-01-28 17:18:04 +00:00
parent 413d1f2258
commit 8d4562d0ef
11 changed files with 81 additions and 75 deletions

View File

@ -10,7 +10,7 @@
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=".exe"/> <TargetFileExt Value=".exe"/>
<Title Value="excel2read"/> <Title Value="excel2read"/>
<ActiveEditorIndexAtStart Value="3"/> <ActiveEditorIndexAtStart Value="0"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -26,7 +26,7 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
@ -39,8 +39,8 @@
<Filename Value="excel2read.lpr"/> <Filename Value="excel2read.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="excel2read"/> <UnitName Value="excel2read"/>
<CursorPos X="6" Y="23"/> <CursorPos X="1" Y="42"/>
<TopLine Value="12"/> <TopLine Value="24"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="309"/> <UsageCount Value="309"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -69,7 +69,7 @@
<Unit4> <Unit4>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<UnitName Value="xlsbiff5"/> <UnitName Value="xlsbiff5"/>
<CursorPos X="37" Y="934"/> <CursorPos X="20" Y="938"/>
<TopLine Value="918"/> <TopLine Value="918"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<UsageCount Value="140"/> <UsageCount Value="140"/>

View File

@ -40,7 +40,8 @@ begin
begin begin
CurCell := MyWorkSheet.GetCellByIndex(i); CurCell := MyWorkSheet.GetCellByIndex(i);
WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ', WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ',
MyWorkSheet.ReadAsAnsiText(CurCell^.Row, CurCell^.Col)); UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row, CurCell^.Col))
);
end; end;
// Finalization // Finalization

View File

@ -26,7 +26,7 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
@ -39,8 +39,8 @@
<Filename Value="excel2write.lpr"/> <Filename Value="excel2write.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="excel2write"/> <UnitName Value="excel2write"/>
<CursorPos X="30" Y="37"/> <CursorPos X="24" Y="37"/>
<TopLine Value="19"/> <TopLine Value="18"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="309"/> <UsageCount Value="309"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -130,7 +130,7 @@
<UsageCount Value="67"/> <UsageCount Value="67"/>
</Unit11> </Unit11>
</Units> </Units>
<JumpHistory Count="26" HistoryIndex="25"> <JumpHistory Count="27" HistoryIndex="26">
<Position1> <Position1>
<Filename Value="..\..\fpolestorage.pas"/> <Filename Value="..\..\fpolestorage.pas"/>
<Caret Line="40" Column="5" TopLine="31"/> <Caret Line="40" Column="5" TopLine="31"/>
@ -235,6 +235,10 @@
<Filename Value="excel2write.lpr"/> <Filename Value="excel2write.lpr"/>
<Caret Line="30" Column="21" TopLine="19"/> <Caret Line="30" Column="21" TopLine="19"/>
</Position26> </Position26>
<Position27>
<Filename Value="excel2write.lpr"/>
<Caret Line="37" Column="30" TopLine="18"/>
</Position27>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -31,10 +31,10 @@ begin
MyWorksheet.WriteNumber(0, 3, 4.0); MyWorksheet.WriteNumber(0, 3, 4.0);
// Write some string cells // Write some string cells
MyWorksheet.WriteAnsiText(1, 0, 'First'); MyWorksheet.WriteUTF8Text(1, 0, 'First');
MyWorksheet.WriteAnsiText(1, 1, 'Second'); MyWorksheet.WriteUTF8Text(1, 1, 'Second');
MyWorksheet.WriteAnsiText(1, 2, 'Third'); MyWorksheet.WriteUTF8Text(1, 2, 'Third');
MyWorksheet.WriteAnsiText(1, 3, 'Fourth'); MyWorksheet.WriteUTF8Text(1, 3, 'Fourth');
// Save the spreadsheet to a file // Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel2); MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel2);

View File

@ -10,7 +10,7 @@
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=".exe"/> <TargetFileExt Value=".exe"/>
<Title Value="excel5read"/> <Title Value="excel5read"/>
<ActiveEditorIndexAtStart Value="3"/> <ActiveEditorIndexAtStart Value="0"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -26,7 +26,7 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
@ -39,7 +39,7 @@
<Filename Value="excel5read.lpr"/> <Filename Value="excel5read.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="excel5read"/> <UnitName Value="excel5read"/>
<CursorPos X="20" Y="30"/> <CursorPos X="39" Y="43"/>
<TopLine Value="21"/> <TopLine Value="21"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="309"/> <UsageCount Value="309"/>
@ -69,7 +69,7 @@
<Unit4> <Unit4>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<UnitName Value="xlsbiff5"/> <UnitName Value="xlsbiff5"/>
<CursorPos X="53" Y="913"/> <CursorPos X="19" Y="920"/>
<TopLine Value="903"/> <TopLine Value="903"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<UsageCount Value="140"/> <UsageCount Value="140"/>
@ -97,7 +97,7 @@
<Filename Value="..\..\fpolestorage.pas"/> <Filename Value="..\..\fpolestorage.pas"/>
<UnitName Value="fpolestorage"/> <UnitName Value="fpolestorage"/>
<CursorPos X="78" Y="806"/> <CursorPos X="78" Y="806"/>
<TopLine Value="798"/> <TopLine Value="792"/>
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<UsageCount Value="139"/> <UsageCount Value="139"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -150,7 +150,7 @@
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit14> </Unit14>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="29" HistoryIndex="28">
<Position1> <Position1>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="895" Column="1" TopLine="885"/> <Caret Line="895" Column="1" TopLine="885"/>
@ -205,72 +205,68 @@
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="913" Column="3" TopLine="919"/> <Caret Line="924" Column="1" TopLine="914"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="924" Column="1" TopLine="914"/> <Caret Line="926" Column="1" TopLine="916"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="926" Column="1" TopLine="916"/> <Caret Line="918" Column="1" TopLine="910"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="918" Column="1" TopLine="910"/> <Caret Line="886" Column="1" TopLine="867"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="886" Column="1" TopLine="867"/> <Caret Line="889" Column="1" TopLine="876"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="889" Column="1" TopLine="876"/> <Caret Line="68" Column="24" TopLine="58"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="68" Column="24" TopLine="58"/> <Caret Line="887" Column="1" TopLine="882"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="887" Column="1" TopLine="882"/> <Caret Line="64" Column="37" TopLine="55"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="64" Column="37" TopLine="55"/> <Caret Line="934" Column="5" TopLine="915"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="934" Column="5" TopLine="915"/> <Caret Line="941" Column="23" TopLine="925"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="941" Column="23" TopLine="925"/> <Caret Line="72" Column="25" TopLine="62"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="72" Column="25" TopLine="62"/>
</Position25>
<Position26>
<Filename Value="..\..\fpspreadsheet.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="499" Column="45" TopLine="486"/> <Caret Line="499" Column="45" TopLine="486"/>
</Position25>
<Position26>
<Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="948" Column="1" TopLine="946"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="948" Column="1" TopLine="946"/> <Caret Line="994" Column="12" TopLine="981"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="994" Column="12" TopLine="981"/> <Caret Line="891" Column="1" TopLine="872"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="891" Column="1" TopLine="872"/>
</Position29>
<Position30>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\xlsbiff5.pas"/>
<Caret Line="70" Column="15" TopLine="60"/> <Caret Line="70" Column="15" TopLine="60"/>
</Position30> </Position29>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -40,7 +40,8 @@ begin
begin begin
CurCell := MyWorkSheet.GetCellByIndex(i); CurCell := MyWorkSheet.GetCellByIndex(i);
WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ', WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ',
MyWorkSheet.ReadAsAnsiText(CurCell^.Row, CurCell^.Col)); UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row, CurCell^.Col))
);
end; end;
// Finalization // Finalization

View File

@ -26,7 +26,7 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
@ -40,7 +40,7 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="excel5write"/> <UnitName Value="excel5write"/>
<CursorPos X="8" Y="21"/> <CursorPos X="8" Y="21"/>
<TopLine Value="52"/> <TopLine Value="46"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="309"/> <UsageCount Value="309"/>
<Loaded Value="True"/> <Loaded Value="True"/>

View File

@ -59,10 +59,10 @@ begin
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2'); MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');
// Write some string cells // Write some string cells
MyWorksheet.WriteAnsiText(0, 0, 'First'); MyWorksheet.WriteUTF8Text(0, 0, 'First');
MyWorksheet.WriteAnsiText(0, 1, 'Second'); MyWorksheet.WriteUTF8Text(0, 1, 'Second');
MyWorksheet.WriteAnsiText(0, 2, 'Third'); MyWorksheet.WriteUTF8Text(0, 2, 'Third');
MyWorksheet.WriteAnsiText(0, 3, 'Fourth'); MyWorksheet.WriteUTF8Text(0, 3, 'Fourth');
// Save the spreadsheet to a file // Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel5); MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel5);

View File

@ -23,6 +23,8 @@ type
const const
{ Default extensions } { Default extensions }
STR_EXCEL_EXTENSION = '.xls'; STR_EXCEL_EXTENSION = '.xls';
STR_OOXML_EXCEL_EXTENSION = '.xlsx';
STR_OPENDOCUMENT_CALC_EXTENSION = '.ods';
const const
{ TokenID values } { TokenID values }
@ -59,7 +61,7 @@ type
{@@ Describes the type of content of a cell on a TsWorksheet } {@@ Describes the type of content of a cell on a TsWorksheet }
TCellContentType = (cctFormula, cctNumber, cctString, cctWideString); TCellContentType = (cctFormula, cctNumber, cctUTF8String);
{@@ Cell structure for TsWorksheet } {@@ Cell structure for TsWorksheet }
@ -68,8 +70,7 @@ type
ContentType: TCellContentType; ContentType: TCellContentType;
FormulaValue: TRPNFormula; FormulaValue: TRPNFormula;
NumberValue: double; NumberValue: double;
StringValue: string; UTF8StringValue: ansistring;
WideStringValue: widestring;
end; end;
PCell = ^TCell; PCell = ^TCell;
@ -97,9 +98,9 @@ type
function GetCell(ARow, ACol: Cardinal): PCell; function GetCell(ARow, ACol: Cardinal): PCell;
function GetCellCount: Cardinal; function GetCellCount: Cardinal;
function GetCellByIndex(AIndex: Cardinal): PCell; function GetCellByIndex(AIndex: Cardinal): PCell;
function ReadAsAnsiText(ARow, ACol: Cardinal): ansistring; function ReadAsUTF8Text(ARow, ACol: Cardinal): ansistring;
procedure RemoveAllCells; procedure RemoveAllCells;
procedure WriteAnsiText(ARow, ACol: Cardinal; AText: ansistring); procedure WriteUTF8Text(ARow, ACol: Cardinal; AText: ansistring);
procedure WriteNumber(ARow, ACol: Cardinal; ANumber: double); procedure WriteNumber(ARow, ACol: Cardinal; ANumber: double);
procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TRPNFormula); procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TRPNFormula);
end; end;
@ -352,15 +353,17 @@ begin
end; end;
{@@ {@@
Reads the contents of a cell and converts it to a user readable text, Reads the contents of a cell and returns an user readable text
if it isn't already a text. representing the contents of the cell.
The resulting ansistring is UTF-8 encoded.
@param ARow The row of the cell @param ARow The row of the cell
@param ACol The column of the cell @param ACol The column of the cell
@return The text representation of the cell @return The text representation of the cell
} }
function TsWorksheet.ReadAsAnsiText(ARow, ACol: Cardinal): ansistring; function TsWorksheet.ReadAsUTF8Text(ARow, ACol: Cardinal): ansistring;
var var
ACell: PCell; ACell: PCell;
begin begin
@ -376,10 +379,9 @@ begin
//cctFormula //cctFormula
cctNumber: Result := FloatToStr(ACell^.NumberValue); cctNumber: Result := FloatToStr(ACell^.NumberValue);
cctString: Result := ACell^.StringValue; cctUTF8String: Result := UTF8ToAnsi(ACell^.UTF8StringValue);
cctWideString: Result := ACell^.WideStringValue;
else else
Result := ACell^.StringValue; Result := '';
end; end;
end; end;
@ -392,25 +394,23 @@ begin
end; end;
{@@ {@@
Writes ansi text to a determined cell. Writes UTF-8 encoded text to a determined cell.
The text must be encoded on the system default encoding. On formats that only support unicode the text will be converted
to the unicode encoding that the format supports.
On formats the support unicode the text will be converted to the unicode
encoding that the format supports.
@param ARow The row of the cell @param ARow The row of the cell
@param ACol The column of the cell @param ACol The column of the cell
@param AText The text to be written encoded with the system encoding @param AText The text to be written encoded with the system encoding
} }
procedure TsWorksheet.WriteAnsiText(ARow, ACol: Cardinal; AText: ansistring); procedure TsWorksheet.WriteUTF8Text(ARow, ACol: Cardinal; AText: ansistring);
var var
ACell: PCell; ACell: PCell;
begin begin
ACell := GetCell(ARow, ACol); ACell := GetCell(ARow, ACol);
ACell^.ContentType := cctString; ACell^.ContentType := cctUTF8String;
ACell^.StringValue := AText; ACell^.UTF8StringValue := AText;
end; end;
{@@ {@@
@ -714,7 +714,7 @@ begin
case ACell.ContentType of case ACell.ContentType of
cctFormula: WriteFormula(AStream, ACell^.Row, ACell^.Col, ACell^.FormulaValue); cctFormula: WriteFormula(AStream, ACell^.Row, ACell^.Col, ACell^.FormulaValue);
cctNumber: WriteNumber(AStream, ACell^.Row, ACell^.Col, ACell^.NumberValue); cctNumber: WriteNumber(AStream, ACell^.Row, ACell^.Col, ACell^.NumberValue);
cctString: WriteLabel(AStream, ACell^.Row, ACell^.Col, ACell^.StringValue); cctUTF8String: WriteLabel(AStream, ACell^.Row, ACell^.Col, ACell^.UTF8StringValue);
end; end;
end; end;

View File

@ -240,8 +240,10 @@ procedure TsSpreadBIFF2Writer.WriteLabel(AStream: TStream; const ARow,
ACol: Word; const AValue: string); ACol: Word; const AValue: string);
var var
L: Byte; L: Byte;
AnsiText: ansistring;
begin begin
L := Length(AValue); AnsiText := UTF8ToAnsi(AValue);
L := Length(AnsiText);
{ BIFF Record header } { BIFF Record header }
AStream.WriteWord(WordToLE(INT_EXCEL_ID_LABEL)); AStream.WriteWord(WordToLE(INT_EXCEL_ID_LABEL));
@ -258,7 +260,7 @@ begin
{ String with 8-bit size } { String with 8-bit size }
AStream.WriteByte(L); AStream.WriteByte(L);
AStream.WriteBuffer(AValue[1], L); AStream.WriteBuffer(AnsiText[1], L);
end; end;
{******************************************************************* {*******************************************************************
@ -357,7 +359,7 @@ begin
AStrValue := AValue; AStrValue := AValue;
{ Save the data } { Save the data }
FWorksheet.WriteAnsiText(ARow, ACol, AStrValue); FWorksheet.WriteUTF8Text(ARow, ACol, AnsiToUTF8(AStrValue));
end; end;
procedure TsSpreadBIFF2Reader.ReadNumber(AStream: TStream); procedure TsSpreadBIFF2Reader.ReadNumber(AStream: TStream);

View File

@ -657,8 +657,10 @@ procedure TsSpreadBIFF5Writer.WriteLabel(AStream: TStream; const ARow,
ACol: Word; const AValue: string); ACol: Word; const AValue: string);
var var
L: Word; L: Word;
AnsiValue: ansistring;
begin begin
L := Length(AValue); AnsiValue := UTF8ToAnsi(AValue);
L := Length(AnsiValue);
{ BIFF Record header } { BIFF Record header }
AStream.WriteWord(WordToLE(INT_EXCEL_ID_LABEL)); AStream.WriteWord(WordToLE(INT_EXCEL_ID_LABEL));
@ -673,7 +675,7 @@ begin
{ Byte String with 16-bit size } { Byte String with 16-bit size }
AStream.WriteWord(L); AStream.WriteWord(L);
AStream.WriteBuffer(AValue[1], L); AStream.WriteBuffer(AnsiValue[1], L);
end; end;
{******************************************************************* {*******************************************************************