diff --git a/components/fpspreadsheet/examples/excel2demo/excel2write.lpi b/components/fpspreadsheet/examples/excel2demo/excel2write.lpi
index 51672116a..0cf19942b 100644
--- a/components/fpspreadsheet/examples/excel2demo/excel2write.lpi
+++ b/components/fpspreadsheet/examples/excel2demo/excel2write.lpi
@@ -38,8 +38,8 @@
-
-
+
+
diff --git a/components/fpspreadsheet/examples/excel2demo/excel2write.lpr b/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
index 6b377501d..931e786b3 100644
--- a/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
+++ b/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
@@ -25,16 +25,16 @@ begin
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
// Write some number cells
- MyWorksheet.WriteNumber(1, 1, 1.0);
- MyWorksheet.WriteNumber(1, 2, 2.0);
- MyWorksheet.WriteNumber(1, 3, 3.0);
- MyWorksheet.WriteNumber(1, 4, 4.0);
+ MyWorksheet.WriteNumber(0, 0, 1.0);
+ MyWorksheet.WriteNumber(0, 1, 2.0);
+ MyWorksheet.WriteNumber(0, 2, 3.0);
+ MyWorksheet.WriteNumber(0, 3, 4.0);
// Write some string cells
- MyWorksheet.WriteUTF8Text(2, 1, 'First');
- MyWorksheet.WriteUTF8Text(2, 2, 'Second');
- MyWorksheet.WriteUTF8Text(2, 3, 'Third');
- MyWorksheet.WriteUTF8Text(2, 4, 'Fourth');
+ MyWorksheet.WriteUTF8Text(1, 0, 'First');
+ MyWorksheet.WriteUTF8Text(1, 1, 'Second');
+ MyWorksheet.WriteUTF8Text(1, 2, 'Third');
+ MyWorksheet.WriteUTF8Text(1, 3, 'Fourth');
// Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel2);
diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi
index c4ef7f100..96adb0ca9 100644
--- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi
+++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi
@@ -38,7 +38,7 @@
-
+
diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
index 1b676b6ea..accb4d33f 100644
--- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
+++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
@@ -28,10 +28,10 @@ begin
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
// Write some number cells
- MyWorksheet.WriteNumber(1, 1, 1.0);
- MyWorksheet.WriteNumber(1, 2, 2.0);
- MyWorksheet.WriteNumber(1, 3, 3.0);
- MyWorksheet.WriteNumber(1, 4, 4.0);
+ MyWorksheet.WriteNumber(0, 0, 1.0);
+ MyWorksheet.WriteNumber(0, 1, 2.0);
+ MyWorksheet.WriteNumber(0, 2, 3.0);
+ MyWorksheet.WriteNumber(0, 3, 4.0);
{ Uncommend this to test large XLS files
for i := 2 to 20 do
@@ -47,22 +47,22 @@ begin
// or, in RPN: A1, B1, +
SetLength(MyFormula, 3);
MyFormula[0].TokenID := INT_EXCEL_TOKEN_TREFV; {A1}
- MyFormula[0].Col := 1;
- MyFormula[0].Row := 1;
+ MyFormula[0].Col := 0;
+ MyFormula[0].Row := 0;
MyFormula[1].TokenID := INT_EXCEL_TOKEN_TREFV; {B1}
- MyFormula[1].Col := 2;
- MyFormula[1].Row := 1;
+ MyFormula[1].Col := 1;
+ MyFormula[1].Row := 0;
MyFormula[2].TokenID := INT_EXCEL_TOKEN_TADD; {+}
- MyWorksheet.WriteRPNFormula(1, 5, MyFormula);
+ MyWorksheet.WriteRPNFormula(0, 4, MyFormula);
// Creates a new worksheet
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');
// Write some string cells
- MyWorksheet.WriteUTF8Text(1, 1, 'First');
- MyWorksheet.WriteUTF8Text(1, 2, 'Second');
- MyWorksheet.WriteUTF8Text(1, 3, 'Third');
- MyWorksheet.WriteUTF8Text(1, 4, 'Fourth');
+ MyWorksheet.WriteUTF8Text(0, 0, 'First');
+ MyWorksheet.WriteUTF8Text(0, 1, 'Second');
+ MyWorksheet.WriteUTF8Text(0, 2, 'Third');
+ MyWorksheet.WriteUTF8Text(0, 3, 'Fourth');
// Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, sfExcel5);
diff --git a/components/fpspreadsheet/examples/opendocdemo/oocreated.ods b/components/fpspreadsheet/examples/opendocdemo/oocreated.ods
index 60d3cf5d4..bfe2e21bd 100644
Binary files a/components/fpspreadsheet/examples/opendocdemo/oocreated.ods 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 cbc91f793..29f5c81c9 100644
--- a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
+++ b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
@@ -11,7 +11,7 @@
-
+
@@ -38,8 +38,8 @@
-
-
+
+
@@ -68,8 +68,8 @@
-
-
+
+
@@ -86,8 +86,8 @@
-
-
+
+
@@ -116,10 +116,10 @@
-
-
+
+
-
+
@@ -131,10 +131,10 @@
-
-
+
+
-
+
@@ -143,7 +143,7 @@
-
+
@@ -151,130 +151,130 @@
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpr b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpr
index 75ab0d688..8440a17c8 100644
--- a/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpr
+++ b/components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpr
@@ -28,10 +28,10 @@ begin
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
// Write some number cells
- MyWorksheet.WriteNumber(1, 1, 1.0);
- MyWorksheet.WriteNumber(1, 2, 2.0);
- MyWorksheet.WriteNumber(1, 3, 3.0);
- MyWorksheet.WriteNumber(1, 4, 4.0);
+ MyWorksheet.WriteNumber(0, 0, 1.0);
+ MyWorksheet.WriteNumber(0, 1, 2.0);
+ MyWorksheet.WriteNumber(0, 2, 3.0);
+ MyWorksheet.WriteNumber(0, 3, 4.0);
{ Uncommend this to test large XLS files
for i := 2 to 20 do
@@ -57,13 +57,13 @@ begin
// Creates a new worksheet
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');
+ *)
// Write some string cells
- MyWorksheet.WriteUTF8Text(1, 1, 'First');
- MyWorksheet.WriteUTF8Text(1, 2, 'Second');
- MyWorksheet.WriteUTF8Text(1, 3, 'Third');
- MyWorksheet.WriteUTF8Text(1, 4, 'Fourth');
- *)
+ MyWorksheet.WriteUTF8Text(1, 0, 'First');
+ MyWorksheet.WriteUTF8Text(1, 1, 'Second');
+ MyWorksheet.WriteUTF8Text(1, 2, 'Third');
+ MyWorksheet.WriteUTF8Text(1, 3, 'Fourth');
// Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test', sfOpenDocument);
diff --git a/components/fpspreadsheet/examples/opendocdemo/ziptest.sh b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh
index 9fa2d4d14..0ad64057d 100755
--- a/components/fpspreadsheet/examples/opendocdemo/ziptest.sh
+++ b/components/fpspreadsheet/examples/opendocdemo/ziptest.sh
@@ -1,4 +1,4 @@
cd test
-zip test.ods *
+zip -r 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 2b2ee492c..0a9eea3f2 100755
--- a/components/fpspreadsheet/fpsopendocument.pas
+++ b/components/fpspreadsheet/fpsopendocument.pas
@@ -71,7 +71,7 @@ const
OOXML_PATH_META = 'meta.xml';
OOXML_PATH_SETTINGS = 'settings.xml';
OOXML_PATH_STYLES = 'styles.xml';
- OOXML_PATH_MIMETYPE = 'mimetype.xml';
+ OOXML_PATH_MIMETYPE = 'mimetype';
OPENDOC_PATH_METAINF = 'META-INF' + PathDelim;
OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + PathDelim + 'manifest.xml';
@@ -270,27 +270,28 @@ begin
FContent := FContent +
' ' + LineEnding +
' ' + LineEnding;
+ IntToStr(LastColNum + 1) + '" table:default-cell-style-name="Default"/>' + LineEnding;
// The cells need to be written in order, row by row, cell by cell
- for j := 1 to CurSheet.GetLastRowNumber do
+ for j := 0 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;
+ SetLength(CurRow, LastColNum + 1);
+ for k := 0 to LastColNum 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 CurRow[CurCell^.Col - 1] := CurCell;
+ if CurCell^.Row = j then CurRow[CurCell^.Col] := CurCell;
end;
- for k := 0 to LastColNum - 1 do
+ // And now write all cells from this row
+ for k := 0 to LastColNum do
begin
CurCell := CurRow[k];
@@ -384,7 +385,11 @@ end;
procedure TsSpreadOpenDocWriter.WriteLabel(AStream: TStream; const ARow,
ACol: Word; const AValue: string);
begin
-
+ // The row should already be the correct one
+ FContent := FContent +
+ ' ' + LineEnding +
+ ' ' + AValue + '' + LineEnding +
+ ' ' + LineEnding;
end;
procedure TsSpreadOpenDocWriter.WriteNumber(AStream: TStream; const ARow,
diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas
index 79bc24832..2bdb5400c 100755
--- a/components/fpspreadsheet/fpspreadsheet.pas
+++ b/components/fpspreadsheet/fpspreadsheet.pas
@@ -304,9 +304,6 @@ end;
}
function TsWorksheet.GetCell(ARow, ACol: Cardinal): PCell;
begin
- // First make sure the row and col values are valid
- if (ARow = 0) or (ACol = 0) then raise Exception.Create('FPSpreadsheet: Row and Col numbers cannot be zero');
-
Result := FindCell(ARow, ACol);
if (Result = nil) then
diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas
index cbb1ab89b..8287bca86 100755
--- a/components/fpspreadsheet/xlsbiff2.pas
+++ b/components/fpspreadsheet/xlsbiff2.pas
@@ -13,8 +13,7 @@ To ensure a properly formed file, the following order must be respected:
2nd to Nth record: Any record
Last record: EOF
-The row and column numbering in BIFF files is zero-based,
-while in FPSpreadsheet it is 1-based, so this needs to be considered.
+The row and column numbering in BIFF files is zero-based.
Excel file format specification obtained from:
@@ -85,10 +84,6 @@ const
INT_EXCEL_CHART = $0020;
INT_EXCEL_MACRO_SHEET = $0040;
- { Marks differences between the BIFF format and FPSpreadsheet }
- INT_FPS_BIFF_ROW_DELTA = 1;
- INT_FPS_BIFF_COL_DELTA = 1;
-
{ TsSpreadBIFF2Writer }
{*******************************************************************
@@ -172,8 +167,8 @@ begin
AStream.WriteWord(WordToLE(17 + RPNLength));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ BIFF2 Attributes }
AStream.WriteByte($0);
@@ -218,8 +213,8 @@ begin
INT_EXCEL_TOKEN_TREFR, INT_EXCEL_TOKEN_TREFV, INT_EXCEL_TOKEN_TREFA:
begin
- AStream.WriteWord( (AFormula[i].Row - INT_FPS_BIFF_ROW_DELTA) and MASK_EXCEL_ROW);
- AStream.WriteByte(AFormula[i].Col - INT_FPS_BIFF_COL_DELTA);
+ AStream.WriteWord(AFormula[i].Row and MASK_EXCEL_ROW);
+ AStream.WriteByte(AFormula[i].Col);
Inc(RPNLength, 3);
end;
@@ -257,8 +252,8 @@ begin
AStream.WriteWord(WordToLE(8 + L));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ BIFF2 Attributes }
AStream.WriteByte($0);
@@ -286,8 +281,8 @@ begin
AStream.WriteWord(WordToLE(15));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ BIFF2 Attributes }
AStream.WriteByte($0);
@@ -351,8 +346,8 @@ var
AStrValue: ansistring;
begin
{ BIFF Record data }
- ARow := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_ROW_DELTA;
- ACol := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_COL_DELTA;
+ ARow := WordLEToN(AStream.ReadWord);
+ ACol := WordLEToN(AStream.ReadWord);
{ BIFF2 Attributes }
AStream.ReadByte();
@@ -375,8 +370,8 @@ var
AValue: Double;
begin
{ BIFF Record data }
- ARow := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_ROW_DELTA;
- ACol := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_COL_DELTA;
+ ARow := WordLEToN(AStream.ReadWord);
+ ACol := WordLEToN(AStream.ReadWord);
{ BIFF2 Attributes }
AStream.ReadByte();
diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas
index 564aadb20..070e8f7f8 100755
--- a/components/fpspreadsheet/xlsbiff5.pas
+++ b/components/fpspreadsheet/xlsbiff5.pas
@@ -31,8 +31,7 @@ DIMENSIONS
WINDOW2
EOF
-The row and column numbering in BIFF files is zero-based,
-while in FPSpreadsheet it is 1-based, so this needs to be considered.
+The row and column numbering in BIFF files is zero-based.
Excel file format specification obtained from:
@@ -206,10 +205,6 @@ const
MASK_XF_VERT_ALIGN = $70;
- { Marks differences between the BIFF format and FPSpreadsheet }
- INT_FPS_BIFF_ROW_DELTA = 1;
- INT_FPS_BIFF_COL_DELTA = 1;
-
{
Exported functions
}
@@ -557,8 +552,8 @@ begin
AStream.WriteWord(WordToLE(22 + RPNLength));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ Index to XF Record }
AStream.WriteWord($0000);
@@ -603,8 +598,8 @@ begin
INT_EXCEL_TOKEN_TREFR, INT_EXCEL_TOKEN_TREFV, INT_EXCEL_TOKEN_TREFA:
begin
- AStream.WriteWord( (AFormula[i].Row - INT_FPS_BIFF_ROW_DELTA) and MASK_EXCEL_ROW);
- AStream.WriteByte(AFormula[i].Col - INT_FPS_BIFF_COL_DELTA);
+ AStream.WriteWord(AFormula[i].Row and MASK_EXCEL_ROW);
+ AStream.WriteByte(AFormula[i].Col);
Inc(RPNLength, 3);
end;
@@ -674,8 +669,8 @@ begin
AStream.WriteWord(WordToLE(8 + L));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ Index to XF record }
AStream.WriteWord(15);
@@ -701,8 +696,8 @@ begin
AStream.WriteWord(WordToLE(14));
{ BIFF Record data }
- AStream.WriteWord(WordToLE(ARow - INT_FPS_BIFF_ROW_DELTA));
- AStream.WriteWord(WordToLE(ACol - INT_FPS_BIFF_COL_DELTA));
+ AStream.WriteWord(WordToLE(ARow));
+ AStream.WriteWord(WordToLE(ACol));
{ Index to XF record }
AStream.WriteWord($0);
@@ -1060,8 +1055,8 @@ var
AValue: Double;
begin
{ BIFF Record data }
- ARow := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_ROW_DELTA;
- ACol := WordLEToN(AStream.ReadWord) + INT_FPS_BIFF_COL_DELTA;
+ ARow := WordLEToN(AStream.ReadWord);
+ ACol := WordLEToN(AStream.ReadWord);
{ Index to XF record }
AStream.ReadWord();