Hi,
the code is quite simple: just a form with a TsWorksheetGrid (to show the result) and a Button to read the external file and fill the TsWorksheetGrid.
This is the code:
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
fpspreadsheet, fpsallformats, fpspreadsheetgrid;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
sWorksheetGrid1: TsWorksheetGrid;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
InputFilename: String;
cell: PCell;
i: Integer;
Form1: TForm1;
MyWorksheet: TsWorksheet;
MyDir: string;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
MyDir := ExtractFilePath(ParamStr(0));
InputFileName := MyDir + 'ELpp1.xls'; // or use 'ELpp1.ods' (working)
if not FileExists(InputFileName) then begin
Showmessage('Input file '+ InputFileName+ ' does not exist. Please check first.');
Halt;
end;
try
sWorksheetGrid1.LoadFromSpreadsheetFile((InputFileName));
except
showmessage('Fault');
end;
end;
After deleting further worksheets in the original file, it seems now to work correct for the open source ELpp1.ods file. If I swap to ELpp1.xls, I still got the mentioned exception.
By the way, I can live with ELpp1.ods.
Enclosed the excel-file, one in odf and one in xls format. Maybe th xls format isn´t quite to standard???
Regards
MSC