User Guides | TMS FMX Grid Excel bridge documentation

User Guides

In this section:

Install Guide

How to install TMS FMX Grid Excel bridge.

User Guide

How to use TMS FMX Grid Excel bridge.

In This Article
Back to top TMS FMX Grid Excel bridge v3.1.0
© 2002 - 2021 tmssoftware.com


TMS FMX Grid Excel bridge Install Guide | TMS FMX Grid Excel bridge documentation

TMS FMX Grid Excel bridge Install Guide

To install TMS FMX Grid Excel bridge,you need to install first [TMS FMX UI Pack]https://www.tmssoftware.com/site/tmsfmxpack.asp) and TMS FlexCel.

Important

Whenever you reinstall or update either FlexCel or FNC UI Pack, you need to reinstall the bridges, even if the bridges themselves didn't change.

Once you have both dependencies installed, you can now go through the setup and install the bridges.

In This Article


TMS FMX Grid Excel bridge User Guide | TMS FMX Grid Excel bridge documentation

TMS FMX Grid Excel bridge User Guide

Introduction

TMS FMX Grid Excel bridge is a distribution with two components: TTMSFMXGridExcelExport and TTMSFMXGridExcelImport.

You can use TTMSFMXGridExcelImport to import an xls or xlsx file to a TMS grid, and you can use TTMSFMXGridExcelExport to export a TMS grid to xls, xlsx, HTML, or PDF. The components use FlexCel Studio to read and write the Excel files, and don't require Excel to be installed in the machine.

Exporting a grid to Excel

Getting started

Exporting a grid is simple. First, make sure to drop a TTMSFMXGridExcelExport component in the form that has the grid you wish to export:

grid export component

After that, associate the Grid to the TTMSFMXGridExcelExport in the object inspector:

grid export options

Finally, drop a button and write the following code:

  TMSFMXGridExcelExport1.Export('test.xlsx');

If everything went right, you should have created an xlsx file from the grid.

Customizing the export

The single-line export methods are the easiest to use. Just write a line of code, check the export option properties in the TTMSFMXGridExcelExport component, and you are ready to go.

But sometimes you need more control over the generated files. Let's imagine for example that you wanted to export the grid into an existing xlsx file that is already customized with your branding. Or that you want to change things not available on the grid, like for example add some conditional formats. For those cases, you can export the grid directly into a FlexCel's TExcelFile object, using code like this:

uses ..., FlexCel.Core, FlexCel.XlsAdapter;
...
procedure TExampleForm.ExportGridToXlsFileObject;
var
  xls: TExcelFile;
  Ranges: TArray<TXlsCellRange>;
  Rules: TArray<IConditionalFormatRule>;
  CellIsRule: IConditionalCellIsRule;
  CFDef: TConditionalFormatDefStandard;
begin
  //Open a template with existing branding. We could also create a new file.
  xls := TXlsFile.Create('..\..\MyTemplate.xlsx', true);
  try
    //Export into the 3rd row of the existing template.
    TMSFMXGridExcelExport1.LocationOptions.XlsStartRow := 3;

    //Export the grid to the xls object.
    //We will export insert the rows into an existing template
    TMSFMXGridExcelExport1.Export(xls, TInsertInSheet.InsertRows);

    //Now you can do extra stuff with the xls file.
    //Adding rows, setting options, adding sheets
    //And exporting other grids. The code below
    //was generated with APIMate, and adds a conditional format
    //for column F that will paint the cell red if it is bigger than 3.

    Ranges := TArray<TXlsCellRange>.Create(
      TXlsCellRange.Create(1, 6, 1048576, 6)
    );

    Rules := nil;  //SetLength will resize the array in place. We set it to nil first to create a new array.
    SetLength(Rules, 1);
    CellIsRule := TConditionalCellIsRule_Create(1, false, TConditionType.GreaterThan, '=3', '');
    CFDef := CellIsRule.FormatDef;
    CFDef.ApplyFont.Color := true;
    CFDef.Font.Color := TExcelColor.FromArgb($9C, $00, $06);
    CFDef.ApplyFill.BgColor := true;
    CFDef.Fill.BgColor := TExcelColor.FromArgb($FF, $C7, $CE);
    Rules[0] := CellIsRule;

    xls.AddConditionalFormat(TConditionalFormat.Create(Ranges, Rules, false));

    // Finally save the xls object to a real file.
    xls.Save('MyFile.xlsx');

  finally
    xls.Free;
  end;
end;

Once you have a TExcelFile object with the grid, you can use the full FlexCel functionality to modify that object as you want.

Note

Always remember that you can use APIMate (a tool that is installed with FlexCel) to figure out exactly how to write the code to customize the TExcelFile object. To create the code above that sets the conditional formats, we just created the conditional format in Excel, then opened the file in APIMate and copied the code.

Exporting a grid to PDF or HTML

You can also export to PDF or HTML, using the methods TTMSFMXGridExcelExport.ExportPdf and TTMSFMXGridExcelExport.ExportHtml

Those methods will export to xlsx under the hood and then export the generated xlsx file to PDF or HTML. Same as when exporting to Excel, you can choose between exporting with one line, or using the corresponding FlexCel objects to allow further customization. The linked documentation in the methods contains code examples on how to use them.

Importing an Excel file

Importing an Excel file isn't conceptually different from exporting it. In this case, you drop a TTMSFMXGridExcelImport component instead of TTMSFMXGridExcelExport, and then call TTMSFMXGridExcelImport.Import.

As was the case with exporting, you have two options to import a file. You can use a one-liner:

  TMSFMXGridExcelImport1.Import('test.xlsx', 'my sheet');

Or you can import an existing TExcelFile object:

uses ..., FlexCel.Core, FlexCel.XlsAdapter;
...
procedure TExampleForm.XlsxObjectImport;
var
  xls: TExcelFile;
begin
  //We will start by opening the file we want to import
  xls := TXlsFile.Create('..\..\MyTemplate.xlsx', true);
  try
    //You can manipulate the xls file before importing it.

    //Select the sheet we want to import.
    xls.ActiveSheetByName := 'My Sheet';

    //Convert the formulas to values, so there aren't formulas in the
    //imported file. Also recalculate the sheet before converting
    //(recalculation is only needed if the original file wasn't calculated)
    xls.ConvertFormulasToValues(false, true);

    TMSFMXGridExcelImport1.Import(xls);
  finally
    xls.Free;
  end;
end;

Differences between a TMS Grid and Excel

Missing features

In an ideal world, you could import an xlsx file into the grid, then export the grid back to a separate xlsx file, and both files would be identical. But as you can guess, this is not the case, except maybe for very simple files. Imagine, for example, that the file we are importing has a macro. Once the file is imported into the grid, the macro will be gone. And when we export the file back to xlsx, the new file won't have the macro.

When we import the file into the grid, we will lose any features in the file that don't have a corresponding grid feature. If the file has a chart, the grid won't have it. It is the same for pivot tables, conditional formats, and another thousand things available in Excel but not in the grid. And when we export the grid into a file, we have the reverse problem. Say you have a fixed row in the middle of the grid. You can't have fixed rows in the middle when in Excel, so we can't export that feature.

Note

If you want to read a file, modify it and save it back, and you don't need to display it, you will be much better off using FlexCel alone. FlexCel won't do an xlsx->grid->xlsx conversion, and most of the stuff in the original file will be in the modified file. Only use TTMSFMXGridExcelImport and TTMSFMXGridExcelExport if you need to show the grid to the final user.

Features that behave differently

Sometimes, both the grid and Excel have a feature, but they aren't exactly compatible. In those cases, the bridge components will try to make their best effort to translate the feature from the grid to Excel or vice-versa, but sometimes it might need additional help. Here we will discuss some of those.

Images

Both Excel and the grid support images, but they behave differently. In Excel, images float over the cells. In the grid, images are inside a cell and can't span to a different cell.

So if you have to import this image from Excel:

we would end up with the following:

grid images not merged

To try avoiding this problem, TTMSFMXGridExcelImport will merge the cells beneath the image:

grid images merged

But of course, this is not a 1-to-1 translation. If there were data in any of the cells we had to merge; those cells would be lost. And when you save the file back to xlsx, it will have merged cells behind the image, even if the original file didn't.

Cell Formats

By default, TTMSFMXGrid uses Delphi format strings to format numbers. For example, if you have the number 10 and use the format "%.2f", it will display as "10.00". But in Excel, to show the number 10 as "10.00", you need to use the format string "0.00".

TTMSFMXGridExcelExport doesn't know how to convert "Delphi format strings" to "Excel format strings", or vice-versa. You can use two ways to get your exported data formatted as it is on the grid.

  1. You can use the event TTMSFMXGridExcelExport.OnExportCell and manually specify the "Excel format" used for every cell. If the cell is formatted as "%.2f", you can say, in the event, that the Excel format used should be "0.00".

  2. Currently only for TMS AdvStringGrid: You can set the property AdvStringGrid.FormatType := vtExcel; and use Excel formatting in the grid. Instead of specifying "%.2f" in the grid, you set the format to "0.00". TTMSFMXGridExcelExport will realize that you are using vtExcel, and pass that format to Excel when saving the file.

  3. Finally, and as a last resort, you could export everything as strings. To do so you would use the property TExportOptions.CellsAsStrings

Exporting as strings is the simplest way to get the exact formatting as the grid, but it comes with significant caveats.

  • First, the Excel cells won't have actual numbers. If in cell A1 you write the string "30", and in cell A2 you write "=Sum(A1)" the result will be 0, not 30.
  • Second, you might run into localization issues. If you write the string "3,000", this might mean 3 or 3000 depending on the decimal separator used in the country. While if you stored the number 3000 in the cell, it will always be 3000 and will display with "," or "." depending on the machine locale.
  • Finally, Excel will warn with a green triangle that the number is stored as text: number stored as text

Cell Margins

TTMSFMXGrid has margins around the cells, while Excel has not. So if a cell is 20 pixels in Excel, to fit the text in the grid, we might need 26 pixels. But now the column is 26 pixels wide, instead of the original 20. If you keep repeating import/export cycles, the column width will grow indefinitely. You can control the cell margin behavior with the property TExportOptions.CellMargins

Hyperlinks

In Excel, hyperlinks apply to the whole cell. In the grid, hyperlinks apply to the text. This means that you can't have more than one link per cell in Excel, while you can have multiple links inside a single cell in the grid. If a cell contains more than one link, only the first will be exported to Excel.


API Documentation | TMS FMX Grid Excel bridge documentation

API Documentation

In this section you can find a list of all the classes, methods and properties available in TMS FMX Grid Excel bridge.

In this section:

FMX.TMSGridExcelBridgeCore

FMX.TMSGridExcelExport

FMX.TMSGridExcelImport


FMX.TMSGridExcelBridgeCore Namespace | TMS FMX Grid Excel bridge documentation

FMX.TMSGridExcelBridgeCore Namespace

Classes

Name | Description
TLocationOptions | Defines which rows and columns to export from the grid and into which rows and columns in Excel.

Records

Name | Description
TExportProgress​Event​Args | Arguments passed in the ExportProgress event.

Constants

Name | Description
CellOfs | Offset for the cells. Internal use.
TMSFMXGridExcel​Bridge​Version | You can use this constant to know what FMXGridExcelBridge version you are running. For example ShowMessage(TMSFMXGridExcelBridgeVersion);
ErrNoAdvStrGrid | No Grid is attached to the component.


TLocationOptions Class | TMS FMX Grid Excel bridge documentation

TLocationOptions Class

Defines which rows and columns to export from the grid and into which rows and columns in Excel.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

TLocationOptions = class(TPersistent);

Constructors

Name | Description
Create | Creates a new TLocationOptions object.

Methods

Name | Description
Assign | Copies source into this object.

Properties

Name | Description
GridStartRow | The first row of the grid to export. Note that this is 0-based, but the first row is normally the headers of the grid. As you normally want to export just the data and not the headers, the default value is 1.
GridStartCol | The first column of the grid to export. Note that this is 0-based, but the first column is normally the headers of the grid. As you normally want to export just the data and not the headers, the default value is 1.
XlsStartRow | Row in Excel where the first row of the grid will go. This is 1-based, so 1 means the first row in Excel.
XlsStartCol | Column in Excel where the first column of the grid will go. This is 1-based, so 1 means column "A" in Excel.


TLocationOptions.Create Constructor | TMS FMX Grid Excel bridge documentation

TLocationOptions.Create Constructor

Creates a new TLocationOptions object.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

constructor TLocationOptions.Create;

See also

  • TLocationOptions


TLocationOptions.Assign Method | TMS FMX Grid Excel bridge documentation

TLocationOptions.Assign Method

Copies source into this object.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

procedure TLocationOptions.Assign(Source: TPersistent); override;

Parameters

<-> | Parameter | Type | Description
 | Source | TPersistent |

See also

  • TLocationOptions


TLocationOptions.GridStartRow Property | TMS FMX Grid Excel bridge documentation

TLocationOptions.GridStartRow Property

The first row of the grid to export. Note that this is 0-based, but the first row is normally the headers of the grid. As you normally want to export just the data and not the headers, the default value is 1.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TLocationOptions.GridStartRow: Integer

See also

  • TLocationOptions


TLocationOptions.GridStartCol Property | TMS FMX Grid Excel bridge documentation

TLocationOptions.GridStartCol Property

The first column of the grid to export. Note that this is 0-based, but the first column is normally the headers of the grid. As you normally want to export just the data and not the headers, the default value is 1.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TLocationOptions.GridStartCol: Integer

See also

  • TLocationOptions


TLocationOptions.XlsStartRow Property | TMS FMX Grid Excel bridge documentation

TLocationOptions.XlsStartRow Property

Row in Excel where the first row of the grid will go. This is 1-based, so 1 means the first row in Excel.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TLocationOptions.XlsStartRow: Integer

See also

  • TLocationOptions


TLocationOptions.XlsStartCol Property | TMS FMX Grid Excel bridge documentation

TLocationOptions.XlsStartCol Property

Column in Excel where the first column of the grid will go. This is 1-based, so 1 means column "A" in Excel.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TLocationOptions.XlsStartCol: Integer

See also

  • TLocationOptions


TExportProgressEventArgs Record | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs Record

Arguments passed in the ExportProgress event.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

TExportProgressEventArgs = record;

Constructors

Name | Description
Create | Initializes the record.

Properties

Name | Description
SheetNum | Number of the sheet we are exporting/​importing. This only applies when exporting TAdvWorkbook objects.
SheetTot | Total number of sheets to export/import. This only applies to TAdvWorkbook objects.
RowNum | Number of the row that is being exported/​imported.​
RowTot | Total numbers of rows to export/import.


TExportProgressEventArgs.Create Constructor | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs.Create Constructor

Initializes the record.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

constructor TExportProgressEventArgs.Create(const aSheetNum: Integer; const aSheetTot: Integer; const aRowNum: Integer; const aRowTot: Integer);

Parameters

<-> | Parameter | Type | Description
const | aSheetNum | Integer |
const | aSheetTot | Integer |
const | aRowNum | Integer |
const | aRowTot | Integer |

See also

  • TExportProgressEventArgs


TExportProgressEventArgs.SheetNum Property | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs.SheetNum Property

Number of the sheet we are exporting/importing. This only applies when exporting TAdvWorkbook objects.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TExportProgressEventArgs.SheetNum: Integer

See also

  • TExportProgressEventArgs


TExportProgressEventArgs.SheetTot Property | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs.SheetTot Property

Total number of sheets to export/import. This only applies to TAdvWorkbook objects.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TExportProgressEventArgs.SheetTot: Integer

See also

  • TExportProgressEventArgs


TExportProgressEventArgs.RowNum Property | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs.RowNum Property

Number of the row that is being exported/imported.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TExportProgressEventArgs.RowNum: Integer

See also

  • TExportProgressEventArgs


TExportProgressEventArgs.RowTot Property | TMS FMX Grid Excel bridge documentation

TExportProgressEventArgs.RowTot Property

Total numbers of rows to export/import.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

property TExportProgressEventArgs.RowTot: Integer

See also

  • TExportProgressEventArgs


CellOfs Constant | TMS FMX Grid Excel bridge documentation

CellOfs Constant

Offset for the cells. Internal use.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

const CellOfs = $0;


TMSFMXGridExcelBridgeVersion Constant | TMS FMX Grid Excel bridge documentation

TMSFMXGridExcelBridgeVersion Constant

You can use this constant to know what FMXGridExcelBridge version you are running. For example ShowMessage(TMSFMXGridExcelBridgeVersion);

Syntax

Unit: FMX.TMSGridExcelBridgeCore

const TMSFMXGridExcelBridgeVersion = '3.0';


ErrNoAdvStrGrid Constant | TMS FMX Grid Excel bridge documentation

ErrNoAdvStrGrid Constant

No Grid is attached to the component.

Syntax

Unit: FMX.TMSGridExcelBridgeCore

const ErrNoAdvStrGrid = 'There is no Grid attached.';


FMX.TMSGridExcelExport Namespace | TMS FMX Grid Excel bridge documentation

FMX.TMSGridExcelExport Namespace

Classes

Name | Description
TExportOptions | Options that affect how the grid is exported.
TTMSFMXGridExcel​Export | This component will export an exiisting TMSFMXGrid to Excel.

Enumerations

Name | Description
TExportDataType | Defines how a cell will be exported to Excel.
THtmlExportMode | Defines how the grid will be exported to html.
TInsertInSheet | How the cells will be inserted when exporting to an existing file.


TExportOptions Class | TMS FMX Grid Excel bridge documentation

TExportOptions Class

Options that affect how the grid is exported.

Syntax

Unit: FMX.TMSGridExcelExport

TExportOptions = class(TPersistent);

Constructors

Name | Description
Create | Creates a new instance.

Methods

Name | Description
Assign | Assigns the contents of Source to this object.

Properties

Name | Description
CellSizes | If true, row heights and column widths will be exported to Excel. If false, columns and rows in Excel will have their default size.
Formulas | If true, the formulas in the grid will be exported as formulas in Excel. If false, the result of the formula will be exported as a value in Excel.
CellsAsStrings | When false (the default) cells will be exported as numbers, booleans, etc, to Excel, and you need to format them to look the same. When true, all cells in the grid will be exported as strings. This way, they will look exactly the same, but you will have a string "1" instead of a number 1 in the Excel cell. You can't use those strings in formulas.
CellFormatting | When true, the cell format(background color, alignment, etc) will be exported to Excel. When false, the existing format in the Excel cells will be used.
WordWrapped | When true (the default) word-wrapped cells in the grid will be exported as word-wrapped cells in Excel. When false, cells in Excel won't be word-wrapped.
RawHTML | When false (the default), we will try to convert the html in the grid to similar formatitng in Excel. When true, html text in cells will be sent "as is" to Excel.
Images | If true (the default)the images in the grid will be exported to Excel. If false, no images will be exported.
Comments | If true, comments in the grid will be exported to Excel.
Checkboxes | If true (the default) checkboxes in the grid will be exported to checkboxes in Excel.
HiddenColumns | IF true, hidden columns in the grid will be exported as hidden columns in Excel. If false, hidden columns won't be exported.
HiddenRows | IF true, hidden rows in the grid will be exported as hidden rows in Excel. If false, hidden rows won't be exported.
HardBorders | In Excel, a group of cells formatted in a solid background color won't show gridlines. If you set this property to true, we will add borders around those cells so they look like the grid. If false, gridlines will be the ones Excel shows, and won't show in solid color regions.
ShowGridLines | If true, the exported Excel file willdisplay gridlines. If false, the exported Excel file will have a white background. If setting it to false, you might want to set HardBorders = true.
CellMargins | StringGrid by default has margins around the columns and rows. This means that for example a 20 pixel wide column might have 16 pixels of effective width. When this property is false, that column will be exported as 16 pixels to Excel. When true, the column width will be 20 pixels in Excel.<para/> IMPORTANT NOTE: YOU CAN SET THIS PROPERTY TO TRUE ONLY IF YOU ARE NOT REIMPORTING THE FILE. If you have an import/export cycle and this property is true, the column widths will grow ad infinitum. For example, imagine you export the column width at 20px. When importing, the column in StringGrid will be 24 pixels, to fit all the text inside Excel. When you export this file again, it will be 24px, and when imported 28 and so on. <para/> In short, this property allows for a nicer export, but can only be used if you are not importing.
ReadonlyCells​AsLocked | If true, readonly cells in the grid will be exported as Locked cells in Excel, and normal cells will be unlocked (so if you protect the sheet, those cells will not be editable in Excel). If false, all cells(readonly or not) will be exported as locked, the Excel default.
PrintOptions | If true (the default), many print options in the grid like print orientation will be set also in the generated Excel file. If false, those options won't be exported.
Outlines | If true (the default) nodes in the grid will be exported to outlines in Excel. You can control how the "+" symbols will appear with SummaryRowsBelow​Detail
SummaryRowsBelow​Detail | If true, when exporting outlines to Excel the "+" symbols will be at the last row (or column) of the range. This is the Excel default, but it is not the way outlines show in StringGrid. If false the "+" signs will appear at the start of the groups.
UseExcelStandard​Color​Palette | When true, the standard Excel color palette will be used while exporting. Excel 97/2003 have only 53 available colors, and any color that does not match must be replaced with the nearest one. If this property is false, the Excel color palette will be changed to better display the real grid colors. Note that when you want to edit the generated file, having a custom palette might make it difficult to find the color you need.


TExportOptions.Create Constructor | TMS FMX Grid Excel bridge documentation

TExportOptions.Create Constructor

Creates a new instance.

Syntax

Unit: FMX.TMSGridExcelExport

constructor TExportOptions.Create;

See also

  • TExportOptions


TExportOptions.Assign Method | TMS FMX Grid Excel bridge documentation

TExportOptions.Assign Method

Assigns the contents of Source to this object.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TExportOptions.Assign(Source: TPersistent); override;

Parameters

<-> | Parameter | Type | Description
 | Source | TPersistent |

See also

  • TExportOptions


TExportOptions.CellSizes Property | TMS FMX Grid Excel bridge documentation

TExportOptions.CellSizes Property

If true, row heights and column widths will be exported to Excel. If false, columns and rows in Excel will have their default size.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.CellSizes: Boolean

See also

  • TExportOptions


TExportOptions.Formulas Property | TMS FMX Grid Excel bridge documentation

TExportOptions.Formulas Property

If true, the formulas in the grid will be exported as formulas in Excel. If false, the result of the formula will be exported as a value in Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.Formulas: Boolean

See also

  • TExportOptions


TExportOptions.CellsAsStrings Property | TMS FMX Grid Excel bridge documentation

TExportOptions.CellsAsStrings Property

When false (the default) cells will be exported as numbers, booleans, etc, to Excel, and you need to format them to look the same. When true, all cells in the grid will be exported as strings. This way, they will look exactly the same, but you will have a string "1" instead of a number 1 in the Excel cell. You can't use those strings in formulas.

Remarks

This property controls how to export cells in a global scope. To control cell by cell how they are exported, use the TTMSFMXGridExcelExport.OnExportCell event.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.CellsAsStrings: Boolean

See also

  • TExportOptions


TExportOptions.CellFormatting Property | TMS FMX Grid Excel bridge documentation

TExportOptions.CellFormatting Property

When true, the cell format(background color, alignment, etc) will be exported to Excel. When false, the existing format in the Excel cells will be used.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.CellFormatting: Boolean

See also

  • TExportOptions


TExportOptions.WordWrapped Property | TMS FMX Grid Excel bridge documentation

TExportOptions.WordWrapped Property

When true (the default) word-wrapped cells in the grid will be exported as word-wrapped cells in Excel. When false, cells in Excel won't be word-wrapped.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.WordWrapped: Boolean

See also

  • TExportOptions


TExportOptions.RawHTML Property | TMS FMX Grid Excel bridge documentation

TExportOptions.RawHTML Property

When false (the default), we will try to convert the html in the grid to similar formatitng in Excel. When true, html text in cells will be sent "as is" to Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.RawHTML: Boolean

See also

  • TExportOptions


TExportOptions.Images Property | TMS FMX Grid Excel bridge documentation

TExportOptions.Images Property

If true (the default)the images in the grid will be exported to Excel. If false, no images will be exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.Images: Boolean

See also

  • TExportOptions


TExportOptions.Comments Property | TMS FMX Grid Excel bridge documentation

TExportOptions.Comments Property

If true, comments in the grid will be exported to Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.Comments: Boolean

See also

  • TExportOptions


TExportOptions.Checkboxes Property | TMS FMX Grid Excel bridge documentation

TExportOptions.Checkboxes Property

If true (the default) checkboxes in the grid will be exported to checkboxes in Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.Checkboxes: Boolean

See also

  • TExportOptions


TExportOptions.HiddenColumns Property | TMS FMX Grid Excel bridge documentation

TExportOptions.HiddenColumns Property

IF true, hidden columns in the grid will be exported as hidden columns in Excel. If false, hidden columns won't be exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.HiddenColumns: Boolean

See also

  • TExportOptions


TExportOptions.HiddenRows Property | TMS FMX Grid Excel bridge documentation

TExportOptions.HiddenRows Property

IF true, hidden rows in the grid will be exported as hidden rows in Excel. If false, hidden rows won't be exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.HiddenRows: Boolean

See also

  • TExportOptions


TExportOptions.HardBorders Property | TMS FMX Grid Excel bridge documentation

TExportOptions.HardBorders Property

In Excel, a group of cells formatted in a solid background color won't show gridlines. If you set this property to true, we will add borders around those cells so they look like the grid. If false, gridlines will be the ones Excel shows, and won't show in solid color regions.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.HardBorders: Boolean

See also

  • TExportOptions


TExportOptions.ShowGridLines Property | TMS FMX Grid Excel bridge documentation

TExportOptions.ShowGridLines Property

If true, the exported Excel file willdisplay gridlines. If false, the exported Excel file will have a white background. If setting it to false, you might want to set HardBorders = true.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.ShowGridLines: Boolean

See also

  • TExportOptions


TExportOptions.CellMargins Property | TMS FMX Grid Excel bridge documentation

TExportOptions.CellMargins Property

StringGrid by default has margins around the columns and rows. This means that for example a 20 pixel wide column might have 16 pixels of effective width. When this property is false, that column will be exported as 16 pixels to Excel. When true, the column width will be 20 pixels in Excel.<para/> IMPORTANT NOTE: YOU CAN SET THIS PROPERTY TO TRUE ONLY IF YOU ARE NOT REIMPORTING THE FILE. If you have an import/export cycle and this property is true, the column widths will grow ad infinitum. For example, imagine you export the column width at 20px. When importing, the column in StringGrid will be 24 pixels, to fit all the text inside Excel. When you export this file again, it will be 24px, and when imported 28 and so on. <para/> In short, this property allows for a nicer export, but can only be used if you are not importing.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.CellMargins: Boolean

See also

  • TExportOptions


TExportOptions.ReadonlyCellsAsLocked Property | TMS FMX Grid Excel bridge documentation

TExportOptions.ReadonlyCellsAsLocked Property

If true, readonly cells in the grid will be exported as Locked cells in Excel, and normal cells will be unlocked (so if you protect the sheet, those cells will not be editable in Excel). If false, all cells(readonly or not) will be exported as locked, the Excel default.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.ReadonlyCellsAsLocked: Boolean

See also

  • TExportOptions


TExportOptions.PrintOptions Property | TMS FMX Grid Excel bridge documentation

TExportOptions.PrintOptions Property

If true (the default), many print options in the grid like print orientation will be set also in the generated Excel file. If false, those options won't be exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.PrintOptions: Boolean

See also

  • TExportOptions


TExportOptions.Outlines Property | TMS FMX Grid Excel bridge documentation

TExportOptions.Outlines Property

If true (the default) nodes in the grid will be exported to outlines in Excel. You can control how the "+" symbols will appear with SummaryRowsBelowDetail

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.Outlines: Boolean

See also

  • TExportOptions


TExportOptions.SummaryRowsBelowDetail Property | TMS FMX Grid Excel bridge documentation

TExportOptions.SummaryRowsBelowDetail Property

If true, when exporting outlines to Excel the "+" symbols will be at the last row (or column) of the range. This is the Excel default, but it is not the way outlines show in StringGrid. If false the "+" signs will appear at the start of the groups.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.SummaryRowsBelowDetail: Boolean

See also

  • TExportOptions


TExportOptions.UseExcelStandardColorPalette Property | TMS FMX Grid Excel bridge documentation

TExportOptions.UseExcelStandardColorPalette Property

When true, the standard Excel color palette will be used while exporting. Excel 97/2003 have only 53 available colors, and any color that does not match must be replaced with the nearest one. If this property is false, the Excel color palette will be changed to better display the real grid colors. Note that when you want to edit the generated file, having a custom palette might make it difficult to find the color you need.

Remarks

Excel 2007 and newer support true color, so this property won't change how the generated files will display in Excel 2007. They will look fine no matter which option you choose.

Syntax

Unit: FMX.TMSGridExcelExport

property TExportOptions.UseExcelStandardColorPalette: Boolean

See also

  • TExportOptions


TTMSFMXGridExcelExport Class | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport Class

This component will export an exiisting TMSFMXGrid to Excel.

Syntax

Unit: FMX.TMSGridExcelExport

TTMSFMXGridExcelExport = class(TComponent);

Constructors

Name | Description
Create | Creates the component.

Destructors

Name | Description
Destroy | Frees all memory assigned to this component and releases the resources.

Methods

Name Description
Export Overloaded
 Export(TFileName, string)
Export(TExcelFile, TInsertInSheet)
Export(TStream, TFileFormats, string)
ExportPdf Overloaded
 ExportPdf(TFileName)
ExportPdf(TStream)
ExportPdf(TStream, TFlexCelPdfExport)
ExportHtml Overloaded
 ExportHtml(TFileName, THtmlExportMode)
ExportHtml(TFlexCelHtmlExport, string, THtmlExportMode)

Properties

Name | Description
Grid | The grid to export.
ExportOptions | Settings that affect how the grid will be exported.
LocationOptions | Settings that define where the grid will be exported in Excel.
DateFormat | Default Excel format for the cells that contain dates. This is a global setting, you can control the format in individual cells with OnExportCell
TimeFormat | Default Excel format for the cells that contain times. This is a global setting, you can control the format in individual cells with OnExportCell
ImageMargin | Adds a margin around the cell for images or checkboxes. If you set this to 0 images will go exactly to the edges of the cell.
Version | The version of this component.

Events

Name | Description
OnExportCell | Occurs before exporting every cell, and allows you to customize what is written in it.
OnProgress | Provides a progress indication of how many cells have been exported.
OnExportComment | Occurs before exporting a comment, and allows you to customize the size of the popup note that will appear in Excel.


TTMSFMXGridExcelExport.Create Constructor | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.Create Constructor

Creates the component.

Syntax

Unit: FMX.TMSGridExcelExport

constructor TTMSFMXGridExcelExport.Create(AOwner: TComponent);

Parameters

<-> | Parameter | Type | Description
 | AOwner | TComponent |

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.Destroy Destructor | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.Destroy Destructor

Frees all memory assigned to this component and releases the resources.

Syntax

Unit: FMX.TMSGridExcelExport

destructor TTMSFMXGridExcelExport.Destroy;

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.Export Method | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.Export Method

Overloads

  • TTMSFMXGridExcelExport.Export(TFileName, string)
  • TTMSFMXGridExcelExport.Export(TExcelFile, TInsertInSheet)
  • TTMSFMXGridExcelExport.Export(TStream, TFileFormats, string)

TTMSFMXGridExcelExport.Export(TFileName, string)

Exports the attached grid to Excel.

Remarks

For more flexibility in how to generate the file use Export(TExcelFile, TInsertInSheet) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.Export(const FileName: TFileName; const SheetName: string); overload;

Parameters

<-> | Parameter | Type | Description
const | FileName | TFileName | Filename of the generated file. If the extension is "xls" then the file will be saved as Excel 2003, if it is xlsx/xlsm it will be saved as Excel 2007.
const | SheetName | string | Defines the sheet name for the exported file. If empty, a normal "Sheet1" will be used.

See also

  • TTMSFMXGridExcelExport

TTMSFMXGridExcelExport.Export(TExcelFile, TInsertInSheet)

Exports the grid into an existing TExcelFile object. You can use this method to add the grid to existing files. Once the file is exported, you can use TExcelFile.Save(string) to save the file.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.Export(const Xls: TExcelFile; const InsertInSheet: TInsertInSheet = TInsertInSheet.Clear); overload;

Parameters

<-> | Parameter | Type | Description
const | Xls | TExcelFile | TExcelFile containing the Excel file where the grid will be exported.
const | InsertInSheet | TInsertInSheet | Optional: Default value is TInsertInSheet.Clear How the grid will be inserted in the existing file.

Examples

To export the grid to an existing file, you can use the code:

uses ..., FlexCel.Core, FlexCel.XlsAdapter;
...
procedure TExampleForm.ExportGrid;
var
  xls: TExcelFile;
begin
  //Let's create an empty file. We could also open a template
  xls := TXlsFile.Create(1, TExcelFileFormat.v2019, true);
  try
    //Export the grid to the xls object.
    TMSFMXGridExcelExport1.Export(xls);

    //Now you can do extra stuff with the xls file.
    //Adding rows, setting options, adding sheets
    //And exporting other grids.

    xls.PageHeader := '&CThis is a header';

    // Finally save the xls object to a real file.
    xls.Save('MyFile.xlsx');

  finally
    xls.Free;
  end;
end;

See also

  • TTMSFMXGridExcelExport

TTMSFMXGridExcelExport.Export(TStream, TFileFormats, string)

Exports the attached grid to Excel.

Remarks

For more flexibility in how to generate the file use Export(TExcelFile, TInsertInSheet) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.Export(const aStream: TStream; const SaveFormat: TFileFormats; const SheetName: string); overload;

Parameters

<-> | Parameter | Type | Description
const | aStream | TStream | Stream where the selected file will be saved.
const | SaveFormat | TFileFormats | Format in which to save the file. As we are saving to a stream and there is no filename we can't figure out whether to save as xls or xlsx, and you need to specify it here.
const | SheetName | string | Defines the sheet name for the exported file. If empty, a normal "Sheet1" will be used.

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.ExportPdf Method | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.ExportPdf Method

Overloads

  • TTMSFMXGridExcelExport.ExportPdf(TFileName)
  • TTMSFMXGridExcelExport.ExportPdf(TStream)
  • TTMSFMXGridExcelExport.ExportPdf(TStream, TFlexCelPdfExport)

TTMSFMXGridExcelExport.ExportPdf(TFileName)

Exports the attached grid to Pdf.

Remarks

This method will export to pdf with the standard xls file defaults. If you want to customize the export more (for example provide an Author for the pdf file) you can use ExportPdf(TStream, TFlexCelPdfExport) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.ExportPdf(const aFileName: TFileName); overload;

Parameters

<-> | Parameter | Type | Description
const | aFileName | TFileName | Filename of the generated file.

See also

  • TTMSFMXGridExcelExport

TTMSFMXGridExcelExport.ExportPdf(TStream)

Exports the attached grid to Pdf.

Remarks

This method will export to pdf with the standard defaults. If you want to customize the export more (for example provide an Author for the pdf file) you can use ExportPdf(TStream, TFlexCelPdfExport) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.ExportPdf(const aStream: TStream); overload;

Parameters

<-> | Parameter | Type | Description
const | aStream | TStream | Stream where the pdf file will be saved.

See also

  • TTMSFMXGridExcelExport

TTMSFMXGridExcelExport.ExportPdf(TStream, TFlexCelPdfExport)

Exports the attached grid to Pdf. As this method uses a TFlexCelPdfExport class to do the export, you can customize all options in the pdf exporting before calling this method.

Remarks

Note that for a complete control over the Excel file and the PDF file, you should use Export(TExcelFile, TInsertInSheet) and then use your own TFlexCelPdfExport to manually create the PDF from the TExcelFile

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.ExportPdf(const aStream: TStream; const aPdf: TFlexCelPdfExport); overload;

Parameters

<-> | Parameter | Type | Description
const | aStream | TStream | Stream where the pdf file will be saved.
const | aPdf | TFlexCelPdfExport | This is a TFlexCelPdfExport component that you need to create.

Examples

To export the grid to PDF, customizing the PDF output, you can use the code:

uses ..., FlexCel.Core, FlexCel.XlsAdapter, FlexCel.Render, FlexCel.Pdf;
...
procedure TExampleForm.ExportGridToPdf;
var
  pdf: TFlexCelPdfExport;
  stream: TFileStream;
begin
  stream := TFileStream.Create('MyFile.pdf', fmCreate);
  try
    //FlexCelPdfExport that we will use to do the export.
    pdf := TFlexCelPdfExport.Create;
    try
      pdf.AllowOverwritingFiles := true;
      //Here we can customize the FlexCelPdfExport.
      //For example, we can set the export to be PDF/A
      pdf.PdfType := TPdfType.PDFA3;
      //Or set the pdf author
      pdf.Properties.Author := 'myself';

      //Export the grid to the stream, using our custom FlexCelPdfExport.
      TMSFMXGridExcelExport1.ExportPdf(stream, pdf);
    finally
      pdf.Free;
    end;
  finally
    stream.Free;
  end;
end;

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.ExportHtml Method | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.ExportHtml Method

Overloads

  • TTMSFMXGridExcelExport.ExportHtml(TFileName, THtmlExportMode)
  • TTMSFMXGridExcelExport.ExportHtml(TFlexCelHtmlExport, string, THtmlExportMode)

TTMSFMXGridExcelExport.ExportHtml(TFileName, THtmlExportMode)

Exports the attached grid to HTML.

Remarks

This method will export to HTML with the standard defaults. If you want to customized the export more you can use ExportHtml(TFlexCelHtmlExport, string, THtmlExportMode) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.ExportHtml(const aFileName: TFileName; const aExportMode: THtmlExportMode); overload;

Parameters

<-> | Parameter | Type | Description
const | aFileName | TFileName | Filename of the generated file. All extra files like images will be stored in the same folder.
const | aExportMode | THtmlExportMode | How the grid will be exported.

See also

  • TTMSFMXGridExcelExport

TTMSFMXGridExcelExport.ExportHtml(TFlexCelHtmlExport, string, THtmlExportMode)

Exports the attached grid to HTML. As this method uses a TFlexCelHtmlExport class to do the export, you can customize all options in the html exporting before calling this method.

Remarks

This method will export to HTML with the standard xls file defaults. If you want to customized the export more you can use ExportHtml(TFlexCelHtmlExport, string, THtmlExportMode) instead.

Syntax

Unit: FMX.TMSGridExcelExport

procedure TTMSFMXGridExcelExport.ExportHtml(const aHtml: TFlexCelHtmlExport; const aFileName: string; const aExportMode: THtmlExportMode); overload;

Parameters

<-> | Parameter | Type | Description
const | aHtml | TFlexCelHtmlExport | This is a TFlexCelHtmlExport component that you need to create.
const | aFileName | string | Filename of the generated file. All extra files like images will be stored in the same folder.
const | aExportMode | THtmlExportMode | How the grid will be exported.

Examples

To export the grid to HTML, customizing the HTML output, you can use the code:

uses ..., FlexCel.Core, FlexCel.XlsAdapter, FlexCel.Render;
...
procedure TExampleForm.ExportGridToHtml;
var
  html: TFlexCelHtmlExport;
begin
  //FlexCelHtmlExport that we will use to do the export.
  html := TFlexCelHtmlExport.Create;
  try
    html.AllowOverwritingFiles := true;

    //Here we can customize the HtmlExport
    html.HtmlVersion := THtmlVersion.Html_32;

    //Export the grid to the stream, using our custom FlexCelHtmlExport.
    TMSFMXGridExcelExport1.ExportHtml(html, 'MyFile.html', THtmlExportMode.AllSheetsAsSingleFile);
  finally
    html.Free;
  end;
end;

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.Grid Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.Grid Property

The grid to export.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.Grid: TTMSFMXGrid

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.ExportOptions Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.ExportOptions Property

Settings that affect how the grid will be exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.ExportOptions: TExportOptions

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.LocationOptions Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.LocationOptions Property

Settings that define where the grid will be exported in Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.LocationOptions: TLocationOptions

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.DateFormat Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.DateFormat Property

Default Excel format for the cells that contain dates. This is a global setting, you can control the format in individual cells with OnExportCell

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.DateFormat: string

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.TimeFormat Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.TimeFormat Property

Default Excel format for the cells that contain times. This is a global setting, you can control the format in individual cells with OnExportCell

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.TimeFormat: string

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.ImageMargin Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.ImageMargin Property

Adds a margin around the cell for images or checkboxes. If you set this to 0 images will go exactly to the edges of the cell.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.ImageMargin: TPoint

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.Version Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.Version Property

The version of this component.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.Version: string

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.OnExportCell Event | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.OnExportCell Event

Occurs before exporting every cell, and allows you to customize what is written in it.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.OnExportCell: TExportCellEvent

Examples

To modify the numeric format in column 3, you can use the code:

procedure TExampleForm.TMSFMXGridExcelExport1ExportCell(Sender: TObject;
  var Args: TExportCellEventArgs);
var
  Fmt: TFlxFormat;
begin
  //Format cells in column 3 with a specific format.
  if Args.GridCol = 3 then
  begin
    //We cant modify directly Args.CellFormats.Property.
    //So we use a temp variable.
    Fmt := Args.CellFormat;
    Fmt.Format := '00.00';
    Args.CellFormat := Fmt;
  end;
end;

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.OnProgress Event | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.OnProgress Event

Provides a progress indication of how many cells have been exported.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.OnProgress: TExportProgressEvent

See also

  • TTMSFMXGridExcelExport


TTMSFMXGridExcelExport.OnExportComment Event | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelExport.OnExportComment Event

Occurs before exporting a comment, and allows you to customize the size of the popup note that will appear in Excel.

Syntax

Unit: FMX.TMSGridExcelExport

property TTMSFMXGridExcelExport.OnExportComment: TExportCommentEvent

See also

  • TTMSFMXGridExcelExport


TExportDataType Enumeration | TMS FMX Grid Excel bridge documentation

TExportDataType Enumeration

Defines how a cell will be exported to Excel.

Syntax

Unit: FMX.TMSGridExcelExport

Members

Name | Value | Description
Value | 0 | The cell will be converted to what it represents. For example, the string "1/1/2000" will be entered as a date.
Text | 1 | Whatever you have in the grid, will be exported as a string to Excel. Numeric format will be preserved, but the Excel cells will contain strings, never numbers. Those strings can't be used in formulas, for example the sum of a range containing strings with numbers will always be 0.
Html | 2 | The cell contains HTML formatted text, and will be entered in Excel as rich text.
Formula | 3 | The cell contains a formula.


THtmlExportMode Enumeration | TMS FMX Grid Excel bridge documentation

THtmlExportMode Enumeration

Defines how the grid will be exported to html.

Syntax

Unit: FMX.TMSGridExcelExport

Members

Name | Value | Description
SingleSheet | 0 | Only the current sheet in a workbook will be exported.
AllSheetsAsTabs | 1 | All sheets in the workbook will be exported, with tabs at the top.
AllSheetsAsSingleFile | 2 | All sheets will be exported, one after the other in the same filesheet.


TInsertInSheet Enumeration | TMS FMX Grid Excel bridge documentation

TInsertInSheet Enumeration

How the cells will be inserted when exporting to an existing file.

Syntax

Unit: FMX.TMSGridExcelExport

Members

Name | Value | Description
Clear | 0 | Clears everything on the sheet before exporting the grid.
OverwriteCells | 1 | Overwrites existing cells, but does not clear any existing information on the sheet.
InsertRows | 2 | Inserts the grid inside the existing sheet, moving all the other rows down.
InsertCols | 3 | Inserts the grid inside the existing sheet, moving all the other columns to the right.
InsertRowsExceptFirstAndSecond | 4 | Inserts the grid inside the existing sheet, moving all the other rows down (Grid.RowCount - 2) rows. The first two rows will be overwritten. This can be used to export for example inside of a chart.
InsertColsExceptFirstAndSecond | 5 | Inserts the grid inside the existing sheet, moving all the other columns right (Grid.ColCount - 2) columns. The first two columns will be overwritten. This can be used to export for example inside of a chart.


FMX.TMSGridExcelImport Namespace | TMS FMX Grid Excel bridge documentation

FMX.TMSGridExcelImport Namespace

Classes

Name | Description
TImportOptions | Options that affect how the file will be imported into the grid.
TTMSFMXGridExcel​Import | Component to import an existing Excel file into an TMS Grid.


TImportOptions Class | TMS FMX Grid Excel bridge documentation

TImportOptions Class

Options that affect how the file will be imported into the grid.

Syntax

Unit: FMX.TMSGridExcelImport

TImportOptions = class(TPersistent);

Constructors

Name | Description
Create | Creates a new instance.

Methods

Name | Description
Assign | Assigns an exisiting object to this one.

Properties

Name | Description
Formulas | If true, formulas in Excel will be imported as formulas in the grid. Curently those formula won't calculate. If false, the values of the formulas will be imported.
Images | If true, images will be imported into the grid. Note that as Excel supports "floating" images over a range of cells and the TMS Grid needs the full image to be on one cell, TMSGridExcelImport will merge the cells below the image when importing.
Comments | If true, comments in Excel will be imported as comments in the grid.
CellFormatting | If true, cel formatting like background color will be imported into the grid.
CellSizes | If true, row heights and columns widths will be imported into the grid. If false they won't.
LockedCellsAs​Readonly | If true, locked cells in Excel will be imported as readonly cells in the grid. Note that by default all cells in Excel are locked but they won't be readonly unless the sheet is protected. So to use this property you need protected Excel sheets where cells have been unlocked, or all the file will be imported as readonly.
Html | If true, rich text in Excel will be imported as html text in the grid. If false (the default) rich text will be imported as simple strings.
PrintOptions | If true, many print options in the Excel file (like print orientation) will be imported into the grid.
Outlines | If true (the default) outlines in Excel will be imported as nodes in the grid.
ClearCells | If true, the cells in the grid will be cleared before importing. If false, the cells in Excel will just overwrite exiting ones, but empty cells in Excel will keep the old values in the grid.
ResizeGrid | If true, the grid will be resized to fit exactly the used range in the sheet being imported. If false only cells that fit into the existing grid will be imported.
ActiveSheet | This option only works when importing into a workbook. If true, it will set the active sheet in the workbook to be the same sheet that was active in the imported xls file.


TImportOptions.Create Constructor | TMS FMX Grid Excel bridge documentation

TImportOptions.Create Constructor

Creates a new instance.

Syntax

Unit: FMX.TMSGridExcelImport

constructor TImportOptions.Create;

See also

  • TImportOptions


TImportOptions.Assign Method | TMS FMX Grid Excel bridge documentation

TImportOptions.Assign Method

Assigns an exisiting object to this one.

Syntax

Unit: FMX.TMSGridExcelImport

procedure TImportOptions.Assign(Source: TPersistent); override;

Parameters

<-> | Parameter | Type | Description
 | Source | TPersistent |

See also

  • TImportOptions


TImportOptions.Formulas Property | TMS FMX Grid Excel bridge documentation

TImportOptions.Formulas Property

If true, formulas in Excel will be imported as formulas in the grid. Curently those formula won't calculate. If false, the values of the formulas will be imported.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.Formulas: Boolean

See also

  • TImportOptions


TImportOptions.Images Property | TMS FMX Grid Excel bridge documentation

TImportOptions.Images Property

If true, images will be imported into the grid. Note that as Excel supports "floating" images over a range of cells and the TMS Grid needs the full image to be on one cell, TMSGridExcelImport will merge the cells below the image when importing.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.Images: Boolean

See also

  • TImportOptions


TImportOptions.Comments Property | TMS FMX Grid Excel bridge documentation

TImportOptions.Comments Property

If true, comments in Excel will be imported as comments in the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.Comments: Boolean

See also

  • TImportOptions


TImportOptions.CellFormatting Property | TMS FMX Grid Excel bridge documentation

TImportOptions.CellFormatting Property

If true, cel formatting like background color will be imported into the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.CellFormatting: Boolean

See also

  • TImportOptions


TImportOptions.CellSizes Property | TMS FMX Grid Excel bridge documentation

TImportOptions.CellSizes Property

If true, row heights and columns widths will be imported into the grid. If false they won't.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.CellSizes: Boolean

See also

  • TImportOptions


TImportOptions.LockedCellsAsReadonly Property | TMS FMX Grid Excel bridge documentation

TImportOptions.LockedCellsAsReadonly Property

If true, locked cells in Excel will be imported as readonly cells in the grid. Note that by default all cells in Excel are locked but they won't be readonly unless the sheet is protected. So to use this property you need protected Excel sheets where cells have been unlocked, or all the file will be imported as readonly.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.LockedCellsAsReadonly: Boolean

See also

  • TImportOptions


TImportOptions.Html Property | TMS FMX Grid Excel bridge documentation

TImportOptions.Html Property

If true, rich text in Excel will be imported as html text in the grid. If false (the default) rich text will be imported as simple strings.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.Html: Boolean

See also

  • TImportOptions


TImportOptions.PrintOptions Property | TMS FMX Grid Excel bridge documentation

TImportOptions.PrintOptions Property

If true, many print options in the Excel file (like print orientation) will be imported into the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.PrintOptions: Boolean

See also

  • TImportOptions


TImportOptions.Outlines Property | TMS FMX Grid Excel bridge documentation

TImportOptions.Outlines Property

If true (the default) outlines in Excel will be imported as nodes in the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.Outlines: Boolean

See also

  • TImportOptions


TImportOptions.ClearCells Property | TMS FMX Grid Excel bridge documentation

TImportOptions.ClearCells Property

If true, the cells in the grid will be cleared before importing. If false, the cells in Excel will just overwrite exiting ones, but empty cells in Excel will keep the old values in the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.ClearCells: Boolean

See also

  • TImportOptions


TImportOptions.ResizeGrid Property | TMS FMX Grid Excel bridge documentation

TImportOptions.ResizeGrid Property

If true, the grid will be resized to fit exactly the used range in the sheet being imported. If false only cells that fit into the existing grid will be imported.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.ResizeGrid: Boolean

See also

  • TImportOptions


TImportOptions.ActiveSheet Property | TMS FMX Grid Excel bridge documentation

TImportOptions.ActiveSheet Property

This option only works when importing into a workbook. If true, it will set the active sheet in the workbook to be the same sheet that was active in the imported xls file.

Syntax

Unit: FMX.TMSGridExcelImport

property TImportOptions.ActiveSheet: Boolean

See also

  • TImportOptions


TTMSFMXGridExcelImport Class | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport Class

Component to import an existing Excel file into an TMS Grid.

Syntax

Unit: FMX.TMSGridExcelImport

TTMSFMXGridExcelImport = class(TComponent);

Constructors

Name | Description
Create | Creates a new instance.

Destructors

Name | Description
Destroy | Frees all the resources associated with this component.

Methods

Name | Description
Import | Overloaded Import(TExcelFile) Import(TFileName, string) Import(TStream, string)

Properties

Name | Description
Grid | The grid where to import.
ImportOptions | Settings that affect how the grid will be imported.
LocationOptions | Settings that define where the cells will be imported in the grid.
Zoom | The zoom level in the sheet that will be used when importing. If 0 (the default) the zoom in the sheet itself will be used. If not 0, this value must be between 10 and 400.
Version | The version of this component.

Events

Name | Description
OnProgress | Provides a progress indication of how many cells have been exported.


TTMSFMXGridExcelImport.Create Constructor | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Create Constructor

Creates a new instance.

Syntax

Unit: FMX.TMSGridExcelImport

constructor TTMSFMXGridExcelImport.Create(AOwner: TComponent);

Parameters

<-> | Parameter | Type | Description
 | AOwner | TComponent |

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.Destroy Destructor | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Destroy Destructor

Frees all the resources associated with this component.

Syntax

Unit: FMX.TMSGridExcelImport

destructor TTMSFMXGridExcelImport.Destroy;

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.Import Method | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Import Method

Overloads

  • TTMSFMXGridExcelImport.Import(TExcelFile)
  • TTMSFMXGridExcelImport.Import(TFileName, string)
  • TTMSFMXGridExcelImport.Import(TStream, string)

TTMSFMXGridExcelImport.Import(TExcelFile)

Imports an existing TXlsFile object into the grid. Use this method for maximum flexibility, as you can use any of the methods in TXlsFile to open a file from anywhere and modify it before importing it. You can also set the ActiveSheet you want to import before calling this method.

Syntax

Unit: FMX.TMSGridExcelImport

procedure TTMSFMXGridExcelImport.Import(const Xls: TExcelFile); overload;

Parameters

<-> | Parameter | Type | Description
const | Xls | TExcelFile | ExcelFile with the file you want to import.

See also

  • TTMSFMXGridExcelImport

TTMSFMXGridExcelImport.Import(TFileName, string)

Imports a file from disk.

Syntax

Unit: FMX.TMSGridExcelImport

procedure TTMSFMXGridExcelImport.Import(const FileName: TFileName; const SheetName: string); overload;

Parameters

<-> | Parameter | Type | Description
const | FileName | TFileName | Name of the file to import.
const | SheetName | string | Sheet name to import. If you set this to '', the active sheet in the file will be used.

See also

  • TTMSFMXGridExcelImport

TTMSFMXGridExcelImport.Import(TStream, string)

Imports a file from a stream.

Syntax

Unit: FMX.TMSGridExcelImport

procedure TTMSFMXGridExcelImport.Import(const aStream: TStream; const SheetName: string); overload;

Parameters

<-> | Parameter | Type | Description
const | aStream | TStream | Stream with the data to import.
const | SheetName | string | Sheet name to import. If you set this to '', the active sheet in the file will be used.

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.Grid Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Grid Property

The grid where to import.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.Grid: TTMSFMXGrid

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.ImportOptions Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.ImportOptions Property

Settings that affect how the grid will be imported.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.ImportOptions: TImportOptions

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.LocationOptions Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.LocationOptions Property

Settings that define where the cells will be imported in the grid.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.LocationOptions: TLocationOptions

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.Zoom Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Zoom Property

The zoom level in the sheet that will be used when importing. If 0 (the default) the zoom in the sheet itself will be used. If not 0, this value must be between 10 and 400.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.Zoom: Integer

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.Version Property | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.Version Property

The version of this component.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.Version: string

See also

  • TTMSFMXGridExcelImport


TTMSFMXGridExcelImport.OnProgress Event | TMS FMX Grid Excel bridge documentation

TTMSFMXGridExcelImport.OnProgress Event

Provides a progress indication of how many cells have been exported.

Syntax

Unit: FMX.TMSGridExcelImport

property TTMSFMXGridExcelImport.OnProgress: TExportProgressEvent

See also

  • TTMSFMXGridExcelImport


Examples | TMS FMX Grid Excel bridge documentation

Examples

This section contains the code listing for all the examples available in the TMS FMX Grid Excel bridge distribution.

You can open the actual examples at the locations shown in each one of the code listings.

In this section:

  • Examples for FMX


Examples for FMX | TMS FMX Grid Excel bridge documentation

Examples for FMX

In this section

  • Simple Export

  • Simple Import


Simple Export (FMX) | TMS FMX Grid Excel bridge documentation

Simple Export (FMX)

Note

This demo is available in your FMXGridExcelBridge installation at <FMXGridExcelBridge Install Folder>\Demo\FMX\SimpleExport and also at https:​//​github.​com/​tmssoftware/​TMS-​FMXGrid-​Excel-​bridge-​demos/​tree/​master/​delphi/​fmx/​Simple​Export

Overview

This demo shows how to export a grid to Excel, PDF or HTML using TMS FMX Grid Excel bridge

Concepts

  • In the checkboxes at the left, you can experiment with multiple option combinations and see which one suits your needs best.

  • In this example we use the simpler one-liners to do the export. Look at the templates demo for an example on more complex exporting.

Files

USimpleExport.pas

unit USimpleExport;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.TMSBaseControl,
  FMX.TMSGridCell, FMX.TMSGridOptions, FMX.TMSGridData, FMX.TMSCustomGrid,
  FMX.TMSGrid, FMX.TMSGridExcelExport,
  FMX.TMSBitmapContainer, FMX.TMSGridPDFIO,
  {$IF COMPILERVERSION >= 25}
  FMX.StdCtrls,
  FMX.ExtCtrls,
  {$IFEND}
  {$IF COMPILERVERSION >= 31}  //Delphi 10.1 Berlin deprecated MessageDlg
  FMX.DialogService.Sync,
  {$ENDIF}
  FMX.TMSUtils,
  FMX.FlexCel.Core, FlexCel.XlsAdapter;

type
  TFSimpleExport = class(TForm)
    TMSFMXGrid1: TTMSFMXGrid;
    ToolBar1: TToolBar;
    btnExportToExcel: TButton;
    btnExportToHTML: TButton;
    btnExportToPDF: TButton;
    ExcelExport: TTMSFMXGridExcelExport;
    SaveDialogExcel: TSaveDialog;
    SaveDialogPdf: TSaveDialog;
    SaveDialogHtml: TSaveDialog;
    TMSFMXBitmapContainer1: TTMSFMXBitmapContainer;
    btnDark: TButton;
    StyleBookDark: TStyleBook;
    StyleBookDefault: TStyleBook;
    procedure btnExportToExcelClick(Sender: TObject);
    procedure TMSFMXGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
      ALayout: TTMSFMXGridCellLayout; ACellState: TCellState);
    procedure FormCreate(Sender: TObject);
    procedure btnDarkClick(Sender: TObject);
    procedure btnExportToPDFClick(Sender: TObject);
    procedure btnExportToHTMLClick(Sender: TObject);
  private
    procedure InitGrid;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FSimpleExport: TFSimpleExport;

implementation

{$R *.fmx}

procedure TFSimpleExport.btnDarkClick(Sender: TObject);
begin
  if btnDark.IsPressed then
  begin
    TMSFMXGrid1.StyleLookup := 'TMSFMXGrid1Style1';
    FSimpleExport.StyleBook := StyleBookDark;
  end
  else
  begin
    TMSFMXGrid1.StyleLookup := '';
    FSimpleExport.StyleBook := StyleBookDefault;
  end;
end;

procedure TFSimpleExport.btnExportToExcelClick(Sender: TObject);
begin
  if not SaveDialogExcel.Execute then exit;

  //SetExportoptions;
  ExcelExport.ExportOptions.HardBorders := true;
  ExcelExport.Export(SaveDialogExcel.FileName, 'Result');

{$IF COMPILERVERSION >= 31}  //Delphi 10.1 Berlin deprecated MessageDlg
  if TDialogServiceSync.MessageDialog('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogExcel.FileName);
  end;
{$ELSE}
  if MessageDlg('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogExcel.FileName);
  end;
{$ENDIF}

end;

procedure TFSimpleExport.btnExportToHTMLClick(Sender: TObject);
begin
  if not SaveDialogHtml.Execute then exit;
  ExcelExport.ExportOptions.HardBorders := true;
  ExcelExport.ExportHtml(SaveDialogHtml.FileName, THtmlExportMode.SingleSheet);

{$IF COMPILERVERSION >= 31}  //Delphi 10.1 Berlin deprecated MessageDlg
  if TDialogServiceSync.MessageDialog('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogHtml.FileName);
  end;
{$ELSE}
  if MessageDlg('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogHtml.FileName);
  end;
{$ENDIF}

end;

procedure TFSimpleExport.btnExportToPDFClick(Sender: TObject);
begin
  if not SaveDialogPdf.Execute then exit;
  ExcelExport.ExportOptions.HardBorders := true;
  ExcelExport.ExportPdf(SaveDialogPdf.FileName);

{$IF COMPILERVERSION >= 31}  //Delphi 10.1 Berlin deprecated MessageDlg
  if TDialogServiceSync.MessageDialog('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogPdf.FileName);
  end;
{$ELSE}
  if MessageDlg('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
  begin
    TTMSFMXUtils.OpenFile(SaveDialogPdf.FileName);
  end;
{$ENDIF}
end;

procedure TFSimpleExport.FormCreate(Sender: TObject);
begin
  InitGrid;
end;

procedure TFSimpleExport.InitGrid;
var
  PrSet: TTMSFMXGridPrintingOptions;
begin
  TMSFMXGrid1.ColumnCount := 6;
  TMSFMXGrid1.RandomFill;
  TMSFMXGrid1.AutoNumberCol(0);
  TMSFMXGrid1.Colors[2,2] := TAlphaColors.Red;
  TMSFMXGrid1.Colors[3,3] := TAlphaColors.Lime;
  TMSFMXGrid1.Colors[4,4] := TAlphaColors.Yellow;

  {$IF COMPILERVERSION >= 27}
  TMSFMXGrid1.HorzAlignments[2,3] := TTextAlign.Center;
  TMSFMXGrid1.HorzAlignments[3,4] := TTextAlign.Trailing;
  {$ELSE}
  TMSFMXGrid1.HorzAlignments[2,3] := TTextAlign.taCenter;
  TMSFMXGrid1.HorzAlignments[3,4] := TTextAlign.taTrailing;
  {$IFEND}

  TMSFMXGrid1.FontStyles[1,1] := [TFontStyle.fsBold];
  TMSFMXGrid1.FontStyles[1,2] := [TFontStyle.fsItalic];

  TMSFMXGrid1.MergeCells(1,4,2,2);

  TMSFMXGrid1.AddBitmap(1,7,'1');
  TMSFMXGrid1.AddBitmap(1,8,'2');
  TMSFMXGrid1.AddBitmap(1,9,'3');

  TMSFMXGrid1.Comments[3,1] := 'This is an important comment!';

  TMSFMXGrid1.AddCheckBox(4,2, true);
  TMSFMXGrid1.AddCheckBox(5,2, false);

  TMSFMXGrid1.AddNode(2, 3);

  TMSFMXGrid1.Cells[1, 3] := 'Html: <br /><b>Bold</b> and <i>Italic</i>';
  TMSFMXGrid1.RowHeights[3] := 50;
  TMSFMXGrid1.ColumnWidths[1] := 100;

  PrSet := TMSFMXGrid1.Options.Printing;
  PrSet.TitlePosition := TTMSFMXGridPrintPosition.ppTopLeft;
  PrSet.Title := 'TMS FMX Grid & Exporting';
  PrSet.TitleFont.Family := 'Times New Roman';
  PrSet.TitleColor := TAlphaColors.Navy;

  PrSet.DescriptionPosition := TTMSFMXGridPrintPosition.ppBottomCenter;
  PrSet.Description := 'This demo shows how to export a grid using FMX Grid Excel Bridge';
  PrSet.DescriptionFont.Family := 'Tahoma';
  PrSet.DescriptionColor := TAlphaColors.Chocolate;

  PrSet.PageNumberPosition := TTMSFMXGridPrintPosition.ppTopRight;
  PrSet.PageNumberFont.Family := 'Times New Roman';
  PrSet.PageNumberFont.Size := 14;
  PrSet.PageNumberFont.Style := [TFontStyle.fsBold];
  PrSet.PageNumberColor := TAlphaColors.MoneyGreen;

end;

procedure TFSimpleExport.TMSFMXGrid1GetCellLayout(Sender: TObject; ACol,
  ARow: Integer; ALayout: TTMSFMXGridCellLayout; ACellState: TCellState);
begin
  if (ACol = 5) then
  begin
    ALayout.FontFill.Color := TAlphaColors.Red;
  {$IF COMPILERVERSION >= 27}
    ALayout.TextAlign := TTextAlign.Trailing;
  {$ELSE}
    ALayout.TextAlign := TTextAlign.taTrailing;
  {$IFEND}
  end;
end;

end.


Simple Import (FMX) | TMS FMX Grid Excel bridge documentation

Simple Import (FMX)

Note

This demo is available in your FMXGridExcelBridge installation at <FMXGridExcelBridge Install Folder>\Demo\FMX\SimpleImport and also at https:​//​github.​com/​tmssoftware/​TMS-​FMXGrid-​Excel-​bridge-​demos/​tree/​master/​delphi/​fmx/​Simple​Import

Overview

This demo shows how to import an existing Excel file into a grid.

Concepts

  • At the left pane, you can play with the different options for importing.

Files

USimpleImport.pas

unit USimpleImport;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.TMSGridExcelImport,
  FMX.TMSBaseControl, FMX.TMSGridCell, FMX.TMSGridOptions, FMX.TMSGridData,
  {$IF COMPILERVERSION >= 25}
  FMX.StdCtrls, FMX.ExtCtrls,
  {$IFEND}
 FMX.TMSCustomGrid, FMX.TMSGrid;

type
  TFSimpleImport = class(TForm)
    Panel1: TPanel;
    TMSFMXGrid: TTMSFMXGrid;
    TMSFMXGridExcelImport: TTMSFMXGridExcelImport;
    btnImport: TButton;
    OpenDialog: TOpenDialog;
    cbFormulas: TCheckBox;
    cbImages: TCheckBox;
    cbComments: TCheckBox;
    cbFormatting: TCheckBox;
    cbCellSizes: TCheckBox;
    cbReadOnlyToLocked: TCheckBox;
    cbHTML: TCheckBox;
    cbPrintOptions: TCheckBox;
    procedure btnImportClick(Sender: TObject);
  private
    procedure SetImportOptions;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FSimpleImport: TFSimpleImport;

implementation

{$R *.fmx}

procedure TFSimpleImport.btnImportClick(Sender: TObject);
begin
  if not OpenDialog.Execute then exit;

  SetImportOptions;
  TMSFMXGridExcelImport.Import(OpenDialog.FileName);

end;

procedure TFSimpleImport.SetImportOptions;
begin
  TMSFMXGridExcelImport.ImportOptions.Formulas := cbFormulas.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.Images := cbImages.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.Comments := cbComments.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.CellFormatting := cbFormatting.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.CellSizes := cbCellSizes.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.LockedCellsAsReadonly := cbReadOnlyToLocked.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.Html := cbHtml.IsChecked;
  TMSFMXGridExcelImport.ImportOptions.PrintOptions := cbPrintOptions.IsChecked;
end;

end.


About | TMS FMX Grid Excel bridge documentation

About

This documentation is for TMS FMX Grid Excel bridge v3.1.0

Copyright (c) 2002 - 2021 tmssoftware.com

In this section:

What's new

Everything that changed since the last release.

Copyright information

Information about the third party copyrights and licenses of code used by TMS FMX Grid Excel bridge.


What's new in TMS FMX Grid-Excel Bridge | TMS FMX Grid Excel bridge documentation

What's new in TMS FMX Grid-Excel Bridge

New in v 3.1 - September 2021

  • Rad Studio 11 support. Added Rad Studio 11 Support.

New in v 3.0.1 - April 2021

  • BugFix. The installer wouldn't install in macOS 64bit

New in v 3.0

  • Unified versioning. Now we have a single versioning between VCL/FMX/FNC Grid-Excel bridges

  • New documentation system. There are new and improved documentation and examples.

New in v 2.3.2

  • Bug Fix. Fixed setup errors.

New in v 2.3.1

  • Bug Fix. The installer could throw an exception when installing in old Delphi versions.

New in v 2.3

  • Support for Rad Studio 10.4 Sydney. Now the setup will install in Rad Studio 10.4 Sydney.

New in v 2.2.1

  • Fixed install error. The setup could fail to find the component pack even if it was installed.

New in v 2.2

  • Support for Rad Studio 10.3 Rio. Now the setup will install in Rad Studio 10.3 Rio.

New in v 2.1

  • Support for Rad Studio 10.2 Tokyo. Now the setup will install in Rad Studio 10.2 Tokyo.

New in v 2.0

  • Adapted for TMS UI Pack 3.5. The component TTMSFMXFlexCelPDFRenderLib for exporting natively to pdf using FlexCel was removed. Now you can use the new pdf engine in the pack directly.

New in v 1.9

  • Setup modified to install all supported platforms. Setup used to install only packages for win32 and the other platforms had to be manually installed. Now they are also installed in the setup.

New in v 1.8

  • Rad Studio 10.1 Berlin support. Added support for Rad Studio 10.1 Berlin.

New in v 1.7

  • Rad Studio 10 Seattle Support. Added support for Rad Studio 10 Seattle.

  • Improved image exporting. The size of the images could be wrong in some cases. Now we also export the images if they are not in a BitmapContainer.

  • Bug Fix. Images could be exported in the wrong sizes sometimes.

New in v 1.6

  • XE8 Support. Added support for Rad Studio XE8.

New in v 1.5

  • XE7 Support. Added support for Rad Studio XE7.

New in v 1.4

  • XE6 Support. Added support for Rad Studio XE6.

New in v 1.3

  • XE5 Support. Added support for Rad Studio XE5.

New in v 1.2.1

  • Bug Fix. C++ Builder header files required explicit namespaces. Now namespaces are implicit.

New in v 1.2

  • XE4 Support. Rad Studio XE4 is now supported.

New in v 1.1

  • Export grid headers and footers. Now when ExportPrintSettings is true, the grid title will be exported as headers or footers in Excel.

New in v 1.0

  • First release. This is the first release.


Copyright information | TMS FMX Grid Excel bridge documentation

Copyright information

All files in this distribution are copyright (c) Adrian Gallero and licensed under the terms detailed in the file license.rtf.


TMS FMX Grid Excel bridge documentation. | TMS FMX Grid Excel bridge documentation

TMS FMX Grid Excel bridge documentation.