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

TMS FlexCel Studio for .NET 6.12.0

tmssoftware.com

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.

Example:

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

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.

Example:

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.

Example:

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 6.12.0.0

  • Improved compatibility with Windows Phone devices. Some windows 8.1 devices have a bug that doesn't let them read resource files (resx). This means that FlexCel would fail when deployed to those devices, even if it would work in the simulator. To fix it, now FlexCel for Windows Phone and Windows RT doesn't use resource files.

  • Improved performance when creating tens of thousands of names in a file. Now when creating a file with tens of thousands of names FlexCel will be much faster.

  • Breaking Change: Bug Fix. In xls files, setting SheetProtection.Scenarios and SheetProtection.Objects had the reverse effect as in xlsx files. Now xls files behave the same as xlsx files. If you are changing the protection of xls files, review the calls to SheetProtectionOptions.Objects and SheetProtectionOptions.Scenarios as they might be reversed. If you are saving as xlsx files, then there is no need to change anything, as xlsx already worked as expected.

  • Better drawing of labels in charts. Now the labels inside charts draw more like Excel when exporting xls files to pdf or html. If multiple labels would overlap, now FlexCel tries to separate them. The leader lines in pie charts from the slices to the legends render better too.

  • APIMate will now suggest to use [[net new TSheetProtection]][vcl TSheetProtection.Create] instead of [[net new TSheetProtection]][vcl TSheetProtection.Create]. The constructors using true and false can be confusing, because while they work, they will set all the protection to true and false, and some protections work when the property is true (contents, objects and scenarios) while the others work when the property is false (all the other properties). The constructors using TProtectionType will set some values to true and some to false as needed to have all the sheet protected or unprotected.

  • Bug Fix. When copying sheets in a file, some conditional formats could raise a null reference exception.

  • Improved compatibility with third party created files. Specifically, we now can read spreadsheets created with google docs which contain pivot tables. Those generate invalid xlsx files lacking required attributes, and FlexCel would complain about them missing. Now it will ignore them, and fix the files if you open and save them in FlexCel.

Write a Review

2 reviews

Dnyaneshwar Wadghane rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Great Component!

Posted on: November 16 / Version: 6.12.0
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: 6.1.0.0