BlogAll Blog Posts | Next Post | Previous Post
Tuesday, March 2, 2021
In the last weeks, we've been working on a component to allow you to import and export FNC Grids to the xlsx file format. We've also used the opportunity to rename the existing "Grid Filters" and "FMX Grid Filters" to "VCL Grid Excel Bridge" and "FNC Grid Excel Bridge" because the word "Filter" has a different meaning in a grid. We hope the new "Bridge" naming proves less ambiguous.
- VCL: https://www.tmssoftware.com/site/vclgridexcelbridge.asp
- FMX: https://www.tmssoftware.com/site/fmxgridexcelbridge.asp
- FNC: https://www.tmssoftware.com/site/fncgridexcelbridge.asp
And the documentation is available here:
- VCL: https://doc.tmssoftware.com/grid-excel-bridge/vcl/guides/user-guide.html
- FMX: https://doc.tmssoftware.com/grid-excel-bridge/fmx/guides/user-guide.html
- FNC: https://doc.tmssoftware.com/grid-excel-bridge/fnc/guides/user-guide.html
So what is the state now if you want to export or import a grid to/from Excel? We have the following choices:
- (VCL Only) You can use StringGrid.SaveToXLS and StringGrid.LoadFromXLS. Those methods will use OLE Automation under the hood, and so they require that Excel is installed in the machine. Because they need Excel, they can only work on Windows.
- You can use TAdvGridExcelIO (VCL), TTMSFMXGridExcelIO (FMX) and TTMSFNCGridExcelIO (FNC). Those components use an older trimmed-down FlexCel 3 to do their job. Because they use FlexCel 3, which predates the XLSX file format, they can only work with XLS files, not XLSX.
- You can use the "TMS Grid Excel Bridge" components. Those components use an existing FlexCel 7 to do the work, and so they can export to xls and xlsx, but also HTML and PDF. Because they require a FlexCel license, they can access the full FlexCel behind it, to do extra customization. Just as an an example: You could add conditional formats to the generated files, as shown in the example here: https://doc.tmssoftware.com/grid-excel-bridge/fnc/guides/user-guide.html#customizing-the-export.
Up to now, the "Bridges" had support for VCL Grids and FMX Grids. With the release of FNC Bridge, we are extending the first-class Excel exporting and importing to FNC.
Note that in FNC, we only support VCL and FMX at the moment (all platforms). We can't support Lazarus or WebCore because FlexCel doesn't support them yet.
So to finish this small post, I'd like to show how it works. We'll try adding export support for the FNC Grid in the "ClientDataset" demo. This is the grid:
We dropped a TTMSFNCGridExcelExportComponent, and wrote the code:
And we got this result:
The checkboxes work in Excel, they are not images. But they will be exported as images to HTML and PDF.
Next, we tried with HTML:
And we got:
Finally we went for the PDF export. We could also have tried the one-liner, but in this case it would end up with 2 pages. The grid is too wide and the right part of it goes to the second page. But here is where the power of having full access to the FlexCel engine can help. We could export this file to xlsx, then set the print options in the xlsx file to fit to one page, and only then export to PDF:
var xls := TXlsFile.Create(1, true); try TMSFNCGridExcelExport1.Export(xls); var Pdf := TFlexCelPdfExport.Create(xls, true); try xls.PrintToFit := true; xls.PrintNumberOfHorizontalPages := 1; xls.PageHeader := '&L FNC Grid Excel Export Demo&RPage &P of &N'; Pdf.ExportAllVisibleSheets('r:\test.pdf', false, ''); finally Pdf.Free; end; finally FreeAndNil(xls); end;
Here is the PDF we got:
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post