Recent

Author Topic: [SOLVED] fpspreadsheet problem on Win8 (but in linux everything works fine)  (Read 9951 times)

xsid

  • Newbie
  • Posts: 6
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: [Select]
...
OD1: TOpenDialog;
WG1: TsWorksheetGrid;
...

part of "var" section of the program:
Code: [Select]
...
WB: TsWorkbook;
WS: TsWorksheet;
...

and the code to open file is:
Code: [Select]
...
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;
...

Did I miss smthg elementary? What am I doing wrong? Thnx in advance for your replies.
« Last Edit: December 26, 2012, 12:22:36 pm by xsid »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #1 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...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

xsid

  • Newbie
  • Posts: 6
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #2 on: December 26, 2012, 10:07:09 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...

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: [Select]
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
  Dialogs, ComCtrls, Menus, fpspreadsheetgrid, fpspreadsheet,
  fpsallformats, LCLType, Grids, Process, LConvEncoding;

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #3 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.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

xsid

  • Newbie
  • Posts: 6
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #4 on: December 26, 2012, 11:41:39 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.

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: [Select]
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.

the result is (screenshot with error message)


2) sad...

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

BlueIcaro

  • Hero Member
  • *****
  • Posts: 832
    • Blog personal
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #5 on: December 26, 2012, 12:02:25 pm »
Hi, try to change the name of the file, put a small and simple name to your excel file, like
Quote
test.xls
without spaces, etc.  And the name with english characters
This way you can check if there is a problem with the name of the file or the format.

/BlueIcaro

xsid

  • Newbie
  • Posts: 6
Re: fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #6 on: December 26, 2012, 12:21:39 pm »
Hi, try to change the name of the file, put a small and simple name to your excel file, like
Quote
test.xls
without spaces, etc.  And the name with english characters
This way you can check if there is a problem with the name of the file or the format.

/BlueIcaro

You are my hero  :)
So simple, but I even didn't think about this. Thanks everybody in this thread for discussion about mentioned problem. Solved.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 832
    • Blog personal
I had a similar problem, a few day ago when I playing for hobbie with that package, with a name with spaces and spanish letters (ñ).

May be it's a bug. I investigated a little bit and I found that the problem comes from the filename.

But due the lack of free time I couldn't investigate more.

May be you do it, and report ad a bug, if this is bug.

/BlueIcaro

Edit: I had the problem with w7/64

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
I would check if you need to convert between UTF8 (which Lazarus uses) and ANSI charactersets. See the wiki pages.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Looks like the usual problem that we have in FPC due to the lack of a proper Unicode support in FPC.

I could change to use TUTF8FileStream instead of TFileStream, but this would only be a temporary solution and then code break when FPC migrates to their incompatible UTF16 solution.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [SOLVED] fpspreadsheet problem on Win8 (but in linux everything works fine)
« Reply #10 on: December 27, 2012, 03:06:56 pm »
Yep, it does.

I wouldn't change the stream code either - perhaps an improved error message may help? See the attached patch against svn r2594... (hope I didn't mess anything up with format detection etc)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018