I'm using following test procedure to open an Excel file. Some files does open, some files shows "The file "" is invalid.
Both are created with excel, maybe different computers and different Excel.
What I'm doing wrong?
unit test;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvUtil, Vcl.StdCtrls, tmsAdvGridExcel,
Vcl.Grids, AdvObj, BaseGrid, AdvGrid;
type
TForm9 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
AdvGridExcelIO1: TAdvGridExcelIO;
OpenDialog1: TOpenDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
AdvGridExcelIO1.XLSImport(OpenDialog1.FileName);
end;
end;
end.
Hi,
Hi I got the file, thanks.
Thank you for test. I will save at least Excel97 next time.
Confusing is only, that message
"The file "" is invalid
shows no file name.
I think (but I am not 100% sure) that the filename "" is because we are using TStreams instead of loading directly from a filename. When loading from a stream, FlexCel doesn't know the filename, and there might be in fact no filename at all (if for example you were loading from a TMemoryStream).
Sorry, this topic is few years old, but I still have problems to open XLSX files.
Ist extension "XSLX" supported or not?
I can send you a short example.
Have a nice weekend.
Hi,
Yes, of course, xlsx has been supported since about 2012 with FlexCel 5. (it was already supported when this topic was created). We also support Excel95, 2, 3, and 4.
If you are having trouble with a specific file, you can send me the file to adrian@tmssoftware.com and I can take a look.
Just looking at the rest of the topic, is this about TAdvGridExcelIO? If that is the case, then no, AdvExcelIO doesn't support xlsx. FlexCel on the other hand does, and if you have a FlexCel license, you can use the free VCL Bridges ( TMS VCL Grid Excel Bridge Import/Export Bridge for TMS Grids to Excel .XLS and .XLSX files ) to work with xlsx files (and xls 2 to 97 too). The bridges are a more advanced version of TAdvGridExcelIO, with xlsx support among other stuff.
Hello Adrian,
thanks for info.
I have changed TAdvGridExcelIO to TAdvGridExcelImport/Export an it works now.