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 @@ <UseAppBundle Value="False"/> - <ActiveEditorIndexAtStart Value="1"/> + <ActiveEditorIndexAtStart Value="6"/> </General> <VersionInfo> <ProjectVersion Value=""/> @@ -38,8 +38,8 @@ <Filename Value="opendocwrite.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="opendocwrite"/> - <CursorPos X="9" Y="30"/> - <TopLine Value="8"/> + <CursorPos X="26" Y="35"/> + <TopLine Value="21"/> <EditorIndex Value="0"/> <UsageCount Value="309"/> <Loaded Value="True"/> @@ -68,8 +68,8 @@ <Unit4> <Filename Value="..\..\xlsbiff5.pas"/> <UnitName Value="xlsbiff5"/> - <CursorPos X="26" Y="95"/> - <TopLine Value="92"/> + <CursorPos X="38" Y="1059"/> + <TopLine Value="1045"/> <EditorIndex Value="6"/> <UsageCount Value="140"/> <Loaded Value="True"/> @@ -86,8 +86,8 @@ <Unit6> <Filename Value="..\..\xlsbiff2.pas"/> <UnitName Value="xlsbiff2"/> - <CursorPos X="1" Y="16"/> - <TopLine Value="1"/> + <CursorPos X="25" Y="216"/> + <TopLine Value="203"/> <EditorIndex Value="7"/> <UsageCount Value="139"/> <Loaded Value="True"/> @@ -116,10 +116,10 @@ <Unit10> <Filename Value="..\..\fpspreadsheet.pas"/> <UnitName Value="fpspreadsheet"/> - <CursorPos X="1" Y="759"/> - <TopLine Value="746"/> + <CursorPos X="17" Y="138"/> + <TopLine Value="125"/> <EditorIndex Value="4"/> - <UsageCount Value="95"/> + <UsageCount Value="97"/> <Loaded Value="True"/> </Unit10> <Unit11> @@ -131,10 +131,10 @@ <Unit12> <Filename Value="..\..\fpsopendocument.pas"/> <UnitName Value="fpsopendocument"/> - <CursorPos X="7" Y="296"/> - <TopLine Value="275"/> + <CursorPos X="88" Y="294"/> + <TopLine Value="284"/> <EditorIndex Value="1"/> - <UsageCount Value="13"/> + <UsageCount Value="15"/> <Loaded Value="True"/> </Unit12> <Unit13> @@ -143,7 +143,7 @@ <CursorPos X="1" Y="268"/> <TopLine Value="253"/> <EditorIndex Value="3"/> - <UsageCount Value="13"/> + <UsageCount Value="15"/> <Loaded Value="True"/> </Unit13> <Unit14> @@ -151,130 +151,130 @@ <CursorPos X="10" Y="154"/> <TopLine Value="141"/> <EditorIndex Value="2"/> - <UsageCount Value="10"/> + <UsageCount Value="12"/> <Loaded Value="True"/> </Unit14> </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="265" Column="28" TopLine="253"/> + <Caret Line="295" Column="1" TopLine="282"/> </Position1> <Position2> <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="313" Column="1" TopLine="301"/> + <Caret Line="297" Column="1" TopLine="284"/> </Position2> <Position3> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="41" Column="45" TopLine="37"/> - </Position3> - <Position4> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="355" Column="5" TopLine="331"/> - </Position4> - <Position5> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="311" Column="1" TopLine="299"/> - </Position5> - <Position6> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="260" Column="28" TopLine="249"/> - </Position6> - <Position7> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="365" Column="5" TopLine="340"/> - </Position7> - <Position8> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="5" TopLine="265"/> - </Position8> - <Position9> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="380" Column="74" TopLine="363"/> - </Position9> - <Position10> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="278" Column="1" TopLine="265"/> - </Position10> - <Position11> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="279" Column="1" TopLine="266"/> - </Position11> - <Position12> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="283" Column="1" TopLine="270"/> - </Position12> - <Position13> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="284" Column="1" TopLine="271"/> - </Position13> - <Position14> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="287" Column="1" TopLine="274"/> - </Position14> - <Position15> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="289" Column="1" TopLine="276"/> - </Position15> - <Position16> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="18" TopLine="277"/> - </Position16> - <Position17> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="289" Column="1" TopLine="276"/> - </Position17> - <Position18> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="1" TopLine="277"/> - </Position18> - <Position19> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="289" Column="1" TopLine="276"/> - </Position19> - <Position20> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="1" TopLine="277"/> - </Position20> - <Position21> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="289" Column="1" TopLine="276"/> - </Position21> - <Position22> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="290" Column="1" TopLine="277"/> - </Position22> - <Position23> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="293" Column="1" TopLine="280"/> - </Position23> - <Position24> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="295" Column="1" TopLine="282"/> - </Position24> - <Position25> - <Filename Value="..\..\fpsopendocument.pas"/> - <Caret Line="297" Column="1" TopLine="284"/> - </Position25> - <Position26> <Filename Value="..\..\fpspreadsheet.pas"/> <Caret Line="754" Column="1" TopLine="741"/> - </Position26> - <Position27> + </Position3> + <Position4> <Filename Value="..\..\fpspreadsheet.pas"/> <Caret Line="755" Column="1" TopLine="742"/> - </Position27> - <Position28> + </Position4> + <Position5> <Filename Value="..\..\fpspreadsheet.pas"/> <Caret Line="757" Column="1" TopLine="744"/> - </Position28> - <Position29> + </Position5> + <Position6> <Filename Value="..\..\fpspreadsheet.pas"/> <Caret Line="759" Column="1" TopLine="746"/> - </Position29> - <Position30> + </Position6> + <Position7> <Filename Value="..\..\fpsopendocument.pas"/> <Caret Line="392" Column="1" TopLine="379"/> + </Position7> + <Position8> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="87" Column="1" TopLine="79"/> + </Position8> + <Position9> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="211" Column="34" TopLine="196"/> + </Position9> + <Position10> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="22" Column="40" TopLine="8"/> + </Position10> + <Position11> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="48" Column="22" TopLine="35"/> + </Position11> + <Position12> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="194" Column="7" TopLine="181"/> + </Position12> + <Position13> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="329" Column="51" TopLine="316"/> + </Position13> + <Position14> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="257" Column="34" TopLine="242"/> + </Position14> + <Position15> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="286" Column="34" TopLine="271"/> + </Position15> + <Position16> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="350" Column="38" TopLine="336"/> + </Position16> + <Position17> + <Filename Value="..\..\xlsbiff5.pas"/> + <Caret Line="207" Column="1" TopLine="196"/> + </Position17> + <Position18> + <Filename Value="..\..\xlsbiff5.pas"/> + <Caret Line="556" Column="34" TopLine="542"/> + </Position18> + <Position19> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="50" Column="19" TopLine="37"/> + </Position19> + <Position20> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="150" Column="34" TopLine="137"/> + </Position20> + <Position21> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="153" Column="72" TopLine="137"/> + </Position21> + <Position22> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="159" Column="13" TopLine="137"/> + </Position22> + <Position23> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="187" Column="32" TopLine="174"/> + </Position23> + <Position24> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="190" Column="13" TopLine="174"/> + </Position24> + <Position25> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="193" Column="34" TopLine="174"/> + </Position25> + <Position26> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="226" Column="33" TopLine="213"/> + </Position26> + <Position27> + <Filename Value="..\..\xlsbiff2.pas"/> + <Caret Line="97" Column="16" TopLine="85"/> + </Position27> + <Position28> + <Filename Value="..\..\xlsbiff5.pas"/> + <Caret Line="601" Column="25" TopLine="588"/> + </Position28> + <Position29> + <Filename Value="..\..\xlsbiff5.pas"/> + <Caret Line="673" Column="34" TopLine="659"/> + </Position29> + <Position30> + <Filename Value="..\..\xlsbiff5.pas"/> + <Caret Line="700" Column="34" TopLine="686"/> </Position30> </JumpHistory> </ProjectOptions> 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 + ' <table:table table:name="' + CurSheet.Name + '" table:style-name="ta1">' + LineEnding + ' <table:table-column table:style-name="co1" table:number-columns-repeated="' + - IntToStr(LastColNum) + '" table:default-cell-style-name="Default"/>' + 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 + ' <table:table-row table:style-name="ro1">' + 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 + + ' <table:table-cell office:value-type="string">' + LineEnding + + ' <text:p>' + AValue + '</text:p>' + LineEnding + + ' </table:table-cell>' + 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();