diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas
index c9474f983..f86d2fa18 100755
--- a/components/fpspreadsheet/fpsopendocument.pas
+++ b/components/fpspreadsheet/fpsopendocument.pas
@@ -184,6 +184,7 @@ type
function WriteBorderStyleXMLAsString(const AFormat: TsCellFormat): String;
function WriteCommentXMLAsString(AComment: String): String;
function WriteDefaultFontXMLAsString: String;
+ function WriteDefaultGraphicStyleXMLAsString: String; overload;
function WriteFontStyleXMLAsString(const AFormat: TsCellFormat): String; overload;
function WriteFontStyleXMLAsString(AFont: TsFont): String; overload;
function WriteHeaderFooterFontXMLAsString(AFont: TsHeaderFooterFont): String;
@@ -4335,6 +4336,11 @@ begin
'',
WriteDefaultFontXMLAsString,
'');
+ if FWorkbook.GetEmbeddedStreamCount > 0 then
+ AppendToStream(FSStyles,
+ '',
+ WriteDefaultGraphicStyleXMLAsString,
+ '');
AppendToStream(FSStyles,
'');
@@ -5496,6 +5502,28 @@ begin
);
end;
+function TsSpreadOpenDocWriter.WriteDefaultGraphicStyleXMLAsString: String;
+begin
+ Result :=
+ '' +
+ ''+
+ ''+
+ ''+
+ '';
+end;
+
procedure TsSpreadOpenDocWriter.WriteError(AStream: TStream;
const ARow, ACol: Cardinal; const AValue: TsErrorValue; ACell: PCell);
var
diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas
index 052ada39b..2dbb8a890 100755
--- a/components/fpspreadsheet/xlsbiff2.pas
+++ b/components/fpspreadsheet/xlsbiff2.pas
@@ -106,6 +106,7 @@ type
procedure WriteBool(AStream: TStream; const ARow, ACol: Cardinal;
const AValue: Boolean; ACell: PCell); override;
procedure WriteCodePage(AStream: TStream; ACodePage: String); override;
+ procedure WriteDefaultRowHeight(AStream: TStream; AWorksheet: TsWorksheet);
procedure WriteError(AStream: TStream; const ARow, ACol: Cardinal;
const AValue: TsErrorValue; ACell: PCell); override;
procedure WriteFORMAT(AStream: TStream; ANumFormatStr: String;
@@ -179,7 +180,7 @@ const
INT_EXCEL_ID_FORMAT = $001E;
INT_EXCEL_ID_FORMATCOUNT = $001F;
INT_EXCEL_ID_COLWIDTH = $0024;
- INT_EXCEL_ID_DEFROWHEIGHT = 00025;
+ INT_EXCEL_ID_DEFROWHEIGHT = $0025;
INT_EXCEL_ID_WINDOW2 = $003E;
INT_EXCEL_ID_XF = $0043;
INT_EXCEL_ID_IXFE = $0044;
@@ -1310,6 +1311,7 @@ begin
WriteCodePage(AStream, FCodePage);
WritePrintHeaders(AStream);
WritePrintGridLines(AStream);
+ WriteDefaultRowHeight(AStream, FWorksheet);
WriteFonts(AStream);
// Page settings block
@@ -1323,6 +1325,8 @@ begin
WriteFormatCount(AStream);
WriteNumFormats(AStream);
WriteXFRecords(AStream);
+
+ WriteDefaultColWidth(AStream, FWorksheet);
WriteColWidths(AStream);
WriteDimensions(AStream, FWorksheet);
WriteRows(AStream, FWorksheet);
@@ -1760,6 +1764,27 @@ begin
AStream.WriteBuffer(rec, SizeOf(rec));
end;
+{@@ ----------------------------------------------------------------------------
+ Writes an Excel 2 DEFAULTROWHEIGHT record
+ Specifies the default height and default flags for rows that do not have a
+ corresponding ROW record
+-------------------------------------------------------------------------------}
+procedure TsSpreadBIFF2Writer.WriteDefaultRowHeight(AStream: TStream;
+ AWorksheet: TsWorksheet);
+var
+ h: Single;
+begin
+ { BIFF record header }
+ WriteBIFFHeader(AStream, INT_EXCEL_ID_DEFROWHEIGHT, 2);
+
+ { Default height for unused rows, in twips = 1/20 of a point
+ Bits 0-14: Default height for unused rows, in twips
+ Bit 15 = 1: Row height not changed manually }
+ h := (AWorksheet.DefaultRowHeight + ROW_HEIGHT_CORRECTION) * FWorkbook.GetDefaultFontSize;
+ AStream.WriteWord(WordToLE(PtsToTwips(h)));
+end;
+
+
{@@ ----------------------------------------------------------------------------
Writes an Excel 2 ERROR cell record.
-------------------------------------------------------------------------------}
diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas
index 604a52b46..526971b44 100755
--- a/components/fpspreadsheet/xlsbiff5.pas
+++ b/components/fpspreadsheet/xlsbiff5.pas
@@ -1144,6 +1144,7 @@ begin
WriteIndex(AStream);
WritePrintHeaders(AStream);
WritePrintGridLines(AStream);
+ WriteDefaultRowHeight(AStream, FWorksheet);
WriteSheetPR(AStream);
// Page settings block
@@ -1157,6 +1158,7 @@ begin
WriteMargin(AStream, 3); // 3 = bottom margin
WritePageSetup(AStream);
+ WriteDefaultColWidth(AStream, FWorksheet);
WriteColInfos(AStream, FWorksheet);
WriteDimensions(AStream, FWorksheet);
WriteWindow2(AStream, FWorksheet);
diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas
index 42c5a913c..625d931f5 100755
--- a/components/fpspreadsheet/xlsbiff8.pas
+++ b/components/fpspreadsheet/xlsbiff8.pas
@@ -2121,6 +2121,7 @@ begin
WriteIndex(AStream);
WritePrintHeaders(AStream);
WritePrintGridLines(AStream);
+ WriteDefaultRowHeight(AStream, FWorksheet);
WriteSheetPR(AStream);
// Page setting block
@@ -2134,6 +2135,7 @@ begin
WriteMargin(AStream, 3); // 3 = bottom margin
WritePageSetup(AStream);
+ WriteDefaultColWidth(AStream, FWorksheet);
WriteColInfos(AStream, FWorksheet);
WriteDimensions(AStream, FWorksheet);
//WriteRowAndCellBlock(AStream, sheet);
diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas
index 233d7065a..469fcd251 100644
--- a/components/fpspreadsheet/xlscommon.pas
+++ b/components/fpspreadsheet/xlscommon.pas
@@ -530,6 +530,10 @@ type
// Writes out a TIME/DATE/TIMETIME
procedure WriteDateTime(AStream: TStream; const ARow, ACol: Cardinal;
const AValue: TDateTime; ACell: PCell); override;
+ // Writes out a DEFCOLWIDTH record
+ procedure WriteDefaultColWidth(AStream: TStream; AWorksheet: TsWorksheet);
+ // Writes out a DEFAULTROWHEIGHT record
+ procedure WriteDefaultRowHeight(AStream: TStream; AWorksheet: TsWorksheet);
// Writes out DEFINEDNAMES records
procedure WriteDefinedName(AStream: TStream; AWorksheet: TsWorksheet;
const AName: String; AIndexToREF: Word); virtual;
@@ -3296,6 +3300,50 @@ begin
WriteNumber(AStream, ARow, ACol, ExcelDateSerial, ACell);
end;
+{@@ ----------------------------------------------------------------------------
+ Writes a DEFCOLWIDTH record.
+ Specifies the default column width for columns that do not have a
+ specific width set using the records COLWIDTH (BIFF2), COLINFO (BIFF3-BIFF8),
+ or STANDARDWIDTH.
+ Valud for BIFF2-BIFF8.
+-------------------------------------------------------------------------------}
+procedure TsSpreadBIFFWriter.WriteDefaultColWidth(AStream: TStream;
+ AWorksheet: TsWorksheet);
+begin
+ { BIFF record header }
+ WriteBIFFHeader(AStream, INT_EXCEL_ID_DEFCOLWIDTH, 2);
+
+ { Column width in characters, using the width of the zero character
+ from default font (first FONT record in the file). }
+ AStream.WriteWord(round(FWorksheet.DefaultColWidth));
+end;
+
+{@@ ----------------------------------------------------------------------------
+ Writes a DEFAULTROWHEIGHT record
+ Specifies the default height and default flags for rows that do not have a
+ corresponding ROW record
+ Valid for BIFF3-BIFF8.
+-------------------------------------------------------------------------------}
+procedure TsSpreadBIFFWriter.WriteDefaultRowHeight(AStream: TStream;
+ AWorksheet: TsWorksheet);
+var
+ h: Single;
+begin
+ { BIFF record header }
+ WriteBIFFHeader(AStream, INT_EXCEL_ID_DEFROWHEIGHT, 4);
+
+ { Options:
+ Bit 1 = Row height and default font height do not match
+ Bit 2 = Row is hidden
+ Bit 4 = Additional space above the row
+ Bit 8 = Additional space below the row }
+ AStream.WriteWord(WordToLE($0001));
+
+ { Default height for unused rows, in twips = 1/20 of a point }
+ h := (AWorksheet.DefaultRowHeight + ROW_HEIGHT_CORRECTION) * FWorkbook.GetDefaultFontSize;
+ AStream.WriteWord(WordToLE(PtsToTwips(h)));
+end;
+
procedure TsSpreadBIFFWriter.WriteDefinedName(AStream: TStream;
AWorksheet: TsWorksheet; const AName: String; AIndexToREF: Word);
begin
diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas
index 3004fce66..69bd4a352 100755
--- a/components/fpspreadsheet/xlsxooxml.pas
+++ b/components/fpspreadsheet/xlsxooxml.pas
@@ -148,6 +148,7 @@ type
procedure WritePageSetup(AStream: TStream; AWorksheet: TsWorksheet);
procedure WritePrintOptions(AStream: TStream; AWorksheet: TsWorksheet);
procedure WriteSheetData(AStream: TStream; AWorksheet: TsWorksheet);
+ procedure WriteSheetFormatPr(AStream: TStream; AWorksheet: TsWorksheet);
procedure WriteSheetPr(AStream: TStream; AWorksheet: TsWorksheet);
procedure WriteSheetViews(AStream: TStream; AWorksheet: TsWorksheet);
procedure WriteStyleList(AStream: TStream; ANodeName: String);
@@ -3020,6 +3021,19 @@ begin
'');
end;
+procedure TsSpreadOOXMLWriter.WriteSheetFormatPr(AStream: TStream;
+ AWorksheet: TsWorksheet);
+var
+ w, h: Single;
+begin
+ w := AWorksheet.DefaultColWidth;
+ h := (AWorksheet.DefaultRowHeight + ROW_HEIGHT_CORRECTION) * Workbook.GetDefaultFontSize;
+ AppendToStream(AStream, Format(
+ '',
+ [w, h],
+ FPointSeparatorSettings));
+end;
+
procedure TsSpreadOOXMLWriter.WriteSheetPr(AStream: TStream; AWorksheet: TsWorksheet);
var
s: String;
@@ -4194,6 +4208,7 @@ begin
WriteSheetPr(FSSheets[FCurSheetNum], AWorksheet);
WriteDimension(FSSheets[FCurSheetNum], AWorksheet);
WriteSheetViews(FSSheets[FCurSheetNum], AWorksheet);
+ WriteSheetFormatPr(FSSheets[FCurSheetNum], AWorksheet);
WriteCols(FSSheets[FCurSheetNum], AWorksheet);
WriteSheetData(FSSheets[FCurSheetNum], AWorksheet);
WriteMergedCells(FSSheets[FCurSheetNum], AWorksheet);