I am trying to export to Excel some data using TMS's TFlexCelReport in Delphi 10.2 and getting an error which I cannot figure out how to fix. In an earlier version of Delphi (2007) and TMS it worked fine. The data is being retrieved from the database, some formatting is done and an XML file is created. Then, using this file and an xsl template file I'm trying to produce an Excel output but I'm getting an error saying that 'the named range MAIN on the Excel template refers to DataTable "MAIN" which is not defined. Verify that you added the dataset with FlexCelReport.AddTable method.' I tried adding it but it doesn't help. Not sure if I can attach the XML file and the template, in case any of them is relevant.
Tried adding the MAIN table but it doesn't help. It's on Windows 10.
procedure TdmExport.RunReport(const ExportFileName: String);
var
Report: TFlexCelReport;
TemplateStream: TResourceStream;
OutputStream: TFileStream;
begin
Report := TFlexCelReport.Create(true);
try
Report.GetInclude := GetIncludes;
Report.AddTable('cdsExport', cdsExport);
TemplateStream := TResourceStream.Create(hinstance, 'CATATemplatesOnTheExe', RT_RCDATA);
try
OutputStream := TFileStream.Create(ExportFileName, fmCreate);
try
Report.Run(TemplateStream, OutputStream); // when executing this I get the error
finally
OutputStream.Free;
end;
finally
TemplateStream.Free;
end;
finally
Report.Free;
end;
end;
Should get an Excel file formatted according to the template but I get the error I mentioned above.
procedure TdmExport.RunReport(const ExportFileName: String);
var
Report: TFlexCelReport;
TemplateStream: TResourceStream;
OutputStream: TFileStream;
begin
Report := TFlexCelReport.Create(true);
try
Report.GetInclude := GetIncludes;
Report.AddTable('cdsExport', cdsExport);
TemplateStream := TResourceStream.Create(hinstance, 'CATATemplatesOnTheExe', RT_RCDATA);
try
OutputStream := TFileStream.Create(ExportFileName, fmCreate);
try
Report.Run(TemplateStream, OutputStream); // when executing this I get the error
finally
OutputStream.Free;
end;
finally
TemplateStream.Free;
end;
finally
Report.Free;
end;
end;
The expected result is an Excel file built using the cdsExport.xml and the xsl template file. Instead I'm getting the error I mentioned above. Not sure if and how I could attach the xml and xsl files, if needed.