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

View File

@ -82,6 +82,7 @@ begin
MyWorksheet.WriteUTF8Text(0, 2, Str_Third);
MyWorksheet.WriteUTF8Text(0, 3, Str_Fourth);
MyWorksheet.WriteTextRotation(0, 0, rt90DegreeClockwiseRotation);
MyWorksheet.WriteUsedFormatting(0, 1, [uffBold]);
// Save the spreadsheet to a file
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 }
TsUsedFormattingField = (uffTextRotation);
TsUsedFormattingField = (uffTextRotation, uffBold);
{@@ Describes which formatting fields are active }
@ -157,6 +157,7 @@ type
procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula);
procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TsRPNFormula);
procedure WriteTextRotation(ARow, ACol: Cardinal; ARotation: TsTextRotation);
procedure WriteUsedFormatting(ARow, ACol: Cardinal; AUsedFormatting: TsUsedFormattingFields);
property Cells: TAVLTree read FCells;
end;
@ -657,6 +658,16 @@ begin
ACell^.TextRotation := ARotation;
end;
procedure TsWorksheet.WriteUsedFormatting(ARow, ACol: Cardinal;
AUsedFormatting: TsUsedFormattingFields);
var
ACell: PCell;
begin
ACell := GetCell(ARow, ACol);
ACell^.UsedFormattingFields := AUsedFormatting;
end;
{ TsWorkbook }
{@@

View File

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