You've already forked lazarus-ccr
fpspreadsheet: Add demos for wikitables. Reader not working (Rainier, could you have a look?)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3230 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</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="wikitableread.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="wikitableread"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsStabs"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
@ -0,0 +1,66 @@
|
||||
{
|
||||
wikitableread.dpr
|
||||
|
||||
Demonstrates how to read a wikitable file using the fpspreadsheet library
|
||||
|
||||
}
|
||||
program wikitableread;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpspreadsheet, wikitable,
|
||||
laz_fpspreadsheet, fpsutils;
|
||||
|
||||
var
|
||||
MyWorkbook: TsWorkbook;
|
||||
MyWorksheet: TsWorksheet;
|
||||
InputFilename: string;
|
||||
MyDir: string;
|
||||
i: Integer;
|
||||
CurCell: PCell;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
// Open the input file
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
InputFileName := MyDir + 'test.wikitable_wikimedia';
|
||||
|
||||
if not FileExists(InputFileName) then begin
|
||||
WriteLn('Input file ', InputFileName, ' does not exist. Please run wikitablewrite first.');
|
||||
Halt;
|
||||
end;
|
||||
WriteLn('Opening input file ', InputFilename);
|
||||
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
|
||||
MyWorkbook.ReadFromFile(InputFilename, sfWikiTable_WikiMedia);
|
||||
|
||||
MyWorksheet := MyWorkbook.GetFirstWorksheet;
|
||||
|
||||
// Write all cells with contents to the console
|
||||
WriteLn('');
|
||||
WriteLn('Contents of the first worksheet of the file:');
|
||||
WriteLn('');
|
||||
|
||||
CurCell := MyWorkSheet.GetFirstCell();
|
||||
for i := 0 to MyWorksheet.GetCellCount - 1 do
|
||||
begin
|
||||
Write('Row: ', CurCell^.Row,
|
||||
' Col: ', CurCell^.Col, ' Value: ',
|
||||
UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(CurCell^.Row,
|
||||
CurCell^.Col))
|
||||
);
|
||||
if Length(CurCell^.RPNFormulaValue) > 0 then
|
||||
WriteLn(' Formula: ', MyWorkSheet.ReadRPNFormulaAsString(CurCell))
|
||||
else
|
||||
WriteLn;
|
||||
CurCell := MyWorkSheet.GetNextCell();
|
||||
end;
|
||||
|
||||
// Finalization
|
||||
MyWorkbook.Free;
|
||||
end.
|
||||
|
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="wikitablewrite"/>
|
||||
<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="wikitablewrite.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value=".."/>
|
||||
<SrcPath Value=".."/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsStabs"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
@ -0,0 +1,53 @@
|
||||
{
|
||||
wikitablewrite.dpr
|
||||
|
||||
Demonstrates how to write a wikitable file using the fpspreadsheet library
|
||||
}
|
||||
program wikitablewrite;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpspreadsheet, wikitable,
|
||||
laz_fpspreadsheet;
|
||||
|
||||
const
|
||||
Str_First = 'First';
|
||||
Str_Second = 'Second';
|
||||
Str_Third = 'Third';
|
||||
Str_Fourth = 'Fourth';
|
||||
Str_Worksheet1 = 'Meu Relatório';
|
||||
Str_Worksheet2 = 'My Worksheet 2';
|
||||
Str_Total = 'Total:';
|
||||
var
|
||||
MyWorkbook: TsWorkbook;
|
||||
MyWorksheet: TsWorksheet;
|
||||
MyRPNFormula: TsRPNFormula;
|
||||
MyDir: string;
|
||||
number: Double;
|
||||
lCell: PCell;
|
||||
lCol: TCol;
|
||||
i: Integer;
|
||||
r: Integer = 10;
|
||||
s: String;
|
||||
begin
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
|
||||
MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet1);
|
||||
|
||||
// Write some cells
|
||||
MyWorksheet.WriteUTF8Text(0, 0, 'This is a text:');
|
||||
MyWorksheet.WriteUTF8Text(0, 1, 'Hello world!');
|
||||
MyWorksheet.WriteUTF8Text(1, 0, 'This is a number:');
|
||||
MyWorksheet.WriteNumber(1, 1, 3.141592);
|
||||
MyWorksheet.WriteUTF8Text(2, 0, 'This is a date:');
|
||||
Myworksheet.WriteDateTime(2, 1, date());
|
||||
|
||||
// Save the spreadsheet to a file
|
||||
MyWorkbook.WriteToFile(MyDir + 'test.wikitable_wikimedia', sfWikitable_wikimedia);
|
||||
MyWorkbook.Free;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user