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 6.7


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

  • Support for opening xls versions from 2 to 4. As FlexCel already supported xls 5 and up and Excel 1 doesn't exist for Windows, this completes the support for all versions of xls. While xls versions from 2 to 4 aren't in wide use, they are still used by other third party libraries.

  • Enhanced High DPI Support in FlexCelPreview. Now FlexCelPreview supports High DPI in Windows, besides iOS or OSX as it already did.

  • Breaking Change: Property Resolution in FlexCelPreview has been removed. The property Resolution of FlexCelPreview has been removed because now FlexCelPreview automatically adjusts to the resolution of the monitor.

  • Full support for background images in a sheet. XlsFile adds two new methods to deal with background images in a sheet: SetSheetBackground and GetSheetBackground. Background images are now converted between xls and xlsx. ApiMate will also report the code to add a background image to a sheet. A new property ExportSheetBackgroundImages allows you to print or export the background images. (note that Excel never prints the background images, so this property is false by default)

  • Full support for manipulating Custom XML parts with XlsFile. The new methods CustomXmlPartCount AddCustomXmlPart, GetCustomXmlPart and RemoveCustomXmlPart in XlsFile allow for reading and writing the custom xml files of an xlsx files, as explained here: https://msdn.microsoft.com/en-us/library/bb608618.aspx ApiMate will now show how to enter custom xml parts in an xlsx file.

  • New property for PDF files: InitialZoomAndView. The new InitialZoomAndView property allows you to specify the initial page and zoom when opening the document.

  • New property for PDF files: PageLayoutDisplay. The new PageLayoutDisplay property allows you to specify if to display one or two pages, and continuous scrolling or one page at a time when opening the document.

  • Two new modes for PDF files PageLayout. Now generated PDF files can use a PageLayout of TPageLayout.OptionalContent to show the optional content panel, or TPageLayout.AttachmentPanel to show the attachments panel.

  • New property ScreenScaling in XlsFile. This new property allows you to workaround Excel bugs when working in high dpi displays. For more information read http://www.tmssoftware.com/site/blog.asp?post=311

  • Better handling of stored numbers in xlsx. Now numbers are saved in xlsx with a roundtrip format, which ensures the number we write in the file is exactly the same number that will be read.

  • Ability to <#insert> empty names in reports. Now when you use the <#include> tag in a report, you can leave the name to include empty. This will mean to insert all the used range in the active sheet.

  • New overload for XlsFile.DeleteRange. There is a new option for XlsFile.DeleteRange, which will clear the cells but not the formats on it: It will behave similar to when you press "Delete" in a range of cells in Excel.

  • New property ExportEmptyBands in FlexCelReport. ExportEmptyBands replaces the existing ExportEmptyRanges property which has been deprecated. It allows you to choose between 3 possibilities when the data table has 0 records: Delete the range and move cells up, clear the data and format of the range, or clear only the data.

  • Bug Fix. Now FlexCel will make sure the xml declaration in the custom xml parts added with AddCustomXmlPart have the same encoding as the encoding being used to store the file.

  • Bug Fix. Xlsx files with external formulas referring to other sheets starting with a number weren't quoted, and Excel would report an error when opening those files.

  • Bug Fix. FlexCel would fail to load files with formulas which pointed to tables in other files with the new table formula syntax.

  • Bug Fix. Subtotal function could recalculate wrong in border cases.

  • Breaking Change: Improved lookup tag in reports. The <#lookup> tag in reports has been rewritten to be faster and behave better. IF you are defining your own VirtualDataSets and overriding the Lookup function you might need to rewrite it, as parameters changed. But with the new base lookup implementation that is now available for all, you might just remove the override and use the base.

  • SPLIT Datasets in Reports can now be used as datasets for sheets. This allows you to overflow a report into multiple sheets. When the data in a sheets reaches the maximum of the split, it will continue in a different sheet. A new sample "Overflow sheets" shows how to do it.

  • Copy to clipboard wasn't working in Excel 2013. We modified the clipboard format so now it is working.

  • Bug Fix. When inserting or deleting columns, array formulas located in other sheets might not update to take in account those changed rows or columns.

  • Bug Fix. Sometimes when moving a range array formulas which pointed to that range might fail to update.

  • Bug Fix. Some functions with array arguments could not be calculated correctly when the formula was not an array formula.

  • Bug Fix. The lookup tag introduced in 6.6.32 could fail if the lookup value was a tag in the template

  • Bug Fix. The functions SumIfs, AverageIfs and CountIfs could give wrong results in some cases.

  • Bug Fix. When rendering a chart with an image inside, there could be an exception.

  • Bug Fix. Images inside charts with negative coordinates weren't rendered.

  • Bug Fix. Now scatter charts behave like Excel, and if any of the x-axis values is a string, it will be rendered as a line chart instead.

  • Bug Fix. XlsFile.SetAutoRowHeigth wouldn't work if the row was empty.

  • Bug Fix. Chart rendering now renders charts where all values are 0.

  • Bug Fix. Chart rendering now respects the label positions next to axis, high and low.

  • Bug Fix. ExportEmptyBands introduced in 6.6.25 wouldn't work in detail reports.

  • Bug Fix. In some cases when generating reports and exporting them to pdf directly without saving them as xls/x, there could be a range check error.

  • Bug Fix. Tabs inside text in autoshapes now will render as 8 spaces. (note that we don't use the tab definitions from the autoshape, so this is an approximation)

  • Bug Fix. When exporting to bitmaps, the bitmaps where a little bigger than the page size

  • Bug Fix. Reports using LINQ could raise an Exception in some cases with null values.

  • Improved compatibility with invalid xlsx files generated by third parties. FlexCel can now read some invalid formulas written in xlsx by other third party products.

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, 2014 / Version: