diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas index fe2d071d2..cb97c13a8 100755 --- a/components/fpspreadsheet/xlsbiff2.pas +++ b/components/fpspreadsheet/xlsbiff2.pas @@ -89,7 +89,6 @@ type procedure WriteXFFieldsForFormattingStyles(AStream: TStream); procedure WriteXFRecords(AStream: TStream); protected - procedure AddDefaultFormats(); override; procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override; procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); override; procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override; @@ -642,20 +641,6 @@ end; { TsSpreadBIFF2Writer } -procedure TsSpreadBIFF2Writer.AddDefaultFormats(); -begin - NextXFIndex := 16; //21; - - SetLength(FFormattingStyles, 1); - - // XF0..XF14: Normal style, Row Outline level 1..7, - // Column Outline level 1..7. - - // XF15 - Default cell format, no formatting (4.6.2) - FFormattingStyles[0].UsedFormattingFields := []; - FFormattingStyles[0].Row := 15; -end; - function TsSpreadBIFF2Writer.FindXFIndex(ACell: PCell): Word; var i: Integer; @@ -830,7 +815,8 @@ var lHorAlign: TsHorAlignment; fmt: String; begin - // The first style was already added (see AddDefaultFormats) + // The loop starts with the first style added manually. + // First style was already added (see AddDefaultFormats) for i := 1 to Length(FFormattingStyles) - 1 do begin // Default styles lFontIndex := 0; diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas index 1712d0a27..77f4f12c0 100755 --- a/components/fpspreadsheet/xlsbiff5.pas +++ b/components/fpspreadsheet/xlsbiff5.pas @@ -108,7 +108,6 @@ type private WorkBookEncoding: TsEncoding; protected - procedure AddDefaultFormats; override; { Record writing methods } procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override; @@ -332,20 +331,6 @@ const { TsSpreadBIFF5Writer } -procedure TsSpreadBIFF5Writer.AddDefaultFormats(); -begin - NextXFIndex := 16; - - SetLength(FFormattingStyles, 1); - - // XF0..XF14: Normal style, Row Outline level 1..7, - // Column Outline level 1..7. - - // XF15 - Default cell format, no formatting (4.6.2) - FFormattingStyles[0].UsedFormattingFields := []; - FFormattingStyles[0].Row := 15; -end; - {******************************************************************* * TsSpreadBIFF5Writer.WriteToFile () * diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index db55421b8..babee06a0 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -110,7 +110,6 @@ type procedure WriteXFIndex(AStream: TStream; ACell: PCell); procedure WriteXFFieldsForFormattingStyles(AStream: TStream); protected - procedure AddDefaultFormats(); override; { Record writing methods } procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override; @@ -473,24 +472,6 @@ begin end; end; -{@@ - These are default style formats which are added as XF fields regardless of being used - in the document or not. -} -procedure TsSpreadBIFF8Writer.AddDefaultFormats(); -begin - NextXFIndex := 16; - - SetLength(FFormattingStyles, 1); - - // XF0..XF14: Normal style, Row Outline level 1..7, - // Column Outline level 1..7. - - // XF15 - Default cell format, no formatting (4.6.2) - FFormattingStyles[0].UsedFormattingFields := []; - FFormattingStyles[0].Row := 15; -end; - {******************************************************************* * TsSpreadBIFF8Writer.WriteToFile () * diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas index 7045b860a..ad38463dd 100644 --- a/components/fpspreadsheet/xlscommon.pas +++ b/components/fpspreadsheet/xlscommon.pas @@ -364,6 +364,7 @@ type FDateMode: TDateMode; FLastRow: Integer; FLastCol: Word; + procedure AddDefaultFormats; override; procedure GetLastRowCallback(ACell: PCell; AStream: TStream); function GetLastRowIndex(AWorksheet: TsWorksheet): Integer; procedure GetLastColCallback(ACell: PCell; AStream: TStream); @@ -865,6 +866,27 @@ begin inherited Destroy; end; +{ These are default style formats which are added as XF fields regardless of + being used in the document or not. + Currently, only one additional default format is supported ("bold"). + Here are the changes to be made when extending this list: + - SetLength(FFormattingstyles, ) +} +procedure TsSpreadBIFFWriter.AddDefaultFormats(); +begin + SetLength(FFormattingStyles, 1); + + // XF0..XF14: Normal style, Row Outline level 1..7, + // Column Outline level 1..7. + + // XF15 - Default cell format, no formatting (4.6.2) + FFormattingStyles[0].UsedFormattingFields := []; + FFormattingStyles[0].Row := 15; + + NextXFIndex := 15 + Length(FFormattingStyles); + // "15" is the index of the last pre-defined xf record +end; + function TsSpreadBIFFWriter.FormulaElementKindToExcelTokenID( AElementKind: TFEKind; out ASecondaryID: Word): Word; const