[SOLVED] fpspreadsheet problem on Win8 (but in linux everything works fine) lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- xsid · 2012-12-26 07:52 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. ---------------------------------------------------------------------- BigChimp · 2012-12-26 08:55 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 · 2012-12-26 09:07 Quote from: BigChimp on December 26, 2012, 09:55:43 am2 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 · 2012-12-26 10:05 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 · 2012-12-26 10:41 Quote from: BigChimp on December 26, 2012, 11:05:36 am1. 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 · 2012-12-26 11:02 Hi, try to change the name of the file, put a small and simple name to your excel file, like Quotetest.xlswithout 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 · 2012-12-26 11:21 Quote from: BlueIcaro on December 26, 2012, 12:02:25 pmHi, try to change the name of the file, put a small and simple name to your excel file, like Quotetest.xlswithout 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 · 2012-12-26 14:17 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 · 2012-12-26 14:34 I would check if you need to convert between UTF8 (which Lazarus uses) and ANSI charactersets. See the wiki pages. ---------------------------------------------------------------------- felipemdc · 2012-12-27 09:27 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 · 2012-12-27 14:06 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)