Adds support for bold formatting to biff 8 in fpspreadsheet

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1399 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2010-12-07 12:59:17 +00:00
parent bfef390ae7
commit 1005ddd45d
5 changed files with 43 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="7"/>
<General> <General>
<Flags> <Flags>
<AlwaysBuild Value="False"/> <AlwaysBuild Value="False"/>
@@ -10,13 +10,15 @@
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Title Value="excel8write"/> <Title Value="excel8write"/>
<UseAppBundle Value="False"/> <UseAppBundle Value="False"/>
</General> </General>
<VersionInfo> <VersionInfo>
<StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/> <StringTable ProductVersion=""/>
</VersionInfo> </VersionInfo>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/> <IgnoreBinaries Value="False"/>
@@ -43,12 +45,17 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="8"/> <Version Value="9"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<SearchPaths> <SearchPaths>
<OtherUnitFiles Value="..\"/> <OtherUnitFiles Value=".."/>
<SrcPath Value="..\"/> <SrcPath Value=".."/>
</SearchPaths> </SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Other> <Other>
<CompilerPath Value="$(CompPath)"/> <CompilerPath Value="$(CompPath)"/>
</Other> </Other>

View File

@@ -82,6 +82,7 @@ begin
MyWorksheet.WriteUTF8Text(0, 2, Str_Third); MyWorksheet.WriteUTF8Text(0, 2, Str_Third);
MyWorksheet.WriteUTF8Text(0, 3, Str_Fourth); MyWorksheet.WriteUTF8Text(0, 3, Str_Fourth);
MyWorksheet.WriteTextRotation(0, 0, rt90DegreeClockwiseRotation); MyWorksheet.WriteTextRotation(0, 0, rt90DegreeClockwiseRotation);
MyWorksheet.WriteUsedFormatting(0, 1, [uffBold]);
// Save the spreadsheet to a file // Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test2.xls', sfExcel8, False); MyWorkbook.WriteToFile(MyDir + 'test2.xls', sfExcel8, False);

View File

@@ -0,0 +1,2 @@
excel8write.exe
pause

View File

@@ -88,7 +88,7 @@ type
{@@ List of possible formatting fields } {@@ List of possible formatting fields }
TsUsedFormattingField = (uffTextRotation); TsUsedFormattingField = (uffTextRotation, uffBold);
{@@ Describes which formatting fields are active } {@@ Describes which formatting fields are active }
@@ -157,6 +157,7 @@ type
procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula); procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula);
procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TsRPNFormula); procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TsRPNFormula);
procedure WriteTextRotation(ARow, ACol: Cardinal; ARotation: TsTextRotation); procedure WriteTextRotation(ARow, ACol: Cardinal; ARotation: TsTextRotation);
procedure WriteUsedFormatting(ARow, ACol: Cardinal; AUsedFormatting: TsUsedFormattingFields);
property Cells: TAVLTree read FCells; property Cells: TAVLTree read FCells;
end; end;
@@ -657,6 +658,16 @@ begin
ACell^.TextRotation := ARotation; ACell^.TextRotation := ARotation;
end; end;
procedure TsWorksheet.WriteUsedFormatting(ARow, ACol: Cardinal;
AUsedFormatting: TsUsedFormattingFields);
var
ACell: PCell;
begin
ACell := GetCell(ARow, ACol);
ACell^.UsedFormattingFields := AUsedFormatting;
end;
{ TsWorkbook } { TsWorkbook }
{@@ {@@

View File

@@ -168,6 +168,7 @@ const
{ FONT record constants } { FONT record constants }
INT_FONT_WEIGHT_NORMAL = $0190; INT_FONT_WEIGHT_NORMAL = $0190;
INT_FONT_WEIGHT_BOLD = $02BC;
{ FORMULA record constants } { FORMULA record constants }
MASK_FORMULA_RECALCULATE_ALWAYS = $0001; MASK_FORMULA_RECALCULATE_ALWAYS = $0001;
@@ -306,10 +307,12 @@ begin
try try
FontData.Name := 'Arial'; FontData.Name := 'Arial';
// FONT0 // FONT0 - normal
WriteFont(AStream, FontData); WriteFont(AStream, FontData);
// FONT1 // FONT1 - bold
FontData.Bold := True;
WriteFont(AStream, FontData); WriteFont(AStream, FontData);
FontData.Bold := False;
// FONT2 // FONT2
WriteFont(AStream, FontData); WriteFont(AStream, FontData);
// FONT3 // FONT3
@@ -356,6 +359,8 @@ begin
WriteXF(AStream, 0, 0, XF_ROTATION_90_DEGREE_COUNTERCLOCKWISE); WriteXF(AStream, 0, 0, XF_ROTATION_90_DEGREE_COUNTERCLOCKWISE);
// XF17 // XF17
WriteXF(AStream, 0, 0, XF_ROTATION_90_DEGREE_CLOCKWISE); WriteXF(AStream, 0, 0, XF_ROTATION_90_DEGREE_CLOCKWISE);
// XF18
WriteXF(AStream, 1, 0, XF_ROTATION_HORIZONTAL);
WriteStyle(AStream); WriteStyle(AStream);
@@ -546,13 +551,15 @@ begin
AStream.WriteWord(WordToLE(200)); AStream.WriteWord(WordToLE(200));
{ Option flags } { Option flags }
AStream.WriteWord(WordToLE(0)); if AFont.Bold then AStream.WriteWord(WordToLE(1))
else AStream.WriteWord(WordToLE(0));
{ Colour index } { Colour index }
AStream.WriteWord(WordToLE($7FFF)); AStream.WriteWord(WordToLE($7FFF));
{ Font weight } { Font weight }
AStream.WriteWord(WordToLE(INT_FONT_WEIGHT_NORMAL)); if AFont.Bold then AStream.WriteWord(WordToLE(INT_FONT_WEIGHT_BOLD))
else AStream.WriteWord(WordToLE(INT_FONT_WEIGHT_NORMAL));
{ Escapement type } { Escapement type }
AStream.WriteWord(WordToLE(0)); AStream.WriteWord(WordToLE(0));
@@ -742,6 +749,10 @@ begin
AStream.WriteWord(WordToLE(15)); AStream.WriteWord(WordToLE(15));
end; end;
end end
else if ACell^.UsedFormattingFields = [uffBold] then
begin
AStream.WriteWord(WordToLE(18));
end
else else
AStream.WriteWord(WordToLE(15)); AStream.WriteWord(WordToLE(15));