You've already forked lazarus-ccr
fpspreadsheet: Improves OpenDocument support
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@684 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -10,12 +10,11 @@
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="excel2read"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
@ -10,12 +10,11 @@
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="excel2write"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
@ -10,12 +10,11 @@
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="excel5read"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
@ -10,12 +10,11 @@
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="excel5write"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
284
components/fpspreadsheet/examples/ooxmldemo/ooxmlwrite.lpi
Normal file
284
components/fpspreadsheet/examples/ooxmldemo/ooxmlwrite.lpi
Normal file
@ -0,0 +1,284 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="ooxmlwrite"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="2"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="laz_fpspreadsheet"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="14">
|
||||
<Unit0>
|
||||
<Filename Value="ooxmlwrite.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ooxmlwrite"/>
|
||||
<CursorPos X="19" Y="46"/>
|
||||
<TopLine Value="33"/>
|
||||
<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="18"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\..\..\..\..\lazarus\lcl\interfaces\win32\win32wsstdctrls.pp"/>
|
||||
<UnitName Value="Win32WSStdCtrls"/>
|
||||
<CursorPos X="35" Y="720"/>
|
||||
<TopLine Value="713"/>
|
||||
<UsageCount Value="75"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\..\..\..\lazarus\ideintf\componenteditors.pas"/>
|
||||
<UnitName Value="ComponentEditors"/>
|
||||
<CursorPos X="40" Y="332"/>
|
||||
<TopLine Value="330"/>
|
||||
<UsageCount Value="73"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<UnitName Value="xlsbiff5"/>
|
||||
<CursorPos X="26" Y="95"/>
|
||||
<TopLine Value="92"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="140"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\fpsutils.pas"/>
|
||||
<UnitName Value="fpsutils"/>
|
||||
<CursorPos X="1" Y="49"/>
|
||||
<TopLine Value="30"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="140"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\..\xlsbiff2.pas"/>
|
||||
<UnitName Value="xlsbiff2"/>
|
||||
<CursorPos X="1" Y="360"/>
|
||||
<TopLine Value="339"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="139"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
<CursorPos X="30" Y="654"/>
|
||||
<TopLine Value="642"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<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="40"/>
|
||||
</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="40"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<UnitName Value="fpspreadsheet"/>
|
||||
<CursorPos X="28" Y="26"/>
|
||||
<TopLine Value="12"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<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="66"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<UnitName Value="fpsopendocument"/>
|
||||
<CursorPos X="15" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\xlsxooxml.pas"/>
|
||||
<UnitName Value="xlsxooxml"/>
|
||||
<CursorPos X="1" Y="89"/>
|
||||
<TopLine Value="79"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="77" Column="7" TopLine="76"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="137" Column="40" TopLine="129"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="563" Column="5" TopLine="544"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="486" Column="5" TopLine="467"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="510" Column="5" TopLine="491"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="94" Column="46" TopLine="84"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="686" Column="5" TopLine="667"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="567" Column="5" TopLine="548"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="622" Column="1" TopLine="618"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="621" Column="29" TopLine="611"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="428" Column="5" TopLine="403"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="458" Column="15" TopLine="434"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="386" Column="1" TopLine="372"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="390" Column="26" TopLine="377"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="420" Column="32" TopLine="407"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="421" Column="14" TopLine="408"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="460" Column="33" TopLine="440"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="181" Column="91" TopLine="160"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="769" Column="83" TopLine="754"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="102" Column="15" TopLine="89"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="103" Column="15" TopLine="90"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="404" Column="5" TopLine="379"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="187" Column="1" TopLine="172"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="380" Column="17" TopLine="362"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="412" Column="1" TopLine="404"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="716" Column="1" TopLine="702"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="167" Column="17" TopLine="154"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\..\xlsbiff2.pas"/>
|
||||
<Caret Line="69" Column="1" TopLine="57"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="ooxmlwrite.lpr"/>
|
||||
<Caret Line="68" Column="57" TopLine="46"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\..\xlsxooxml.pas"/>
|
||||
<Caret Line="102" Column="1" TopLine="77"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="..\"/>
|
||||
<SrcPath Value="..\"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
71
components/fpspreadsheet/examples/ooxmldemo/ooxmlwrite.lpr
Normal file
71
components/fpspreadsheet/examples/ooxmldemo/ooxmlwrite.lpr
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
ooxmlwrite.dpr
|
||||
|
||||
Demonstrates how to write an OOXML file using the fpspreadsheet library
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
}
|
||||
program ooxmlwrite;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpspreadsheet, fpsallformats, laz_fpspreadsheet;
|
||||
|
||||
var
|
||||
MyWorkbook: TsWorkbook;
|
||||
MyWorksheet: TsWorksheet;
|
||||
MyFormula: TRPNFormula;
|
||||
MyDir: string;
|
||||
i: Integer;
|
||||
a: TStringList;
|
||||
begin
|
||||
// Open the output file
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
|
||||
|
||||
// Write some number cells
|
||||
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
|
||||
begin
|
||||
MyWorksheet.WriteAnsiText(i, 0, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 1, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 2, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 3, ParamStr(0));
|
||||
end;
|
||||
}
|
||||
|
||||
// Write the formula E1 = A1 + B1
|
||||
// or, in RPN: A1, B1, +
|
||||
SetLength(MyFormula, 3);
|
||||
MyFormula[0].TokenID := INT_EXCEL_TOKEN_TREFV; {A1}
|
||||
MyFormula[0].Col := 0;
|
||||
MyFormula[0].Row := 0;
|
||||
MyFormula[1].TokenID := INT_EXCEL_TOKEN_TREFV; {B1}
|
||||
MyFormula[1].Col := 1;
|
||||
MyFormula[1].Row := 0;
|
||||
MyFormula[2].TokenID := INT_EXCEL_TOKEN_TADD; {+}
|
||||
MyWorksheet.WriteRPNFormula(0, 4, MyFormula);
|
||||
|
||||
// Creates a new worksheet
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');
|
||||
|
||||
// Write some string cells
|
||||
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_OOXML_EXCEL_EXTENSION, sfOOXML);
|
||||
MyWorkbook.Free;
|
||||
end.
|
||||
|
284
components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
Normal file
284
components/fpspreadsheet/examples/opendocdemo/opendocwrite.lpi
Normal file
@ -0,0 +1,284 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="opendocwrite"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="laz_fpspreadsheet"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="14">
|
||||
<Unit0>
|
||||
<Filename Value="opendocwrite.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="opendocwrite"/>
|
||||
<CursorPos X="3" Y="66"/>
|
||||
<TopLine Value="46"/>
|
||||
<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="26" Y="95"/>
|
||||
<TopLine Value="92"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="140"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\fpsutils.pas"/>
|
||||
<UnitName Value="fpsutils"/>
|
||||
<CursorPos X="1" Y="49"/>
|
||||
<TopLine Value="30"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="140"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\..\xlsbiff2.pas"/>
|
||||
<UnitName Value="xlsbiff2"/>
|
||||
<CursorPos X="1" Y="360"/>
|
||||
<TopLine Value="339"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="139"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
<CursorPos X="30" Y="654"/>
|
||||
<TopLine Value="642"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<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="44" Y="636"/>
|
||||
<TopLine Value="630"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<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="..\..\fpsopendocument.pas"/>
|
||||
<UnitName Value="fpsopendocument"/>
|
||||
<CursorPos X="28" Y="248"/>
|
||||
<TopLine Value="237"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\xlsxooxml.pas"/>
|
||||
<UnitName Value="xlsxooxml"/>
|
||||
<CursorPos X="1" Y="268"/>
|
||||
<TopLine Value="253"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="458" Column="15" TopLine="434"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="386" Column="1" TopLine="372"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="390" Column="26" TopLine="377"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="420" Column="32" TopLine="407"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="421" Column="14" TopLine="408"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="460" Column="33" TopLine="440"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="181" Column="91" TopLine="160"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="769" Column="83" TopLine="754"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="102" Column="15" TopLine="89"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="103" Column="15" TopLine="90"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="404" Column="5" TopLine="379"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="187" Column="1" TopLine="172"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="380" Column="17" TopLine="362"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="412" Column="1" TopLine="404"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="716" Column="1" TopLine="702"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\..\fpspreadsheet.pas"/>
|
||||
<Caret Line="167" Column="17" TopLine="154"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\xlsbiff2.pas"/>
|
||||
<Caret Line="69" Column="1" TopLine="57"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="opendocwrite.lpr"/>
|
||||
<Caret Line="71" Column="1" TopLine="46"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\..\xlsxooxml.pas"/>
|
||||
<Caret Line="48" Column="16" TopLine="35"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="105" Column="1" TopLine="80"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="111" Column="1" TopLine="86"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="386" Column="1" TopLine="377"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="357" Column="1" TopLine="350"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="304" Column="3" TopLine="294"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="265" Column="28" TopLine="253"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="313" Column="1" TopLine="301"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="41" Column="45" TopLine="37"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="355" Column="5" TopLine="331"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="311" Column="1" TopLine="299"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\..\fpsopendocument.pas"/>
|
||||
<Caret Line="260" Column="28" TopLine="249"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="..\"/>
|
||||
<SrcPath Value="..\"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
@ -0,0 +1,72 @@
|
||||
{
|
||||
opendocwrite.dpr
|
||||
|
||||
Demonstrates how to write an OpenDocument file using the fpspreadsheet library
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
}
|
||||
program opendocwrite;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpspreadsheet, fpsallformats, laz_fpspreadsheet;
|
||||
|
||||
var
|
||||
MyWorkbook: TsWorkbook;
|
||||
MyWorksheet: TsWorksheet;
|
||||
MyFormula: TRPNFormula;
|
||||
MyDir: string;
|
||||
i: Integer;
|
||||
a: TStringList;
|
||||
begin
|
||||
// Open the output file
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
|
||||
|
||||
// Write some number cells
|
||||
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
|
||||
begin
|
||||
MyWorksheet.WriteAnsiText(i, 0, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 1, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 2, ParamStr(0));
|
||||
MyWorksheet.WriteAnsiText(i, 3, ParamStr(0));
|
||||
end;
|
||||
}
|
||||
|
||||
// Write the formula E1 = A1 + B1
|
||||
// or, in RPN: A1, B1, +
|
||||
(* SetLength(MyFormula, 3);
|
||||
MyFormula[0].TokenID := INT_EXCEL_TOKEN_TREFV; {A1}
|
||||
MyFormula[0].Col := 0;
|
||||
MyFormula[0].Row := 0;
|
||||
MyFormula[1].TokenID := INT_EXCEL_TOKEN_TREFV; {B1}
|
||||
MyFormula[1].Col := 1;
|
||||
MyFormula[1].Row := 0;
|
||||
MyFormula[2].TokenID := INT_EXCEL_TOKEN_TADD; {+}
|
||||
MyWorksheet.WriteRPNFormula(0, 4, MyFormula);
|
||||
|
||||
// Creates a new worksheet
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');
|
||||
|
||||
// Write some string cells
|
||||
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', sfOpenDocument);
|
||||
MyWorkbook.Free;
|
||||
end.
|
||||
|
@ -5,15 +5,18 @@ Writes an OpenDocument 1.0 Spreadsheet document
|
||||
|
||||
An OpenDocument document is a compressed ZIP file with the following files inside:
|
||||
|
||||
content.xml
|
||||
meta.xml
|
||||
settings.xml
|
||||
styles.xml
|
||||
META-INF\manifest.xml
|
||||
filename\
|
||||
content.xml - Actual contents
|
||||
meta.xml - Authoring data
|
||||
settings.xml - User persistent viewing information, such as zoom, cursor position, etc.
|
||||
styles.xml - Styles, which are the only way to do formatting
|
||||
mimetype - application/vnd.oasis.opendocument.spreadsheet
|
||||
META-INF
|
||||
manifest.xml -
|
||||
|
||||
Specifications obtained from:
|
||||
|
||||
write url here
|
||||
http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.pdf
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
|
||||
@ -28,7 +31,7 @@ unit fpsopendocument;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, {zipper,}
|
||||
Classes, SysUtils, zipper,
|
||||
fpspreadsheet;
|
||||
|
||||
type
|
||||
@ -37,16 +40,24 @@ type
|
||||
|
||||
TsSpreadOpenDocWriter = class(TsCustomSpreadWriter)
|
||||
protected
|
||||
// FZip: TZipper;
|
||||
FMetaInfManifest: string;
|
||||
FZip: TZipper;
|
||||
// Strings with the contents of files
|
||||
// filename\
|
||||
FMeta, FSettings, FStyles: string;
|
||||
FContent: string;
|
||||
FMimetype: string;
|
||||
// filename\META-INF
|
||||
FMetaInfManifest: string;
|
||||
// Routines to write those files
|
||||
procedure WriteGlobalFiles;
|
||||
procedure WriteContent(AData: TsWorkbook);
|
||||
public
|
||||
{ General writing methods }
|
||||
procedure WriteStringToFile(AFileName, AString: string);
|
||||
procedure WriteToFile(AFileName: string; AData: TsWorkbook); override;
|
||||
procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override;
|
||||
{ Record writing methods }
|
||||
procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TRPNFormula); override;
|
||||
procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override;
|
||||
procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override;
|
||||
end;
|
||||
@ -62,6 +73,7 @@ const
|
||||
OOXML_PATH_META = 'meta.xml';
|
||||
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';
|
||||
|
||||
@ -94,72 +106,9 @@ const
|
||||
|
||||
{ TsSpreadOpenDocWriter }
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteStringToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes a string to a file. Helper convenience method.
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOpenDocWriter.WriteStringToFile(AFileName, AString: string);
|
||||
var
|
||||
TheStream : TFileStream;
|
||||
S : String;
|
||||
procedure TsSpreadOpenDocWriter.WriteGlobalFiles;
|
||||
begin
|
||||
TheStream := TFileStream.Create(AFileName, fmCreate);
|
||||
S:=AString;
|
||||
TheStream.WriteBuffer(Pointer(S)^,Length(S));
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes an OOXML document to the disc
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOpenDocWriter.WriteToFile(AFileName: string; AData: TsWorkbook);
|
||||
var
|
||||
TempDir: string;
|
||||
begin
|
||||
{FZip := TZipper.Create;
|
||||
FZip.ZipFiles(AFileName, x);
|
||||
FZip.Free;}
|
||||
|
||||
WriteToStream(nil, AData);
|
||||
|
||||
TempDir := IncludeTrailingBackslash(AFileName);
|
||||
|
||||
{ files on the root path }
|
||||
|
||||
ForceDirectories(TempDir);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_CONTENT, FContent);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_META, FMeta);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_SETTINGS, FSettings);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_STYLES, FStyles);
|
||||
|
||||
{ META-INF directory }
|
||||
|
||||
ForceDirectories(TempDir + OPENDOC_PATH_METAINF);
|
||||
|
||||
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
|
||||
// WriteCellsToStream(AStream, AData.GetFirstWorksheet.FCells);
|
||||
FMimetype := 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
|
||||
FMetaInfManifest :=
|
||||
XML_HEADER + LineEnding +
|
||||
@ -247,7 +196,13 @@ begin
|
||||
'</style:master-page>' + LineEnding +
|
||||
'</office:master-styles>' + LineEnding +
|
||||
'</office:document-styles>';
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteContent(AData: TsWorkbook);
|
||||
var
|
||||
i: Integer;
|
||||
CurSheet: TsWorksheet;
|
||||
begin
|
||||
FContent :=
|
||||
XML_HEADER + LineEnding +
|
||||
'<office:document-content xmlns:office="' + SCHEMAS_XMLNS_OFFICE +
|
||||
@ -270,127 +225,151 @@ begin
|
||||
'" xmlns:xforms="' + SCHEMAS_XMLNS_XFORMS +
|
||||
'" xmlns:xsd="' + SCHEMAS_XMLNS_XSD +
|
||||
'" xmlns:xsi="' + SCHEMAS_XMLNS_XSI + '">' + LineEnding +
|
||||
'<office:scripts />' + LineEnding +
|
||||
'<office:font-face-decls>' + LineEnding +
|
||||
'<style:font-face style:name="Arial" svg:font-family="Arial" xmlns:v="urn:schemas-microsoft-com:vml" />' + LineEnding +
|
||||
'</office:font-face-decls>' + LineEnding +
|
||||
'<office:automatic-styles>' + LineEnding +
|
||||
'<style:style style:name="ID0EM" style:family="table-column" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<style:table-column-properties fo:break-before="auto" style:column-width="1.961cm" />' + LineEnding +
|
||||
'</style:style>' + LineEnding +
|
||||
'<style:style style:name="ID0EM" style:family="table-row" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<style:table-row-properties fo:break-before="auto" style:row-height="0.45cm" />' + LineEnding +
|
||||
'</style:style>' + LineEnding +
|
||||
'<style:style style:name="ID1E6B" style:family="table-cell" style:parent-style-name="Default" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<style:text-properties fo:font-size="10" style:font-name="Arial" />' + LineEnding +
|
||||
'</style:style>' + LineEnding +
|
||||
'<style:style style:name="ID2EY" style:family="table" style:master-page-name="Default" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<style:table-properties />' + LineEnding +
|
||||
'</style:style>' + LineEnding +
|
||||
'<style:style style:name="scenario" style:family="table" style:master-page-name="Default">' + LineEnding +
|
||||
'<style:table-properties table:display="false" style:writing-mode="lr-tb" />' + LineEnding +
|
||||
'</style:style>' + LineEnding +
|
||||
'</office:automatic-styles>' + LineEnding +
|
||||
'<office:body>' + LineEnding +
|
||||
'<office:spreadsheet>' + LineEnding +
|
||||
'<table:table table:name="Tabelle1" table:style-name="ID2EY">' + LineEnding +
|
||||
'<table:table-column table:style-name="ID0EM" table:number-columns-repeated="256" table:default-cell-style-name="ID1E6B" xmlns:v="urn:schemas-microsoft-com:vml" />' + LineEnding +
|
||||
'<table:table-row table:style-name="ID0EM" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<table:table-cell office:value-type="float" office:value="1">' + LineEnding +
|
||||
'<text:p>1</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="float" office:value="2">' + LineEnding +
|
||||
'<text:p>2</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="float" office:value="3">' + LineEnding +
|
||||
'<text:p>3</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="float" office:value="4">' + LineEnding +
|
||||
'<text:p>4</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell table:number-columns-repeated="252" />' + LineEnding +
|
||||
'</table:table-row>' + LineEnding +
|
||||
'<table:table-row table:style-name="ID0EM" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
'<table:table-cell office:value-type="string">' + LineEnding +
|
||||
'<text:p>First</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="string">' + LineEnding +
|
||||
'<text:p>Second</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="string">' + LineEnding +
|
||||
'<text:p>Third</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell office:value-type="string">' + LineEnding +
|
||||
'<text:p>Fourth</text:p>' + LineEnding +
|
||||
'</table:table-cell>' + LineEnding +
|
||||
'<table:table-cell table:number-columns-repeated="252" />' + LineEnding +
|
||||
'</table:table-row>' + LineEnding +
|
||||
'</table:table>' + LineEnding +
|
||||
'<table:database-ranges />' + LineEnding +
|
||||
'</office:spreadsheet>' + LineEnding +
|
||||
'</office:body>' + LineEnding +
|
||||
' <office:scripts />' + LineEnding +
|
||||
|
||||
// Fonts
|
||||
' <office:font-face-decls>' + LineEnding +
|
||||
' <style:font-face style:name="Arial" svg:font-family="Arial" xmlns:v="urn:schemas-microsoft-com:vml" />' + LineEnding +
|
||||
' </office:font-face-decls>' + LineEnding +
|
||||
|
||||
// Automatic styles
|
||||
' <office:automatic-styles>' + LineEnding +
|
||||
' <style:style style:name="ID0EM" style:family="table-column" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
' <style:table-column-properties fo:break-before="auto" style:column-width="1.961cm" />' + LineEnding +
|
||||
' </style:style>' + LineEnding +
|
||||
' <style:style style:name="ID0EM" style:family="table-row" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
' <style:table-row-properties fo:break-before="auto" style:row-height="0.45cm" />' + LineEnding +
|
||||
' </style:style>' + LineEnding +
|
||||
' <style:style style:name="ID1E6B" style:family="table-cell" style:parent-style-name="Default" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
' <style:text-properties fo:font-size="10" style:font-name="Arial" />' + LineEnding +
|
||||
' </style:style>' + LineEnding +
|
||||
' <style:style style:name="ID2EY" style:family="table" style:master-page-name="Default" xmlns:v="urn:schemas-microsoft-com:vml">' + LineEnding +
|
||||
' <style:table-properties />' + LineEnding +
|
||||
' </style:style>' + LineEnding +
|
||||
' <style:style style:name="scenario" style:family="table" style:master-page-name="Default">' + LineEnding +
|
||||
' <style:table-properties table:display="false" style:writing-mode="lr-tb" />' + LineEnding +
|
||||
' </style:style>' + LineEnding +
|
||||
' </office:automatic-styles>' + LineEnding +
|
||||
|
||||
// Body
|
||||
' <office:body>' + LineEnding +
|
||||
' <office:spreadsheet>' + LineEnding;
|
||||
|
||||
for i := 0 to AData.GetWorksheetCount - 1 do
|
||||
begin
|
||||
CurSheet := Adata.GetWorksheetByIndex(i);
|
||||
|
||||
// Header
|
||||
FContent := FContent + '<table:table table:name="' + CurSheet.Name + '" table:style-name="ID2EY">' + LineEnding;
|
||||
|
||||
// The cells need to be written in order, row by row
|
||||
WriteCellsToStream(nil, CurSheet.FCells);
|
||||
|
||||
// Footer
|
||||
FContent := FContent + '</table:table>' + LineEnding;
|
||||
end;
|
||||
|
||||
FContent := FContent +
|
||||
' </office:spreadsheet>' + LineEnding +
|
||||
' </office:body>' + LineEnding +
|
||||
'</office:document-content>';
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteLabel ()
|
||||
* TsSpreadOOXMLWriter.WriteStringToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes an Excel 2 LABEL record
|
||||
*
|
||||
* Writes a string to the sheet
|
||||
* DESCRIPTION: Writes a string to a file. Helper convenience method.
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOpenDocWriter.WriteLabel(AStream: TStream; const ARow,
|
||||
ACol: Word; const AValue: string);
|
||||
procedure TsSpreadOpenDocWriter.WriteStringToFile(AFileName, AString: string);
|
||||
var
|
||||
L: Byte;
|
||||
TheStream : TFileStream;
|
||||
S : String;
|
||||
begin
|
||||
L := Length(AValue);
|
||||
|
||||
{ BIFF Record header }
|
||||
// AStream.WriteWord(WordToLE(INT_EXCEL_ID_LABEL));
|
||||
// AStream.WriteWord(WordToLE(8 + L));
|
||||
|
||||
{ BIFF Record data }
|
||||
// AStream.WriteWord(WordToLE(ARow));
|
||||
// AStream.WriteWord(WordToLE(ACol));
|
||||
|
||||
{ BIFF2 Attributes }
|
||||
AStream.WriteByte($0);
|
||||
AStream.WriteByte($0);
|
||||
AStream.WriteByte($0);
|
||||
|
||||
{ String with 8-bit size }
|
||||
AStream.WriteByte(L);
|
||||
AStream.WriteBuffer(AValue[1], L);
|
||||
TheStream := TFileStream.Create(AFileName, fmCreate);
|
||||
S:=AString;
|
||||
TheStream.WriteBuffer(Pointer(S)^,Length(S));
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteNumber ()
|
||||
* TsSpreadOOXMLWriter.WriteToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes an Excel 2 NUMBER record
|
||||
*
|
||||
* Writes a number (64-bit IEE 754 floating point) to the sheet
|
||||
* DESCRIPTION: Writes an OOXML document to the disc
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOpenDocWriter.WriteToFile(AFileName: string; AData: TsWorkbook);
|
||||
var
|
||||
TempDir: string;
|
||||
begin
|
||||
{FZip := TZipper.Create;
|
||||
FZip.ZipFiles(AFileName, x);
|
||||
FZip.Free;}
|
||||
|
||||
// WriteToStream(nil, AData);
|
||||
|
||||
WriteGlobalFiles();
|
||||
WriteContent(AData);
|
||||
|
||||
TempDir := IncludeTrailingBackslash(AFileName);
|
||||
|
||||
{ files on the root path }
|
||||
|
||||
ForceDirectories(TempDir);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_CONTENT, FContent);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_META, FMeta);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_SETTINGS, FSettings);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_STYLES, FStyles);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_MIMETYPE, FMimetype);
|
||||
|
||||
{ META-INF directory }
|
||||
|
||||
ForceDirectories(TempDir + OPENDOC_PATH_METAINF);
|
||||
|
||||
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
|
||||
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteFormula(AStream: TStream; const ARow,
|
||||
ACol: Word; const AFormula: TRPNFormula);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteLabel(AStream: TStream; const ARow,
|
||||
ACol: Word; const AValue: string);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteNumber(AStream: TStream; const ARow,
|
||||
ACol: Cardinal; const AValue: double);
|
||||
begin
|
||||
{ BIFF Record header }
|
||||
// AStream.WriteWord(WordToLE(INT_EXCEL_ID_NUMBER));
|
||||
// AStream.WriteWord(WordToLE(15));
|
||||
|
||||
{ BIFF Record data }
|
||||
// AStream.WriteWord(WordToLE(ARow));
|
||||
// AStream.WriteWord(WordToLE(ACol));
|
||||
|
||||
{ BIFF2 Attributes }
|
||||
AStream.WriteByte($0);
|
||||
AStream.WriteByte($0);
|
||||
AStream.WriteByte($0);
|
||||
|
||||
{ IEE 754 floating-point value }
|
||||
AStream.WriteBuffer(AValue, 8);
|
||||
// The row should already be the correct one
|
||||
FContent := FContent +
|
||||
'<table:table-row table:style-name="ro' + IntToStr(ARow) + '">' + LineEnding +
|
||||
' <table:table-cell office:value-type="float" office:value="' + IntToStr(ACol) + '1">' + LineEnding +
|
||||
' <text:p>1</text:p>' + LineEnding +
|
||||
' </table:table-cell>' + LineEnding +
|
||||
'</table:table-row>' + LineEnding;
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
|
@ -643,7 +643,8 @@ end;
|
||||
}
|
||||
function TsWorkbook.GetWorksheetByIndex(AIndex: Cardinal): TsWorksheet;
|
||||
begin
|
||||
Result := TsWorksheet(FWorksheets.Items[AIndex]);
|
||||
if AIndex < FWorksheets.Count then Result := TsWorksheet(FWorksheets.Items[AIndex])
|
||||
else Result := nil;
|
||||
end;
|
||||
|
||||
{@@
|
||||
|
@ -32,7 +32,7 @@ unit xlsxooxml;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, {zipper,}
|
||||
Classes, SysUtils, zipper,
|
||||
fpspreadsheet;
|
||||
|
||||
type
|
||||
@ -41,10 +41,11 @@ type
|
||||
|
||||
TsSpreadOOXMLWriter = class(TsCustomSpreadWriter)
|
||||
protected
|
||||
// FZip: TZipper;
|
||||
FZip: TZipper;
|
||||
FContentTypes: string;
|
||||
FRelsRels: string;
|
||||
FWorkbook, FWorkbookRels, FStyles, FSharedString, FSheet1: string;
|
||||
procedure FillFileContentStrings(AData: TsWorkbook);
|
||||
public
|
||||
{ General writing methods }
|
||||
procedure WriteStringToFile(AFileName, AString: string);
|
||||
@ -94,82 +95,7 @@ const
|
||||
|
||||
{ TsSpreadOOXMLWriter }
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteStringToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes a string to a file. Helper convenience method.
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOOXMLWriter.WriteStringToFile(AFileName, AString: string);
|
||||
var
|
||||
TheStream : TFileStream;
|
||||
S : String;
|
||||
begin
|
||||
TheStream := TFileStream.Create(AFileName, fmCreate);
|
||||
S:=AString;
|
||||
TheStream.WriteBuffer(Pointer(S)^,Length(S));
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes an OOXML document to the disc
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOOXMLWriter.WriteToFile(AFileName: string; AData: TsWorkbook);
|
||||
var
|
||||
TempDir: string;
|
||||
begin
|
||||
{FZip := TZipper.Create;
|
||||
FZip.ZipFiles(AFileName, x);
|
||||
FZip.Free;}
|
||||
|
||||
WriteToStream(nil, AData);
|
||||
|
||||
TempDir := IncludeTrailingBackslash(AFileName);
|
||||
|
||||
{ files on the root path }
|
||||
|
||||
ForceDirectories(TempDir);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_TYPES, FContentTypes);
|
||||
|
||||
{ _rels directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_RELS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_RELS_RELS, FRelsRels);
|
||||
|
||||
{ xl directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_XL_RELS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_RELS_RELS, FWorkbookRels);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_WORKBOOK, FWorkbook);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_STYLES, FStyles);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_STRINGS, FSharedString);
|
||||
|
||||
{ xl\worksheets directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_XL_WORKSHEETS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_WORKSHEETS + 'sheet1.xml', FSheet1);
|
||||
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 TsSpreadOOXMLWriter.WriteToStream(AStream: TStream; AData: TsWorkbook);
|
||||
procedure TsSpreadOOXMLWriter.FillFileContentStrings(AData: TsWorkbook);
|
||||
begin
|
||||
// WriteCellsToStream(AStream, AData.GetFirstWorksheet.FCells);
|
||||
|
||||
@ -305,6 +231,76 @@ begin
|
||||
' </row>' + LineEnding +
|
||||
' </sheetData>' + LineEnding +
|
||||
'</worksheet>';
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteStringToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes a string to a file. Helper convenience method.
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOOXMLWriter.WriteStringToFile(AFileName, AString: string);
|
||||
var
|
||||
TheStream : TFileStream;
|
||||
S : String;
|
||||
begin
|
||||
TheStream := TFileStream.Create(AFileName, fmCreate);
|
||||
S:=AString;
|
||||
TheStream.WriteBuffer(Pointer(S)^,Length(S));
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteToFile ()
|
||||
*
|
||||
* DESCRIPTION: Writes an OOXML document to the disc
|
||||
*
|
||||
*******************************************************************}
|
||||
procedure TsSpreadOOXMLWriter.WriteToFile(AFileName: string; AData: TsWorkbook);
|
||||
var
|
||||
TempDir: string;
|
||||
begin
|
||||
{ FZip := TZipper.Create;
|
||||
FZip.ZipFiles(AFileName, x);
|
||||
FZip.Free;}
|
||||
|
||||
FillFileContentStrings(AData);
|
||||
|
||||
TempDir := IncludeTrailingBackslash(AFileName);
|
||||
|
||||
{ files on the root path }
|
||||
|
||||
ForceDirectories(TempDir);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_TYPES, FContentTypes);
|
||||
|
||||
{ _rels directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_RELS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_RELS_RELS, FRelsRels);
|
||||
|
||||
{ xl directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_XL_RELS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_RELS_RELS, FWorkbookRels);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_WORKBOOK, FWorkbook);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_STYLES, FStyles);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_STRINGS, FSharedString);
|
||||
|
||||
{ xl\worksheets directory }
|
||||
|
||||
ForceDirectories(TempDir + OOXML_PATH_XL_WORKSHEETS);
|
||||
|
||||
WriteStringToFile(TempDir + OOXML_PATH_XL_WORKSHEETS + 'sheet1.xml', FSheet1);
|
||||
end;
|
||||
|
||||
procedure TsSpreadOOXMLWriter.WriteToStream(AStream: TStream; AData: TsWorkbook);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user