Export XLS Problems

Hello

I working on a FMX project and I'm using the TmsFncDataGrid export to XLS functionality. I've encountered some problems that I want to share. I hope they are due to my lack of knowledge, although some of them sound like bugs:

  1. The grid header is not exported
  2. I'm drawing certain cells in the OnAfterDrawCell. Nothing I do there is exported in the XLS
  3. Text formatting with HTML tags is ignored, no bold, embedded images, etc.
  4. After exporting, certain formatting of the grid disappears (colors, alignments, lines that divide cells). Basically what was set at design time via Appearance (in the Column objects).
    Here I show the problems graphically.

I hope some of them can be resolved quickly.

Regards, Angel

Hi,

  1. Set
  TMSFNCDataGridExcelIO1.DataGridStartRow := 0;
  TMSFNCDataGridExcelIO1.DataGridStartCol := 0;

  1. That's normal, the graphics context is not available in Excel, therefore it's unable to know what it needs to draw. If you want colored cells please use
  TMSFNCDataGrid1.Layouts[2,2].Fill.Color := gcRed;
  TMSFNCDataGrid1.Layouts[3,3].Fill.Color := gcLime;
  TMSFNCDataGrid1.Layouts[4,4].Fill.Color := gcYellow;

Then the colors will export to excel

  1. It's not possible to export HTML formatted text in the built-in Excel export capabilities. This is possible when using the bridge between data grid and Flexcel. Please take a look here: TMS FNC Grid Excel Bridge Universal import/Export bridge for TMS FNC Grid to Excel .XLS and .XLSX files in VCL, FMX, LCL and web apps

  2. In the same way as colors this works for exporting to Excel

  TMSFNCDataGrid1.Layouts[2,3].TextAlign := gtaCenter;
  TMSFNCDataGrid1.Layouts[3,4].TextAlign := gtaTrailing;

  TMSFNCDataGrid1.Layouts[1,1].Font.Style := [TFontStyle.fsBold];
  TMSFNCDataGrid1.Layouts[1,2].Font.Style := [TFontStyle.fsItalic];

Note that you have to set ExportCellProperties := True; under Options.

Ok, Thanks.

Point 4 was not understood. The bug is not the export itself but the DataGrid, which after the export is done, the formating set at the design time (via Column.Appearance) are reset (initially column 3 is red and 4 is blue, both centered. After exporting, in the grid those columns turn black and lose the center alignment of the text.

Regars,
Angel

Can you put together a sample?

Yes of course.

I compilling in RAD Studio 12 Version 29.0.53982.032
Regards,

Processing: FormattingLost.zip…

Seems we are unable to download, can you try editing and re-upload or post a link to the download?

I upload it again

FormattingLost.zip (12.7 KB)

Thanks for the sample, issue has been detected and fixed!

Thank you very much