You've already forked lazarus-ccr
fpspreadsheet: Add missing simple opendocread demo (for .ods file format)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3097 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<LRSInOutputDirectory Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="opendocread"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
</General>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<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="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="opendocread.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="opendocread"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<SearchPaths>
|
||||||
|
<OtherUnitFiles Value=".."/>
|
||||||
|
<SrcPath Value=".."/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Parsing>
|
||||||
|
<SyntaxOptions>
|
||||||
|
<UseAnsiStrings Value="False"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
|
<Other>
|
||||||
|
<CompilerMessages>
|
||||||
|
<UseMsgFile Value="True"/>
|
||||||
|
</CompilerMessages>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
</CONFIG>
|
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
opendocread.dpr
|
||||||
|
|
||||||
|
Demonstrates how to read an OpenDocument file using the fpspreadsheet library
|
||||||
|
|
||||||
|
AUTHORS: Felipe Monteiro de Carvalho, Werner Pamler
|
||||||
|
}
|
||||||
|
program opendocread;
|
||||||
|
|
||||||
|
{$mode delphi}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, fpspreadsheet, fpsallformats,
|
||||||
|
laz_fpspreadsheet;
|
||||||
|
|
||||||
|
var
|
||||||
|
MyWorkbook: TsWorkbook;
|
||||||
|
MyWorksheet: TsWorksheet;
|
||||||
|
InputFilename: String;
|
||||||
|
MyDir: string;
|
||||||
|
cell: PCell;
|
||||||
|
i: Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MyDir := ExtractFilePath(ParamStr(0));
|
||||||
|
|
||||||
|
// Open the input file
|
||||||
|
MyDir := ExtractFilePath(ParamStr(0));
|
||||||
|
InputFileName := MyDir + 'test.ods';
|
||||||
|
WriteLn('Opening input file ', InputFilename);
|
||||||
|
|
||||||
|
// Create the spreadsheet
|
||||||
|
MyWorkbook := TsWorkbook.Create;
|
||||||
|
|
||||||
|
MyWorkbook.ReadFromFile(InputFilename, sfOpenDocument);
|
||||||
|
|
||||||
|
MyWorksheet := MyWorkbook.GetFirstWorksheet;
|
||||||
|
|
||||||
|
// Write all cells with contents to the console
|
||||||
|
WriteLn('');
|
||||||
|
WriteLn('Contents of the first worksheet of the file:');
|
||||||
|
WriteLn('');
|
||||||
|
|
||||||
|
cell := MyWorkSheet.GetFirstCell();
|
||||||
|
for i := 0 to MyWorksheet.GetCellCount - 1 do begin
|
||||||
|
WriteLn('Row: ', cell^.Row,
|
||||||
|
' Col: ', cell^.Col, ' Value: ',
|
||||||
|
UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(cell^.Row, cell^.Col))
|
||||||
|
);
|
||||||
|
cell := MyWorkSheet.GetNextCell();
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Finalization
|
||||||
|
MyWorkbook.Free;
|
||||||
|
end.
|
||||||
|
|
@ -238,7 +238,7 @@ begin
|
|||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
|
|
||||||
ActualNumber:=MyWorkSheet.ReadAsNumber(Row, 0);
|
ActualNumber:=MyWorkSheet.ReadAsNumber(Row, 0);
|
||||||
CheckEquals(abs(SollNumbers[Row]-ActualNumber) < 1E-4, true,'Test value mismatch '
|
CheckEquals(SollNumbers[Row], ActualNumber,'Test value mismatch '
|
||||||
+'cell '+CellNotation(MyWorkSheet,Row));
|
+'cell '+CellNotation(MyWorkSheet,Row));
|
||||||
|
|
||||||
// Finalization
|
// Finalization
|
||||||
|
Reference in New Issue
Block a user