diff --git a/components/fpspreadsheet/examples/excel2demo/excel2read.lpi b/components/fpspreadsheet/examples/excel2demo/excel2read.lpi index 41331d5e1..a122edc85 100644 --- a/components/fpspreadsheet/examples/excel2demo/excel2read.lpi +++ b/components/fpspreadsheet/examples/excel2demo/excel2read.lpi @@ -7,11 +7,11 @@ + <UseAppBundle Value="False"/> - <ActiveEditorIndexAtStart Value="0"/> </General> <VersionInfo> <ProjectVersion Value=""/> @@ -33,230 +33,13 @@ <PackageName Value="laz_fpspreadsheet"/> </Item1> </RequiredPackages> - <Units Count="13"> + <Units Count="1"> <Unit0> <Filename Value="excel2read.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="excel2read"/> - <CursorPos X="3" Y="37"/> - <TopLine Value="25"/> - <EditorIndex Value="0"/> - <UsageCount Value="309"/> - <Loaded Value="True"/> </Unit0> - <Unit1> - <Filename Value="..\fpolestorage.pas"/> - <UnitName Value="fpolestorage"/> - <CursorPos X="1" Y="1"/> - <TopLine Value="1"/> - <UsageCount Value="19"/> - </Unit1> - <Unit2> - <Filename Value="..\..\..\..\..\lazarus\lcl\interfaces\win32\win32wsstdctrls.pp"/> - <UnitName Value="Win32WSStdCtrls"/> - <CursorPos X="35" Y="720"/> - <TopLine Value="713"/> - <UsageCount Value="76"/> - </Unit2> - <Unit3> - <Filename Value="..\..\..\..\..\lazarus\ideintf\componenteditors.pas"/> - <UnitName Value="ComponentEditors"/> - <CursorPos X="40" Y="332"/> - <TopLine Value="330"/> - <UsageCount Value="74"/> - </Unit3> - <Unit4> - <Filename Value="..\..\xlsbiff5.pas"/> - <UnitName Value="xlsbiff5"/> - <CursorPos X="20" Y="938"/> - <TopLine Value="918"/> - <EditorIndex Value="3"/> - <UsageCount Value="140"/> - <Loaded Value="True"/> - </Unit4> - <Unit5> - <Filename Value="..\..\fpsutils.pas"/> - <UnitName Value="fpsutils"/> - <CursorPos X="10" Y="15"/> - <TopLine Value="5"/> - <EditorIndex Value="2"/> - <UsageCount Value="140"/> - <Loaded Value="True"/> - </Unit5> - <Unit6> - <Filename Value="..\..\xlsbiff2.pas"/> - <UnitName Value="xlsbiff2"/> - <CursorPos X="1" Y="311"/> - <TopLine Value="293"/> - <EditorIndex Value="4"/> - <UsageCount Value="139"/> - <Loaded Value="True"/> - </Unit6> - <Unit7> - <Filename Value="..\..\fpolestorage.pas"/> - <UnitName Value="fpolestorage"/> - <CursorPos X="12" Y="748"/> - <TopLine Value="766"/> - <EditorIndex Value="5"/> - <UsageCount Value="139"/> - <Loaded Value="True"/> - </Unit7> - <Unit8> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\classesh.inc"/> - <CursorPos X="19" Y="562"/> - <TopLine Value="553"/> - <UsageCount Value="41"/> - </Unit8> - <Unit9> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\streams.inc"/> - <CursorPos X="21" Y="158"/> - <TopLine Value="151"/> - <UsageCount Value="41"/> - </Unit9> - <Unit10> - <Filename Value="..\..\fpspreadsheet.pas"/> - <UnitName Value="fpspreadsheet"/> - <CursorPos X="2" Y="714"/> - <TopLine Value="701"/> - <EditorIndex Value="1"/> - <UsageCount Value="93"/> - <Loaded Value="True"/> - </Unit10> - <Unit11> - <Filename Value="..\..\..\..\..\lazarus\lcl\include\customtrayicon.inc"/> - <CursorPos X="22" Y="203"/> - <TopLine Value="197"/> - <UsageCount Value="67"/> - </Unit11> - <Unit12> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\sysutils\sysstrh.inc"/> - <CursorPos X="26" Y="154"/> - <TopLine Value="144"/> - <UsageCount Value="10"/> - </Unit12> </Units> - <JumpHistory Count="30" HistoryIndex="29"> - <Position1> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="312" Column="1" TopLine="302"/> - </Position1> - <Position2> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="314" Column="1" TopLine="304"/> - </Position2> - <Position3> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="317" Column="1" TopLine="307"/> - </Position3> - <Position4> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="326" Column="1" TopLine="316"/> - </Position4> - <Position5> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="328" Column="1" TopLine="318"/> - </Position5> - <Position6> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="309" Column="1" TopLine="299"/> - </Position6> - <Position7> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="310" Column="1" TopLine="300"/> - </Position7> - <Position8> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="312" Column="1" TopLine="302"/> - </Position8> - <Position9> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="314" Column="1" TopLine="304"/> - </Position9> - <Position10> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="317" Column="1" TopLine="307"/> - </Position10> - <Position11> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="326" Column="1" TopLine="316"/> - </Position11> - <Position12> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="328" Column="1" TopLine="318"/> - </Position12> - <Position13> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="309" Column="1" TopLine="299"/> - </Position13> - <Position14> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="310" Column="1" TopLine="300"/> - </Position14> - <Position15> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="312" Column="1" TopLine="302"/> - </Position15> - <Position16> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="314" Column="1" TopLine="304"/> - </Position16> - <Position17> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="320" Column="1" TopLine="310"/> - </Position17> - <Position18> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="100" Column="16" TopLine="87"/> - </Position18> - <Position19> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="357" Column="16" TopLine="348"/> - </Position19> - <Position20> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="354" Column="6" TopLine="344"/> - </Position20> - <Position21> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="356" Column="14" TopLine="340"/> - </Position21> - <Position22> - <Filename Value="..\..\fpsutils.pas"/> - <Caret Line="48" Column="20" TopLine="34"/> - </Position22> - <Position23> - <Filename Value="..\..\fpsutils.pas"/> - <Caret Line="11" Column="3" TopLine="1"/> - </Position23> - <Position24> - <Filename Value="..\..\fpsutils.pas"/> - <Caret Line="90" Column="5" TopLine="71"/> - </Position24> - <Position25> - <Filename Value="..\..\fpolestorage.pas"/> - <Caret Line="654" Column="30" TopLine="642"/> - </Position25> - <Position26> - <Filename Value="..\..\fpolestorage.pas"/> - <Caret Line="218" Column="24" TopLine="210"/> - </Position26> - <Position27> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="355" Column="6" TopLine="347"/> - </Position27> - <Position28> - <Filename Value="..\..\xlsbiff2.pas"/> - <Caret Line="123" Column="26" TopLine="106"/> - </Position28> - <Position29> - <Filename Value="..\..\fpsutils.pas"/> - <Caret Line="69" Column="5" TopLine="50"/> - </Position29> - <Position30> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="901" Column="1" TopLine="882"/> - </Position30> - </JumpHistory> </ProjectOptions> <CompilerOptions> <Version Value="8"/> diff --git a/components/fpspreadsheet/examples/excel2demo/excel2read.lpr b/components/fpspreadsheet/examples/excel2demo/excel2read.lpr index 22d579dce..fd56de91d 100644 --- a/components/fpspreadsheet/examples/excel2demo/excel2read.lpr +++ b/components/fpspreadsheet/examples/excel2demo/excel2read.lpr @@ -36,12 +36,13 @@ begin WriteLn('Contents of the first worksheet of the file:'); WriteLn(''); + CurCell := MyWorkSheet.GetFirstCell(); for i := 0 to MyWorksheet.GetCellCount - 1 do begin - CurCell := MyWorkSheet.GetCellByIndex(i); WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ', UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row, CurCell^.Col)) ); + CurCell := MyWorkSheet.GetNextCell(); end; // Finalization diff --git a/components/fpspreadsheet/examples/excel5demo/excel5read.lpi b/components/fpspreadsheet/examples/excel5demo/excel5read.lpi index 2e84c9709..7198405ec 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5read.lpi +++ b/components/fpspreadsheet/examples/excel5demo/excel5read.lpi @@ -7,11 +7,11 @@ <Flags> <LRSInOutputDirectory Value="False"/> </Flags> + <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> <TargetFileExt Value=".exe"/> <Title Value="excel5read"/> <UseAppBundle Value="False"/> - <ActiveEditorIndexAtStart Value="2"/> </General> <VersionInfo> <ProjectVersion Value=""/> @@ -33,297 +33,13 @@ <PackageName Value="laz_fpspreadsheet"/> </Item1> </RequiredPackages> - <Units Count="21"> + <Units Count="1"> <Unit0> <Filename Value="excel5read.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="excel5read"/> - <CursorPos X="39" Y="43"/> - <TopLine Value="21"/> - <EditorIndex Value="0"/> - <UsageCount Value="309"/> - <Loaded Value="True"/> </Unit0> - <Unit1> - <Filename Value="..\fpolestorage.pas"/> - <UnitName Value="fpolestorage"/> - <CursorPos X="1" Y="1"/> - <TopLine Value="1"/> - <UsageCount Value="19"/> - </Unit1> - <Unit2> - <Filename Value="..\..\..\..\..\lazarus\lcl\interfaces\win32\win32wsstdctrls.pp"/> - <UnitName Value="Win32WSStdCtrls"/> - <CursorPos X="35" Y="720"/> - <TopLine Value="713"/> - <UsageCount Value="76"/> - </Unit2> - <Unit3> - <Filename Value="..\..\..\..\..\lazarus\ideintf\componenteditors.pas"/> - <UnitName Value="ComponentEditors"/> - <CursorPos X="40" Y="332"/> - <TopLine Value="330"/> - <UsageCount Value="74"/> - </Unit3> - <Unit4> - <Filename Value="..\..\xlsbiff5.pas"/> - <UnitName Value="xlsbiff5"/> - <CursorPos X="1" Y="61"/> - <TopLine Value="49"/> - <EditorIndex Value="4"/> - <UsageCount Value="140"/> - <Loaded Value="True"/> - </Unit4> - <Unit5> - <Filename Value="..\..\fpsutils.pas"/> - <UnitName Value="fpsutils"/> - <CursorPos X="16" Y="10"/> - <TopLine Value="1"/> - <EditorIndex Value="3"/> - <UsageCount Value="140"/> - <Loaded Value="True"/> - </Unit5> - <Unit6> - <Filename Value="..\..\xlsbiff2.pas"/> - <UnitName Value="xlsbiff2"/> - <CursorPos X="1" Y="387"/> - <TopLine Value="367"/> - <EditorIndex Value="10"/> - <UsageCount Value="139"/> - <Loaded Value="True"/> - </Unit6> - <Unit7> - <Filename Value="..\..\fpolestorage.pas"/> - <UnitName Value="fpolestorage"/> - <CursorPos X="92" Y="774"/> - <TopLine Value="763"/> - <EditorIndex Value="11"/> - <UsageCount Value="139"/> - <Loaded Value="True"/> - </Unit7> - <Unit8> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\classesh.inc"/> - <CursorPos X="19" Y="562"/> - <TopLine Value="553"/> - <UsageCount Value="41"/> - </Unit8> - <Unit9> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\streams.inc"/> - <CursorPos X="21" Y="158"/> - <TopLine Value="151"/> - <UsageCount Value="41"/> - </Unit9> - <Unit10> - <Filename Value="..\..\fpspreadsheet.pas"/> - <UnitName Value="fpspreadsheet"/> - <CursorPos X="5" Y="181"/> - <TopLine Value="177"/> - <EditorIndex Value="1"/> - <UsageCount Value="95"/> - <Loaded Value="True"/> - </Unit10> - <Unit11> - <Filename Value="..\..\..\..\..\lazarus\lcl\include\customtrayicon.inc"/> - <CursorPos X="22" Y="203"/> - <TopLine Value="197"/> - <UsageCount Value="67"/> - </Unit11> - <Unit12> - <Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\sysutils\sysstrh.inc"/> - <CursorPos X="26" Y="154"/> - <TopLine Value="144"/> - <UsageCount Value="10"/> - </Unit12> - <Unit13> - <Filename Value="..\..\..\..\..\lazarus\lcl\stdctrls.pp"/> - <UnitName Value="StdCtrls"/> - <CursorPos X="19" Y="665"/> - <TopLine Value="662"/> - <UsageCount Value="10"/> - </Unit13> - <Unit14> - <Filename Value="..\..\..\..\..\lazarus\lcl\controls.pp"/> - <UnitName Value="Controls"/> - <CursorPos X="20" Y="1513"/> - <TopLine Value="1508"/> - <UsageCount Value="10"/> - </Unit14> - <Unit15> - <Filename Value="..\..\xlsbiff8.pas"/> - <UnitName Value="xlsbiff8"/> - <CursorPos X="21" Y="1053"/> - <TopLine Value="1041"/> - <EditorIndex Value="9"/> - <UsageCount Value="11"/> - <Loaded Value="True"/> - </Unit15> - <Unit16> - <Filename Value="..\..\uvirtuallayer.pas"/> - <UnitName Value="uvirtuallayer"/> - <CursorPos X="108" Y="901"/> - <TopLine Value="885"/> - <EditorIndex Value="6"/> - <UsageCount Value="10"/> - <Loaded Value="True"/> - </Unit16> - <Unit17> - <Filename Value="..\..\uvirtuallayer_types.pas"/> - <UnitName Value="uvirtuallayer_types"/> - <CursorPos X="27" Y="177"/> - <TopLine Value="165"/> - <EditorIndex Value="8"/> - <UsageCount Value="10"/> - <Loaded Value="True"/> - </Unit17> - <Unit18> - <Filename Value="..\..\..\..\..\..\..\..\usr\local\share\fpcsrc\rtl\objpas\sysutils\filutilh.inc"/> - <CursorPos X="24" Y="20"/> - <TopLine Value="12"/> - <EditorIndex Value="7"/> - <UsageCount Value="10"/> - <Loaded Value="True"/> - </Unit18> - <Unit19> - <Filename Value="..\..\fpolebasic.pas"/> - <UnitName Value="fpolebasic"/> - <CursorPos X="1" Y="35"/> - <TopLine Value="16"/> - <EditorIndex Value="5"/> - <UsageCount Value="10"/> - <Loaded Value="True"/> - </Unit19> - <Unit20> - <Filename Value="..\..\laz_fpspreadsheet.pas"/> - <UnitName Value="laz_fpspreadsheet"/> - <CursorPos X="10" Y="16"/> - <TopLine Value="1"/> - <EditorIndex Value="2"/> - <UsageCount Value="10"/> - <Loaded Value="True"/> - </Unit20> </Units> - <JumpHistory Count="30" HistoryIndex="29"> - <Position1> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="918" Column="1" TopLine="910"/> - </Position1> - <Position2> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="886" Column="1" TopLine="867"/> - </Position2> - <Position3> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="889" Column="1" TopLine="876"/> - </Position3> - <Position4> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="68" Column="24" TopLine="58"/> - </Position4> - <Position5> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="887" Column="1" TopLine="882"/> - </Position5> - <Position6> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="64" Column="37" TopLine="55"/> - </Position6> - <Position7> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="934" Column="5" TopLine="915"/> - </Position7> - <Position8> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="941" Column="23" TopLine="925"/> - </Position8> - <Position9> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="72" Column="25" TopLine="62"/> - </Position9> - <Position10> - <Filename Value="..\..\fpspreadsheet.pas"/> - <Caret Line="499" Column="45" TopLine="486"/> - </Position10> - <Position11> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="948" Column="1" TopLine="946"/> - </Position11> - <Position12> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="994" Column="12" TopLine="981"/> - </Position12> - <Position13> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="891" Column="1" TopLine="872"/> - </Position13> - <Position14> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="70" Column="15" TopLine="60"/> - </Position14> - <Position15> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="1063" Column="1" TopLine="1050"/> - </Position15> - <Position16> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="1064" Column="1" TopLine="1051"/> - </Position16> - <Position17> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="1065" Column="1" TopLine="1052"/> - </Position17> - <Position18> - <Filename Value="..\..\uvirtuallayer.pas"/> - <Caret Line="1" Column="1" TopLine="1"/> - </Position18> - <Position19> - <Filename Value="..\..\uvirtuallayer.pas"/> - <Caret Line="12" Column="21" TopLine="1"/> - </Position19> - <Position20> - <Filename Value="..\..\uvirtuallayer_types.pas"/> - <Caret Line="1" Column="1" TopLine="1"/> - </Position20> - <Position21> - <Filename Value="..\..\uvirtuallayer.pas"/> - <Caret Line="987" Column="20" TopLine="963"/> - </Position21> - <Position22> - <Filename Value="..\..\uvirtuallayer.pas"/> - <Caret Line="893" Column="15" TopLine="882"/> - </Position22> - <Position23> - <Filename Value="..\..\uvirtuallayer.pas"/> - <Caret Line="894" Column="20" TopLine="882"/> - </Position23> - <Position24> - <Filename Value="..\..\xlsbiff5.pas"/> - <Caret Line="60" Column="20" TopLine="49"/> - </Position24> - <Position25> - <Filename Value="..\..\xlsbiff8.pas"/> - <Caret Line="54" Column="11" TopLine="48"/> - </Position25> - <Position26> - <Filename Value="..\..\xlsbiff8.pas"/> - <Caret Line="1053" Column="22" TopLine="1041"/> - </Position26> - <Position27> - <Filename Value="..\..\fpolestorage.pas"/> - <Caret Line="98" Column="15" TopLine="66"/> - </Position27> - <Position28> - <Filename Value="..\..\xlsbiff8.pas"/> - <Caret Line="1053" Column="21" TopLine="1041"/> - </Position28> - <Position29> - <Filename Value="..\..\fpolestorage.pas"/> - <Caret Line="98" Column="91" TopLine="86"/> - </Position29> - <Position30> - <Filename Value="..\..\laz_fpspreadsheet.pas"/> - <Caret Line="1" Column="1" TopLine="1"/> - </Position30> - </JumpHistory> </ProjectOptions> <CompilerOptions> <Version Value="8"/> diff --git a/components/fpspreadsheet/examples/excel5demo/excel5read.lpr b/components/fpspreadsheet/examples/excel5demo/excel5read.lpr index a23bf90ce..61cfcdfda 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5read.lpr +++ b/components/fpspreadsheet/examples/excel5demo/excel5read.lpr @@ -37,14 +37,15 @@ begin WriteLn('Contents of the first worksheet of the file:'); WriteLn(''); + CurCell := MyWorkSheet.GetFirstCell(); for i := 0 to MyWorksheet.GetCellCount - 1 do begin - CurCell := MyWorkSheet.GetCellByIndex(i); WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ', UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row, CurCell^.Col)) ); + CurCell := MyWorkSheet.GetNextCell(); end; // Finalization diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi index 6fb8ca6eb..4875319c2 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi +++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi @@ -2,14 +2,14 @@ <CONFIG> <ProjectOptions> <PathDelim Value="\"/> - <Version Value="6"/> + <Version Value="7"/> <General> <Flags> <AlwaysBuild Value="False"/> + <LRSInOutputDirectory Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> <TargetFileExt Value=".exe"/> <Title Value="excel5write"/> <UseAppBundle Value="False"/> diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr index a4a48a969..433d99fd0 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr +++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr @@ -75,7 +75,7 @@ begin MyWorksheet.WriteUTF8Text(0, 3, 'Fourth');} // Save the spreadsheet to a file - MyWorkbook.WriteToFile(MyDir + 'test.xls', sfExcel5); + MyWorkbook.WriteToFile(MyDir + 'test.xls', sfExcel5, False); MyWorkbook.Free; end. diff --git a/components/fpspreadsheet/examples/excel5demo/run_excel5write.bat b/components/fpspreadsheet/examples/excel5demo/run_excel5write.bat index 6d70c6689..9ee17c60b 100644 --- a/components/fpspreadsheet/examples/excel5demo/run_excel5write.bat +++ b/components/fpspreadsheet/examples/excel5demo/run_excel5write.bat @@ -1,3 +1,3 @@ -del test.xls +#del test.xls excel5write.exe pause \ No newline at end of file diff --git a/components/fpspreadsheet/examples/excel8demo/excel8read.lpi b/components/fpspreadsheet/examples/excel8demo/excel8read.lpi index 7f9dc1779..06e6eaccf 100644 --- a/components/fpspreadsheet/examples/excel8demo/excel8read.lpi +++ b/components/fpspreadsheet/examples/excel8demo/excel8read.lpi @@ -2,14 +2,14 @@ <CONFIG> <ProjectOptions> <PathDelim Value="\"/> - <Version Value="6"/> + <Version Value="7"/> <General> <Flags> <AlwaysBuild Value="False"/> + <LRSInOutputDirectory Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> <TargetFileExt Value=""/> <UseXPManifest Value="True"/> </General> diff --git a/components/fpspreadsheet/examples/excel8demo/excel8read.lpr b/components/fpspreadsheet/examples/excel8demo/excel8read.lpr index 76edf8103..0e04c1e26 100644 --- a/components/fpspreadsheet/examples/excel8demo/excel8read.lpr +++ b/components/fpspreadsheet/examples/excel8demo/excel8read.lpr @@ -40,14 +40,15 @@ begin WriteLn('Contents of the first worksheet of the file:'); WriteLn(''); + CurCell := MyWorkSheet.GetFirstCell(); for i := 0 to MyWorksheet.GetCellCount - 1 do begin - CurCell := MyWorkSheet.GetCellByIndex(i); WriteLn('Row: ', CurCell^.Row, ' Col: ', CurCell^.Col, ' Value: ', UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row, CurCell^.Col)) ); + CurCell := MyWorkSheet.GetNextCell(); end; // Finalization diff --git a/components/fpspreadsheet/fpolestorage.pas b/components/fpspreadsheet/fpolestorage.pas index c9ea1e5ec..c8b898f06 100755 --- a/components/fpspreadsheet/fpolestorage.pas +++ b/components/fpspreadsheet/fpolestorage.pas @@ -94,7 +94,8 @@ type public constructor Create; destructor Destroy; override; - procedure WriteOLEFile(AFileName: string; AOLEDocument: TOLEDocument; const AStreamName: UTF8String='Book'); + procedure WriteOLEFile(AFileName: string; AOLEDocument: TOLEDocument; + const AOverwriteExisting: Boolean = False; const AStreamName: UTF8String='Book'); procedure ReadOLEFile(AFileName: string; AOLEDocument: TOLEDocument; const AStreamName: UTF8String='Book'); procedure FreeOLEDocumentData(AOLEDocument: TOLEDocument); end; @@ -690,12 +691,22 @@ end; it should be placed doesn't exist. } procedure TOLEStorage.WriteOLEFile(AFileName: string; - AOLEDocument: TOLEDocument; const AStreamName: UTF8String); + AOLEDocument: TOLEDocument; const AOverwriteExisting: Boolean; + const AStreamName: UTF8String); var cbWritten: Cardinal; AFileStream: TFileStream; i, x: Cardinal; + lMode: Word; begin + // The behavior of LCL classes is failling to write to existing file, + // But here we make this settable + if AOverwriteExisting then lMode := fmCreate or fmOpenWrite + else lMode := fmCreate; + + if (not AOverwriteExisting) and FileExists(AFileName) then + Raise EStreamError.Createfmt('File already exists "%s"',[AFileName]); + { Fill information for helper routines } FOLEDocument := AOLEDocument; @@ -720,7 +731,7 @@ begin { Create a Storage Object } OleCheck(StgCreateDocfile(PWideChar(WideString(AFileName)), - STGM_READWRITE or STGM_FAILIFTHERE or STGM_SHARE_EXCLUSIVE or STGM_DIRECT, + STGM_READWRITE or STGM_CREATE or STGM_SHARE_EXCLUSIVE or STGM_DIRECT, 0, FStorage)); { Create a workbook stream in the storage. A BIFF5 file must @@ -735,9 +746,7 @@ begin {$else} - // Follows the behavior of LCL classes: Fails to write to existing file - if FileExists(AFileName) then Raise EStreamError.Createfmt('File already exists "%s"',[AFileName]); - AFileStream := TFileStream.Create(AFileName, fmCreate); + AFileStream := TFileStream.Create(AFileName, lMode); try // Header WriteOLEHeader(AFileStream); diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index 6b0dd688f..4133a0ec1 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -66,7 +66,8 @@ type public { General writing methods } procedure WriteStringToFile(AString, AFileName: string); - procedure WriteToFile(AFileName: string; AData: TsWorkbook); override; + procedure WriteToFile(const AFileName: string; AData: TsWorkbook; + const AOverwriteExisting: Boolean = False); override; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsFormula); override; @@ -459,7 +460,8 @@ end; { Writes an OOXML document to the disc. } -procedure TsSpreadOpenDocWriter.WriteToFile(AFileName: string; AData: TsWorkbook); +procedure TsSpreadOpenDocWriter.WriteToFile(const AFileName: string; + AData: TsWorkbook; const AOverwriteExisting: Boolean); var FZip: TZipper; begin diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 239c83fa4..856d0f091 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -139,7 +139,9 @@ type function CreateSpreadWriter(AFormat: TsSpreadsheetFormat): TsCustomSpreadWriter; procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat); procedure ReadFromStream(AStream: TStream; AFormat: TsSpreadsheetFormat); - procedure WriteToFile(AFileName: string; AFormat: TsSpreadsheetFormat); + procedure WriteToFile(const AFileName: string; + const AFormat: TsSpreadsheetFormat; + const AOverwriteExisting: Boolean = False); procedure WriteToStream(AStream: TStream; AFormat: TsSpreadsheetFormat); { Worksheet list handling methods } function AddWorksheet(AName: string): TsWorksheet; @@ -182,7 +184,8 @@ type { General writing methods } procedure WriteCellCallback(data, arg: pointer); procedure WriteCellsToStream(AStream: TStream; ACells: TAVLTree); - procedure WriteToFile(AFileName: string; AData: TsWorkbook); virtual; + procedure WriteToFile(const AFileName: string; AData: TsWorkbook; + const AOverwriteExisting: Boolean = False); virtual; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); virtual; { Record writing methods } procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsFormula); virtual; @@ -674,14 +677,15 @@ end; If the file doesn't exist, it will be created. } -procedure TsWorkbook.WriteToFile(AFileName: string; AFormat: TsSpreadsheetFormat); +procedure TsWorkbook.WriteToFile(const AFileName: string; + const AFormat: TsSpreadsheetFormat; const AOverwriteExisting: Boolean = False); var AWriter: TsCustomSpreadWriter; begin AWriter := CreateSpreadWriter(AFormat); try - AWriter.WriteToFile(AFileName, Self); + AWriter.WriteToFile(AFileName, Self, AOverwriteExisting); finally AWriter.Free; end; @@ -905,11 +909,16 @@ end; @see TsWorkbook } -procedure TsCustomSpreadWriter.WriteToFile(AFileName: string; AData: TsWorkbook); +procedure TsCustomSpreadWriter.WriteToFile(const AFileName: string; + AData: TsWorkbook; const AOverwriteExisting: Boolean = False); var OutputFile: TFileStream; + lMode: Word; begin - OutputFile := TFileStream.Create(AFileName, fmCreate or fmOpenWrite); + if AOverwriteExisting then lMode := fmCreate or fmOpenWrite + else lMode := fmCreate; + + OutputFile := TFileStream.Create(AFileName, lMode); try WriteToStream(OutputFile, AData); finally diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas index e7df5d9b0..51edc752a 100755 --- a/components/fpspreadsheet/xlsbiff5.pas +++ b/components/fpspreadsheet/xlsbiff5.pas @@ -108,7 +108,8 @@ type // constructor Create; // destructor Destroy; override; { General writing methods } - procedure WriteToFile(AFileName: string; AData: TsWorkbook); override; + procedure WriteToFile(const AFileName: string; AData: TsWorkbook; + const AOverwriteExisting: Boolean = False); override; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } procedure WriteBOF(AStream: TStream; ADataType: Word); @@ -278,7 +279,8 @@ end; * COM functions * *******************************************************************} -procedure TsSpreadBIFF5Writer.WriteToFile(AFileName: string; AData: TsWorkbook); +procedure TsSpreadBIFF5Writer.WriteToFile(const AFileName: string; + AData: TsWorkbook; const AOverwriteExisting: Boolean); var MemStream: TMemoryStream; OutputStorage: TOLEStorage; @@ -292,7 +294,7 @@ begin // Only one stream is necessary for any number of worksheets OLEDocument.Stream := MemStream; - OutputStorage.WriteOLEFile(AFileName, OLEDocument); + OutputStorage.WriteOLEFile(AFileName, OLEDocument, AOverwriteExisting); finally MemStream.Free; OutputStorage.Free; diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index 069caca1d..6ff20ef26 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -103,7 +103,8 @@ type // constructor Create; // destructor Destroy; override; { General writing methods } - procedure WriteToFile(AFileName: string; AData: TsWorkbook); override; + procedure WriteToFile(const AFileName: string; AData: TsWorkbook; + const AOverwriteExisting: Boolean = False); override; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } procedure WriteBOF(AStream: TStream; ADataType: Word); @@ -246,7 +247,8 @@ const * COM functions * *******************************************************************} -procedure TsSpreadBIFF8Writer.WriteToFile(AFileName: string; AData: TsWorkbook); +procedure TsSpreadBIFF8Writer.WriteToFile(const AFileName: string; + AData: TsWorkbook; const AOverwriteExisting: Boolean); var MemStream: TMemoryStream; OutputStorage: TOLEStorage; @@ -260,7 +262,7 @@ begin // Only one stream is necessary for any number of worksheets OLEDocument.Stream := MemStream; - OutputStorage.WriteOLEFile(AFileName, OLEDocument,'Workbook'); + OutputStorage.WriteOLEFile(AFileName, OLEDocument, AOverwriteExisting, 'Workbook'); finally MemStream.Free; OutputStorage.Free; diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index b3f526c6f..a22c19b48 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -59,7 +59,8 @@ type destructor Destroy; override; { General writing methods } procedure WriteStringToFile(AFileName, AString: string); - procedure WriteToFile(AFileName: string; AData: TsWorkbook); override; + procedure WriteToFile(const AFileName: string; AData: TsWorkbook; + const AOverwriteExisting: Boolean = False); override; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; @@ -314,7 +315,8 @@ end; { Writes an OOXML document to the disc } -procedure TsSpreadOOXMLWriter.WriteToFile(AFileName: string; AData: TsWorkbook); +procedure TsSpreadOOXMLWriter.WriteToFile(const AFileName: string; + AData: TsWorkbook; const AOverwriteExisting: Boolean); var FZip: TZipper; i: Integer;