
- Allow processing of string formulas (conversion to/from rpn formulas, calculation). - Drop cell ContentType cctRPNFormula. - Drop field RPNFormulaValue of TCell record. - Remove all fekXXXX declarations for sheet functions. Function is specified by name now. - Complete registration mechanism for user-defined formulas. Adapt all demos Test cases working This commit does not yet support: shared formulas, formulas in ods. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3506 8e941d3f-bd1b-0410-a28a-d453659cc2b4
69 lines
1.5 KiB
ObjectPascal
69 lines
1.5 KiB
ObjectPascal
{
|
|
excel8read.lpr
|
|
|
|
Demonstrates how to read an Excel 8.x file using the fpspreadsheet library
|
|
|
|
AUTHORS: Felipe Monteiro de Carvalho
|
|
}
|
|
program excel8read;
|
|
|
|
{$mode delphi}{$H+}
|
|
|
|
uses
|
|
Classes, SysUtils, fpspreadsheet, xlsbiff8,
|
|
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.xls';
|
|
|
|
if not FileExists(InputFileName) then begin
|
|
WriteLn('Input file ', InputFileName, ' does not exist. Please run excel8write first.');
|
|
Halt;
|
|
end;
|
|
WriteLn('Opening input file ', InputFilename);
|
|
|
|
// Create the spreadsheet
|
|
MyWorkbook := TsWorkbook.Create;
|
|
MyWorkbook.ReadFormulas := true;
|
|
|
|
MyWorkbook.ReadFromFile(InputFilename, sfExcel8);
|
|
|
|
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 HasFormula(CurCell) then
|
|
WriteLn(' Formula: ', MyWorkSheet.ReadFormulaAsString(CurCell))
|
|
else
|
|
WriteLn;
|
|
CurCell := MyWorkSheet.GetNextCell();
|
|
end;
|
|
|
|
// Finalization
|
|
MyWorkbook.Free;
|
|
end.
|
|
|