How to use XLSX Export Events?

Using Fast Reports 2023.3.1 VCL, with Embarcadero Rad studio 11 with Delphi, I have converted Quick Reports code and would like to save my reports to Excel files, but different from the report displayed on the screen. My report displays 26 columns of data, so I had to use a small font on each cell to make them fit on a single page.

Fast Reports preserves these small fonts to Excel, which I do not want, since most monitors are wider than a sheet of paper. Quick Reports did not preserve these small fonts.

The frxXLSLExport filter provides some options, but 'discard cell formats' was not one of them. The only events I could find were BeforeExport, BeginExport, and GenerateSheetName. I found several properties, but none that could turn off formatting.

In order to determine whether I would be able to make use of the three events above, I added them to my code as follows:

procedure TFormCottonAndSalesPositionRep.frxSimpleTextExport1BeforeExport(Sender: TObject);

begin

end;

procedure TFormCottonAndSalesPositionRep.frxXLSXExport1BeginExport(Sender: TObject);

begin

end;

function TFormCottonAndSalesPositionRep.frxXLSXExport1GenerateSheetName(

PageName: string; PageNumber: Integer): string;

begin

end;

I was able to set breakpoints and verify that Fast Reports did call these methods.

However, even though my code did nothing except return, the result was different. Before this change, I could save my report as an Excel spreadsheet and open it in Excel (although the cells were so small that they were unreadable unless I selected all columns and zoomed). After I added the code above, regenerated the Excel file, and tried to open it, I got a popup message:

We found a problem with some content in '{myFileName}'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

I clicked Yes and the resulting spreadsheet looked the same as before.

If simply adding empty methods causes Fast Reports to generate invalid worksheets, how will I be able to eliminate the cell formatting?

Tom Disque

Comments

  • G'day Tom,

    Your post is on a similar theme to one a couple of months back.

    Basically, we gave up using FastReports to export to anyrhing other than PDF because of its "quirky" treatment of formatting.

    Instead we use RAD Studio's ISAM functionality (reusing the Queries that drive the Reports). A bit of creative work allowed us to integrate that with the Preview Form...

    Cheers, Paul

    See:

    https://forum.fast-report.com/en/discussion/comment/43662

  • Thanks for your response. It probably saved me from wasting time!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.