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

TMS FlexCel Studio for .NET 6.13.2.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.13.2.0 - February 2017

  • New method [[vcl T]]XlsFile.AddAutoShape to add autoshapes with the API. The new method allows you to add an autoshape to a file. As usual APIMate will provide you with the needed code.

  • Support for Visual Studio 2017 RC. Setup now installs in Visual Studio 2017.

  • Support for .NET Core 1.1. Project.json was changed to a csproj in order to build in 1.1.

  • Support for drawing mirrored images when rendering. Now when a bitmap is flipped vertically or horizontally, FlexCel will also draw it like this when exporting it.

  • New method TCellAddress.DecodeColumn. This method is provided for symmetry with the existing TCellAddress.EncodeColumn, but it is normally not required as you can use TCellAddress to get the full cell address string for a row and a column. This method could be used in the rare case you only wanted the column string and not the full cell address.

  • Breaking Change: Support for losslessly rotated JPEG images. Now when inserting JPEG images that are rotated via the "orientation" attribute in the JPEG file, FlexCel will automatically rotate the image so it appears with the desired orientation in Excel. Before FlexCel behaved as Excel 2010 or older, just entering the image as is, so Excel would show it rotated. Now it works like Excel 2013 or newer, where we rotate the image in Excel to compensate. All orientation values are supported, included mirrors. Note that this change might be breaking if you were manually rotating the images before entering so they would show fine. If you ware rotating the images manually, you should remove the code as now it will be done automatically. There is also a new method ImageUtils.GetJPEGOrientation which you can use to tell if a JPEG image is rotated or not.

  • Bug Fix. When autofitting a column which contained multiple lines but the cell was set to not wrap, FlexCel would consider that the cell could wrap and so end up with a smaller column width than needed.

  • Bug Fix. Xml declarations when writing custom xml parts could be duplicated.

  • Bug Fix. When replacing hyperlinks in a shape with a report there could be an exception.

  • Bug Fix. Support for reading xlsx files with custom properties with repeated names or empty names.

New on v 6.13.0.0 - January 2017

  • Support for rendering Right-To-Left sheets. Now FlexCel can export sheets where A1 is at the right side of the page and the cells grow to the left instead of to the right. A new property XlsFile.SheetIsRightToLeft allows you to read or write the right to left state of the sheet directly without needing to use SheetOptions. APIMate will now also suggest SheetIsRightToLeft instead of SheetOptions for RTL sheets.

  • Improved right to left support for text. Now FlexCel will support mixed right to left and left to right text more as the Unicode BIDI algorithm defines it. The Context property of the cell is now also used to figure out if it is rtl text embedded in ltr text or ltr text embedded in rtl text.

  • New static properties [[vcl T]]ExcelFile.CompressionLevel, [[vcl T]]FlexCelConfig.XlsxCompressionLevel and [[vcl T]]FlexCelConfig.PdfPngCompressionLevel. Properties ExcelFile.CompressionLevel and FlexCelConfig.XlsxCompressionLevel are the same and control the zip compression level used to creating xlsx files. FlexCelConfig.PdfPngCompressionLevel controls the compression level for pdn and png files. FlexCel uses "zcDefault" zlib compression level, which normally gives the best ratio between speed and size. But note that Excel itself uses zcFastest when saving xlsx files, resulting in faster saves but also bigger files. While you won't probably want to change the defaults, now you can. Note: We require .NET 4.5 or newer for this property to work.

  • New static property FlexCelConfig.DpiForReadingImages. This new property FlexCelConfig.DpiForReadingImages allows you to force a resolution in the images you are loading. Normally FlexCel will use the resolution stored in the images to calculate the desired width in inches, but now you can override whatever is saved in the file by changing this property.

  • New implementation of wildcard matching for all functions that use them. The new algorithm to match patterns like * or ? and used in functions like MATCH or COUNTIF is now much faster and can use much less memory in pathological cases.

  • New method FlexCelReport.Run(Stream templateStream, Stream outStream, TFileFormats fileFormat). This method allows you to specify the resulting file format when running a report to a stream.

  • Better handling of expressions or formats defined both in an included report and the master report. Now when an included report has the same expressions or formats defined in the config sheet as the master, those local definitions will be used, instead of raising an error of repeated formats/expressions.

  • Breaking Change: Better handling of image resolution in reports. Now when adding an image to a report and resizing it, FlexCel will take in account the image resolution if it is saved in the image. If the image doesn't have a resolution saved, FlexCel will use the screen resolution. You can revert to the old way of assuming a resolution of 96 dpi for all images by changing FlexCelConfig.DpiForReadingImages

  • Bug Fix. When exporting to HTML and a merged cell covered hidden rows or columns, the resulting html could be wrong.

  • Bug Fix. When exporting to HTML with embedded SVG images, the fill colors in the SVG images would be wrong if there were gradients.

  • Bug Fix. When exporting to SVG, text in controls or shapes could go a little lower than it should.

  • Bug Fix. The formula parser would fail to detect some unicode characters as valid characters for a sheet name or named range.

  • Better display of complex numeric formats. Now we handle some complex formatting the same as Excel does, handling also invalid formats which Excel doesn't allow better.

  • Bug Fix. Now FlexCel allows names with spaces as macro identifiers when loading files. While those aren't valid names and Excel won't let you enter them directly, you can enter them with VBA code, and FlexCel was refusing to read those files. Now FlexCel will open them correctly.

  • Bug Fix. In .NET Core we could fail to read formulas

  • Bug Fix. When a file had "Precision as displayed" set and there were cell formats including percentage signs, the numbers might be rounded wrong.

  • Bug Fix. There could be an stack overflow when a camera object rendered a range of cells which included the cells where the camera object was.

Write a Review

2 reviews

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

Perfect. It's very easy to use. And it also provides a good tool to help creating code - there is no need to spend more time to read the documents, just checking the created code is almost enough.

Posted on: July 9 / Version: 6.1.0.0
Dnyaneshwar Wadghane rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Great Component!

Posted on: November 16, 2016 / Version: 6.12.0