diff --git a/components/fpspreadsheet/examples/opendocdemo/oocreated.ods b/components/fpspreadsheet/examples/opendocdemo/oocreated.ods
new file mode 100644
index 000000000..60d3cf5d4
Binary files /dev/null and b/components/fpspreadsheet/examples/opendocdemo/oocreated.ods differ
diff --git a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
index 9ce023901..cbc91f793 100644
--- a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
+++ b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
@@ -11,7 +11,7 @@
-
+
@@ -33,13 +33,13 @@
-
+
-
-
+
+
@@ -70,7 +70,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
@@ -97,7 +97,7 @@
-
+
@@ -116,9 +116,9 @@
-
-
-
+
+
+
@@ -131,8 +131,8 @@
-
-
+
+
@@ -142,131 +142,139 @@
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
diff --git a/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh b/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh
new file mode 100755
index 000000000..fde5b79f9
--- /dev/null
+++ b/components/fpspreadsheet/examples/opendocdemo/unzipoocreated.sh
@@ -0,0 +1 @@
+unzip oocreated.ods
\ No newline at end of file
diff --git a/components/fpspreadsheet/examples/opendocdemo/ziptest.sh b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh
new file mode 100755
index 000000000..9fa2d4d14
--- /dev/null
+++ b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh
@@ -0,0 +1,4 @@
+cd test
+zip test.ods *
+mv test.ods ../
+cd ..
\ No newline at end of file
diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas
index e312dcc38..2b2ee492c 100755
--- a/components/fpspreadsheet/fpsopendocument.pas
+++ b/components/fpspreadsheet/fpsopendocument.pas
@@ -72,8 +72,8 @@ const
OOXML_PATH_SETTINGS = 'settings.xml';
OOXML_PATH_STYLES = 'styles.xml';
OOXML_PATH_MIMETYPE = 'mimetype.xml';
- OPENDOC_PATH_METAINF = 'META-INF\';
- OPENDOC_PATH_METAINF_MANIFEST = 'META-INF\manifest.xml';
+ OPENDOC_PATH_METAINF = 'META-INF' + PathDelim;
+ OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + PathDelim + 'manifest.xml';
{ OpenDocument schemas constants }
SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
@@ -261,30 +261,54 @@ procedure TsSpreadOpenDocWriter.WriteWorksheet(CurSheet: TsWorksheet);
var
j, k: Integer;
CurCell: PCell;
+ CurRow: array of PCell;
+ LastColNum: Cardinal;
begin
+ LastColNum := CurSheet.GetLastColNumber;
+
// Header
FContent := FContent +
' ' + LineEnding +
' ' + LineEnding;
+ IntToStr(LastColNum) + '" table:default-cell-style-name="Default"/>' + LineEnding;
- // The cells need to be written in order, row by row
- for j := 0 to CurSheet.GetLastRowNumber do
+ // The cells need to be written in order, row by row, cell by cell
+ for j := 1 to CurSheet.GetLastRowNumber do
begin
FContent := FContent +
' ' + LineEnding;
+ // First make an array with the cells of this row in their respective order
+ // nil pointers indicate empty cells, so it's necessary to initialize the array
+ SetLength(CurRow, LastColNum);
+ for k := 0 to LastColNum - 1 do CurRow[k] := nil;
+
+ // Now fill the array with the cells in their proper place
for k := 0 to CurSheet.FCells.Count - 1 do
begin
CurCell := CurSheet.FCells.Items[k];
- if CurCell^.Row = j then WriteCellCallback(CurCell, nil);
+ if CurCell^.Row = j then CurRow[CurCell^.Col - 1] := CurCell;
end;
- FContent := FContent + ' ' + LineEnding;
+ for k := 0 to LastColNum - 1 do
+ begin
+ CurCell := CurRow[k];
+
+ if CurCell = nil then
+ FContent := FContent + '' + LineEnding
+ else WriteCellCallback(CurCell, nil);
+ end;
+
+ FContent := FContent +
+ ' ' + LineEnding;
end;
+ // Clean up
+ SetLength(CurRow, 0);
+
// Footer
- FContent := FContent + ' ' + LineEnding;
+ FContent := FContent +
+ ' ' + LineEnding;
end;
{*******************************************************************
@@ -346,15 +370,6 @@ begin
WriteStringToFile(TempDir + OPENDOC_PATH_METAINF_MANIFEST, FMetaInfManifest);
end;
-{*******************************************************************
-* TsSpreadOOXMLWriter.WriteToStream ()
-*
-* DESCRIPTION: Writes an Excel 2 file to a stream
-*
-* Excel 2.x files support only one Worksheet per Workbook,
-* so only the first will be written.
-*
-*******************************************************************}
procedure TsSpreadOpenDocWriter.WriteToStream(AStream: TStream; AData: TsWorkbook);
begin
@@ -377,8 +392,8 @@ procedure TsSpreadOpenDocWriter.WriteNumber(AStream: TStream; const ARow,
begin
// The row should already be the correct one
FContent := FContent +
- ' ' + LineEnding +
- ' 1' + LineEnding +
+ ' ' + LineEnding +
+ ' ' + FloatToStr(AValue) + '' + LineEnding +
' ' + LineEnding;
end;