3 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 3
4 star 0
3 star 0
2 star 0
1 star 0
Compatible with
  • iOS
  • Android

TMS FlexCel Studio for .NET


Manipulate Excel files, create reports based on templates, and export Excel files to Pdf and HTML.

FlexCel Studio is a library to read and write xls and xlsx files, export them to html or pdf and print and preview them.

All code is written in C#, and full sources are included.

It is available for Xamarin.Mac, Xamarin.iOS, Xamarin.Android, Windows Phone, Windows Store (WinRT), Mono for Linux and Desktop .NET. A single license is valid for all supported platforms.

At its core, FlexCel has three main components:

1. An xls/x engine

This is the most lower level component in the pack. It contains an API to read and write xls or xlsx files, and the main object you use for it is the XlsFile object.


public void CreateFile()
   XlsFile xls = new XlsFile(1, true);
   xls.SetCellValue(1, 1, "FlexCel says Hello!");

There is a tool available for Windows and OSX that you can use to find out how to use the xls/x engine. Just create the file you want to create in Excel, and open the file with:

APIMate will show you the needed code (in C# or VB.NET) to create the file. Full source for APIMate is included, so you can study how it works too.

2. A reporting engine

This is a higher level component for creating xls or xlsx files. When using it, you create a file in Excel which will be used as a template where the reporting engine will fill the values. Internally, this component uses the xls/x engine to create the files, but it allows you to do it in a more declarative way. It allows you to use Excel as the report designer.


In Excel, create a file and write:

|   |         A          |           B              |        C                          |
| 1 | <#Customer.Name>   | <#if(Customer.Vip;VIP;)> | <#Customer.Age>                   |
| 2 |                    |                          |                                   |
| 3 |                    |                          | ="Average Age: " & Average(C1:C2) |

Add a named range (in the ribbon-> Formula tab->Name Manager). Name it "__Customer__", and make it go from A1 to C1. This name must have 2 underscores at the beginning and end, and the text between the underscores must be the same as the text between <#.... .> tags. It tells FlexCel which rows are used for each record in the database.

Save the file as "template.xlsx"

Then write the following code:

class Customer
   public string Name { get; set; }
   public bool Vip { get; set; }
   public int Age {get; set; }

public void CreateFile()
   List<Customer> Customers = GetCustomers();

   using (FlexCelReport fr = new FlexCelReport(true))
      fr.AddTable("Customer", Customers);
      fr.Run("template.xlsx", "result.xlsx");

This is a basic report, but you can do a lot more, like multiple level master-detail reports, cross ref reports, etc. Take a look at the Windows examples for a list of possible reports.

3. A rendering engine

This component is used to convert any xls or xlsx file to pdf, images, html or to print them. Internally it also uses the xls/x engine, as the reporting engine does.


To convert a file to pdf:

    XlsFile xls = new XlsFile(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "result.xlsx"));

    using (var pdf = new FlexCelPdfExport(xls, true))
        pdf.Export(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "result.pdf"));

To convert a file to html:

    XlsFile xls = new XlsFile(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "result.xlsx"));

    using (var html = new FlexCelHtmlExport(xls, true))
        html.Export(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "result.html"), null);

Release Notes

New on v

  • Windows Phone 8.1 and Windows Store 8.1 Support. Now FlexCel includes a Portable Class Library which will let you create Windows Phone 8.1 and Windows Store 8.1 apps. Note that in order to see it, you need Visual Studio 2013 Update 2 (currently in RC with a go-live license)

  • SVG Exporting. A new component, FlexCelSVGExport allows to export xls/x files to SVG. A new example "Export SVG" is included too. SVG files are now supported by all major browsers, desktop and mobile, so you can use them when exporting to html to have resolution independent images.

  • HTML 5 Exporting. Now FlexCelHtmlExport can export to HTML5/CSS3 as one of the options. When exporting to HTML5 some new capabilities are available.

  • Improved support for document properties. Full support for setting standard or custom properties in xlsx files. (xls is still read only). A new method XlsFile.DocumentProperties.RemoveAllProperties will allow you to remove all properties in the xls or xlsx files, so you can be sure it doesn't contain unwanted information. A new method XlsFile.DocumentProperties.GetUsedStandardProperties will return a list of the used standard properties in the file. A new method XlsFile.DocumentProperties.SetUsedStandardProperty allows to modify standard properties in xlsx. New methods SetCustomProperty, GetCustomProperty and GetAllCustomProperties allow to manage custom properties. Document properties will be preserved when opening xls or xlsx files and saving as xlsx, or when opening and saving as xls. They won't be preserved when opening xlsx and saving as xls.

  • Embed images in HTML files. A new property: FlexCelHtmlExport.EmbedImages allows to embed the images as Data Uris ( http://tools.ietf.org/html/rfc2397 ) inside the html file. When setting this property to true the generated html file can be self contained, and you don't have to deal with managing the external images.

  • SVG images in HTML files. Now FlexCelHtmlExport.SavedImagesFormat allows a new possibility: THtmlImageFormat.Svg. SVG is a standard vector image format supported by most modern browsers, and using svg means that high-dpi/retina devices can zoom smoothly in the vector assets of the file, like charts or autoshapes.

  • TExcelChart.RemoveLegend method. A new method in TExcelChart allows to remove a legend. Note that currently this only works in xls charts, not xlsx.

  • Improved chart rendering. Now charts will have the frame box with rounded corners if you specify so in Excel.

  • Improved performance in VLookup. The implementation of the function VLookup is now much faster when searching in an unsorted range.

  • Improved performance in pdf/html exporting. Many optimizations in the rendering engine.

  • Improved APIMate. APIMate now shows how to autofit a comment box to the text size, and also how to set properties in xlsx.

  • New property DisableSQLValidation in FlexCelReport. Now FlexCelReport has a new property "DisableSQLValidation" which will allow to send arbitrary SQL commands from the config sheet. It will allow for example to execute stored procedures in SQL Server. If you decide to disable the SQL validation, please take a look at the remarks in DisableSQLValidation documentation.

  • Bug fix. Some cells with automatic background colors in xls files could be saved with the wrong color when converting to xlsx.

  • Bug fix. XlsFile.Find could keep returning the same values in corner cases.

  • Bug fix. When Inserting an empty sheet locally defined ranges wouldn't update the sheet where they were defined. This happened only with empty sheets, if you inserted a sheet with data it would work fine.

  • Bug fix. FlexCelPreview could show text as underlined in some third party generated xlsx files.

Write a Review

1 review

Hao Li rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Perfect, easy to use. A good tool to create code - even no need to read document, it's enough to just check the code

Posted on: April 30 / Version: