External table is not in the expected format
Posted: Fri Aug 09, 2013 9:57 am
Hi,
I'm running on 5.10.25
I have created an Excel2007 xlsx file with XLSReadWriteII5 like so:
XLS := TXLSReadWriteII5.Create(nil);
try
// somestuff
for i := 0 to Pred(FileContents.Count) do
begin
for j := 0 to Pred(LineContents.Count) do
XLS[0].AsString[j,i] := LineContents[j];
end;
XLS.Calculate;
XLS[0].CalcDimensions;
XLS.Filename := Result;
XLS.Write;
finally
FreeAndNil(XLS);
end;
If I try to read the generated file like this:
SampleDataset := TADODataSet.Create(nil);
SampleDataset.ConnectionString := GetConnectionString(Definition.SampleFile);
SampleDataset.CommandType := cmdTableDirect;
SampleDataset.CommandText := Definition.SampleSheet + '$';
SampleDataset.Open;
if will fail with "External table is not in the expected format"
If I add the following code to the file generation code it works:
ExcelObject := CreateOleObject('Excel.Application');
try
ExcelObject.Visible := False;
ExcelObject.WorkBooks.Open(Result);
ExcelObject.DisplayAlerts := False;
ExcelObject.WorkBooks[1].SaveAS(Result);
ExcelObject.WorkBooks.Close;
finally
ExcelObject.Quit;
end;
I obviously do not want to start Excel to post process the file. What am I doing wrong, or is this an issue in the XLSReadWriteII5 component?
Regards,
Frank
I'm running on 5.10.25
I have created an Excel2007 xlsx file with XLSReadWriteII5 like so:
XLS := TXLSReadWriteII5.Create(nil);
try
// somestuff
for i := 0 to Pred(FileContents.Count) do
begin
for j := 0 to Pred(LineContents.Count) do
XLS[0].AsString[j,i] := LineContents[j];
end;
XLS.Calculate;
XLS[0].CalcDimensions;
XLS.Filename := Result;
XLS.Write;
finally
FreeAndNil(XLS);
end;
If I try to read the generated file like this:
SampleDataset := TADODataSet.Create(nil);
SampleDataset.ConnectionString := GetConnectionString(Definition.SampleFile);
SampleDataset.CommandType := cmdTableDirect;
SampleDataset.CommandText := Definition.SampleSheet + '$';
SampleDataset.Open;
if will fail with "External table is not in the expected format"
If I add the following code to the file generation code it works:
ExcelObject := CreateOleObject('Excel.Application');
try
ExcelObject.Visible := False;
ExcelObject.WorkBooks.Open(Result);
ExcelObject.DisplayAlerts := False;
ExcelObject.WorkBooks[1].SaveAS(Result);
ExcelObject.WorkBooks.Close;
finally
ExcelObject.Quit;
end;
I obviously do not want to start Excel to post process the file. What am I doing wrong, or is this an issue in the XLSReadWriteII5 component?
Regards,
Frank