diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index 18f2af5eb..9155f61e5 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -54,7 +54,7 @@ type FSSheets: array of TStringStream; FCurSheetNum: Integer; { Routines to write those files } - procedure WriteGlobalFiles; + procedure WriteGlobalFiles(AData: TsWorkbook); procedure WriteContent(AData: TsWorkbook); procedure WriteWorksheet(CurSheet: TsWorksheet); public @@ -108,7 +108,9 @@ const { TsSpreadOOXMLWriter } -procedure TsSpreadOOXMLWriter.WriteGlobalFiles; +procedure TsSpreadOOXMLWriter.WriteGlobalFiles(AData: TsWorkbook); +var + i: Integer; begin // WriteCellsToStream(AStream, AData.GetFirstWorksheet.FCells); @@ -117,8 +119,14 @@ begin '' + LineEnding + ' ' + LineEnding + ' ' + LineEnding + - ' ' + LineEnding + - ' ' + LineEnding + + ' ' + LineEnding; + for i := 1 to AData.GetWorksheetCount do + begin + FContentTypes := FContentTypes + + Format(' ', [i, MIME_WORKSHEET]) + LineEnding; + end; + + FContentTypes := FContentTypes + ' ' + LineEnding + ' ' + LineEnding + ''; @@ -231,18 +239,6 @@ begin '' + LineEnding + FSharedStrings + -{ ' ' + LineEnding + - ' First' + LineEnding + - ' ' + LineEnding + - ' ' + LineEnding + - ' Second' + LineEnding + - ' ' + LineEnding + - ' ' + LineEnding + - ' Third' + LineEnding + - ' ' + LineEnding + - ' ' + LineEnding + - ' Fourth' + LineEnding + - ' ' + LineEnding + } ''; end; @@ -376,7 +372,7 @@ var begin { Fill the strings with the contents of the files } - WriteGlobalFiles(); + WriteGlobalFiles(AData); WriteContent(AData); { Write the data to streams } @@ -432,7 +428,7 @@ var begin { Fill the strings with the contents of the files } - WriteGlobalFiles(); + WriteGlobalFiles(AData); WriteContent(AData); { Write the data to streams } @@ -490,11 +486,16 @@ procedure TsSpreadOOXMLWriter.WriteLabel(AStream: TStream; const ARow, var CellPosText: string; begin + FSharedStrings := FSharedStrings + + ' ' + LineEnding + + Format(' %s', [AValue]) + LineEnding + + ' ' + LineEnding; + + Inc(FSharedStringsCount); + CellPosText := TsWorksheet.CellPosToText(ARow, ACol); FSheets[FCurSheetNum] := FSheets[FCurSheetNum] + - Format(' ', [CellPosText]) + LineEnding + - Format(' %s', [AValue]) + LineEnding + - ' ' + LineEnding; + Format(' %d', [CellPosText, FSharedStringsCount]) + LineEnding; end; { @@ -507,9 +508,7 @@ var begin CellPosText := TsWorksheet.CellPosToText(ARow, ACol); FSheets[FCurSheetNum] := FSheets[FCurSheetNum] + - Format(' ', [CellPosText]) + LineEnding + - Format(' %f', [AValue]) + LineEnding + - ' ' + LineEnding; + Format(' %f', [CellPosText, AValue]) + LineEnding; end; {