Forum > FPSpreadsheet

[SOLVED] fpspreadsheet problem on Win8 (but in linux everything works fine)

(1/3) > >>

xsid:
Hello everybody!
Hope smbdy can help me with ridiculous problem: when I trying to open an XLS file in linux - everything works just fine, but in windows the same part of code gives me an error, it says that I'am trying to load an unsupported file format. I said "ridiculous", because in "uses" section presents all needed things, including "fpsallformats".

part of "type" section of the program:

--- Code: ---...
OD1: TOpenDialog;
WG1: TsWorksheetGrid;
...

--- End code ---

part of "var" section of the program:

--- Code: ---...
WB: TsWorkbook;
WS: TsWorksheet;
...

--- End code ---

and the code to open file is:

--- Code: ---...
if LowerCase(ExtractFileExt(OD1.FileName))='.xls' then
begin
  WB:=TsWorkbook.Create;
  WB.ReadFromFile(OD1.FileName); {windows gives me an error on this line}
  WS:=WB.GetFirstWorksheet;
  WG1.LoadFromWorksheet(WS);
end;
...

--- End code ---

Did I miss smthg elementary? What am I doing wrong? Thnx in advance for your replies.

BigChimp:
2 things I can think of:
1. the fpspreadsheet code you have on Linux and Windows differ
2. you need to add some additional units to your uses clause. There have been at least one thread in the forum lately with that problem and solution...

xsid:

--- Quote from: BigChimp on December 26, 2012, 09:55:43 am ---2 things I can think of:
1. the fpspreadsheet code you have on Linux and Windows differ
2. you need to add some additional units to your uses clause. There have been at least one thread in the forum lately with that problem and solution...

--- End quote ---

Thanks for reply, but
1) the code is the same: I'm working with the one folder synced by dropbox
2) the solution was in adding "fpsallformats". Solution, which, in my case not working. And if the problem is in the units, which I must use in addition to existing in my project?


--- Code: ---uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
  Dialogs, ComCtrls, Menus, fpspreadsheetgrid, fpspreadsheet,
  fpsallformats, LCLType, Grids, Process, LConvEncoding;

--- End code ---

BigChimp:
1. So you're syncing the fpspreadsheet package? Ok, that covers that.
If you're not using the latest fpspreadsheet from SVN I would give that a try...

2. As for adding any other units: no idea, sorry.

xsid:

--- Quote from: BigChimp on December 26, 2012, 11:05:36 am ---1. So you're syncing the fpspreadsheet package? Ok, that covers that.
If you're not using the latest fpspreadsheet from SVN I would give that a try...

2. As for adding any other units: no idea, sorry.

--- End quote ---

1) I'm syncing only project folder, all packages are installed from svn both on windows and linux. I wrote the simple program on windows, which just opens the xls file and the error is the same:


--- Code: ---unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, fpspreadsheetgrid, Forms, Controls, Graphics,
  Dialogs, Buttons, fpsallformats, fpspreadsheet;

type

  { TForm1 }

  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    SpeedButton1: TSpeedButton;
    sWorksheetGrid1: TsWorksheetGrid;
    procedure SpeedButton1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  wb:TsWorkbook;
  ws:TsWorksheet;
implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
  wb:=TsWorkbook.Create;
  wb.ReadFromFile(OpenDialog1.FileName);
  ws:=wb.GetFirstWorksheet;
  sWorksheetGrid1.LoadFromWorksheet(ws);
  end;
end;

end.

--- End code ---

the result is (screenshot with error message)


2) sad...

I've reinstall Lazarus, fpspreadsheet package, but with no result.

Navigation

[0] Message Index

[#] Next page

Go to full version