VCL / FMX Flexcel for D2010

VCL / FMX Flexcel is suitable for Delphi 2010 !!
I have not found a version for Delphi 2010


Sorry, FlexCel requires Delphi XE or newer. It is not because we wouldn’t love to support D2010 (and 2009, which should also theoretically work), but because we make use heavy use of generics, and those are really buggy in Delphi 2009/2010. We spent months trying to compile FlexCel in D2010, but finally had to give up: It doesn’t work.

What we do have is FlexCel dll:

Which is a dll compiled with Delphi Xe2, which can be used from Delphi 6 and up. It doesn’t include all FlexCel functionality (most important thing missing is reports), but it does include a big part of the functinality of the full FlexCel, and can workin Delphi 2010.

Hi, the help of XE10 is very short and incomplete. I understand that's not your problem, but could you shortly give some hints about how to pass datas to a DLL, and get datas in return ?

Many thanks, Milos

Mostly all the documentation for normal FlexCel works in FlexCel dll:

Basically you need to change some "." by "" because old Delphi don't support scoped enums or records with methods, and that is all. You should be able to compile any code in normal FlexCel (excluding reports), in FlexCel dll. 

This includes APIMate, which will work mostly the same too, so you can look at the code generated by APIMate and try it: you will get some compiler errors but they are normally fixed by replacing "." by "".

For examples on how to use, it please take a look at the demos at:
<FlexCel dll install folder>\TMSSoftware\FlexCelDLL\Demo\10.API

For example, the first example shows how to send data to an Excel file:

unit UGettingStarted;


  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellAPI, UPaths,
  VCL_FlexCel_Core, FlexCel_XlsAdapter, FlexCelDynEnums;

  TFGettingStarted = class(TForm)
    btnCreateFile: TButton;
    Memo1: TMemo;
    SaveDialog: TSaveDialog;
    procedure btnCreateFileClick(Sender: TObject);
    procedure CreateFile;
    procedure AddData(const Xls: TExcelFile);
    procedure ShowOpenDialog(const Xls: TExcelFile);

  FGettingStarted: TFGettingStarted;


{$R *.dfm}

procedure TFGettingStarted.CreateFile;
  Xls: TExcelFile;
  Xls := TXlsFile.Create(true);

procedure TFGettingStarted.AddData(const Xls: TExcelFile);
  PathToImage : string;
  fmt: TFlxFormat;
  XF, XF2: integer;
	//Create a new file. We could also open an existing file with Xls.Open

  //Set some cell values.
  Xls.SetCellValue(1, 1, 'Hello to the world');
  Xls.SetCellValue(2, 1, 3);
  Xls.SetCellValue(3, 1, 2.1);
  Xls.SetCellValue(4, 1, TFormula_Create('=Sum(A2, A3)')); //Note that formulas always are in English. This means use "," to separate arguments, not ";".
	//Get path for images from disk.
  PathToImage := DataFolder  + 'poweredbyflexcel.png';

  //Add a new image on cell F2
    TClientAnchor_Create(TFlxAnchorType_MoveAndResize, 2, 0, 6, 0, 5, 0, 8, 0),
    PathToImage, 'My image')); 

	//Add a comment on cell a2
	Xls.SetComment(2, 1, 'This is a comment');

	//Custom Format cells a2 and a3
  fmt := Xls.GetDefaultFormat;  //Always initialize the record with an existing format.
  fmt.Font.Name := 'Times New Roman';
  fmt.Font.Color :=  TExcelColor_FromTheme(TThemeColor_Accent2);
  fmt.FillPattern.Pattern := TFlxPatternStyle_LightDown;
  fmt.FillPattern.FgColor := TExcelColor_FromColor(clBlue);
  fmt.FillPattern.BgColor := TExcelColor_FromColor(clWhite);

	//You can call AddFormat as many times as you want, it will never add a format twice.
	//But if you know the format you are going to use, you can get some extra CPU cycles by
	//calling addformat once and saving the result into a variable.
	XF := Xls.AddFormat(fmt);

  Xls.SetCellFormat(2, 1, XF);
  Xls.SetCellFormat(3, 1, XF);

	fmt.Rotation := 45;
  fmt.Font.Size20 := 400;
  fmt.FillPattern.Pattern := TFlxPatternStyle_Solid;
  XF2 := Xls.AddFormat(fmt);

	//Apply a custom format to all the row.
	Xls.SetRowFormat(1, XF2);

  //Merge cells
	Xls.MergeCells(5, 1, 10, 6);
	//Note how this one merges with the previous range, creating a final range (5,1,15,6)
	Xls.MergeCells(10, 6, 15, 6);

	//Make the page print in landscape or portrait mode
	Xls.PrintLandscape := true;

procedure TFGettingStarted.btnCreateFileClick(Sender: TObject);

procedure TFGettingStarted.ShowOpenDialog(const Xls: TExcelFile);
  if not SaveDialog.Execute then exit;
  Xls.Save(SaveDialog.FileName); //No need to delete the file first, since AllowOverWriteFiles is true in XlsAdapter.

  if MessageDlg('Do you want to open the generated file?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    ShellExecute(0, 'open', PCHAR(SaveDialog.FileName), nil, nil, SW_SHOWNORMAL);


And you will see it is basically the same as the "Getting started" demo for normal FlexCel:

Differences are that the dll needs to use an extra unit :
And for example this line in normal FlexCel:

  Xls.SetCellValue(4, 1, TFormula.Create('=Sum(A2, A3)')); 


  Xls.SetCellValue(4, 1, TFormula_Create('=Sum(A2, A3)')); 


You can see a full diff between both versions here:

To read text, please take a look at the demo 20.Reading Files. Again, this is very similar to the normal FlexCel, with only the differences needed because unsupported stuff in older Delphi versions.

I do wish we had the resources to have a complete FlexCel dll documentation (which would be identical to the FlexCel documentation but with some "." replaced by "_", but we just don't have the resources. FlexCel dll is a solution to allow users in Delphi < XE to still use FlexCel, but we can't just keep the docs at the same standard. Keeping both a FlexCel .NET and FlexCel VCL docs always complete and up to date is a full time job. Considering docs for FlexCel dll are virtually the same as FlexCel VCL, we can't justify to keep another version with some dots replaced with underscores.

If there is anything specific that you would like to know that is not covered in the demos included in FlexCel Dll let me know, and I can send you an example.