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.5.0.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.5.0.0

  • PDF/A support. FlexCel can now export to PDF/A-1, PDF/A-2 and PDF/A-3 files. A new property FlexCelPdfExport.PdfType determines if the file is a standard PDF or the version of PDF/A.

  • Xamarin Unified API Support. FlexCel now includes two new dlls compiled against Xamain.Mac.dll and Xamarin.iOS.dll instead of XamMac.dll and monotouch.dll, in order to support the new Unified API ( http://developer.xamarin.com/guides/cross-platform/macios/newstyle/ ) This means you can now compile 64 bit iOS and OSX applications with FlexCel.

  • Breaking Change: Generated PDF files are now tagged by default. The files generated by FlexCel are now tagged by default, as tagging is an accessibility requirement. Tagged PDF files are bigger than normal files so in order to try to get smaller files FlexCel uses now features available only in Acrobat 7 or newer. To go back to generating untagged files you can set FlexCelPdfExport.TaggedPdf = false. To go back to creating files compatible with Acrobat 5 or newer, set FlexCelPdfExport.PdfVersion = TPdfVersion.v14

  • Breaking Change: Generated PDF files are now compatible with Acrobat 7 or newer. In order to reduce the size of the tagged pdf files that FlexCel now creates by default, FlexCel now generates files that need Acrobat 7 or newer to open. To go back to creating files compatible with Acrobat 5 or newer, set FlexCelPdfExport.PdfVersion = TPdfVersion.v14. Note that as PDF/A-1 requires compatibility with Acrobat 5 or newer, when exporting PDF/A-1 FlexCel will use v14 automatically. PDF/A-2 and 3 don't require v14, so it isn't used by default for those formats.

  • Breaking Change: Generated PDF files now embed the fonts by default. Now the default value of FontEmbed in FlexCelPdfExport and PdfWriter is TFontEmbed.Embed. While this will create slightly bigger files, they will show fine everywhere, including mobile devices which might not have the fonts. You can revert to the old behavior by changing FontEmbed to be TFontEmbed.None.

  • Breaking Change: FlexCel will throw an Exception when trying to embed a font that doesn't have a license allowing embedding. FlexCel will now check that the embedded fonts in PDF have a license that allows embedding. You can revert to the old behavior by setting UnlicensedFontAction = TUnlicensedFontAction.Ignore, in case you have an agreement with the Font author. You can also set UnlicensedFontAction = TUnlicensedFontAction.Replace to replace the unlicensed fonts with a fallback font. FlexCelTrace will alert when replacing or ignoring a font that is not licensed.

  • Ability to embed files inside the PDF. Now you can embed arbitrary files inside the pdf. This allows for example to ship the original xls/x file inside the pdf. This is supported also in PDF/A-3.

  • Ability to set the language of the PDF files. You can now set a FlexCelPdfExport.Properties.Language to specify the language of the generated PDF file. Note that the language will be used by text-to-speech engines to read text out loud, so it is recommended to set this property.

  • PDF properties are now saved in XMP format. PDF properties (like Author, Title, etc.) are now saved in XMP xml format besides the PDF format. XMP is a requirement for PDF/A, and allows other tools that don't understand PDF to read the metadata. Note that the files generated by FlexCel will be now a little bigger due to this metadata, because it can't be compressed.

  • Ability to embed a Color Profile inside the generated pdf files. You can now set a FlexCelPdfExport.EmbedColorProfile property to embed a color profile in the generated files. Note that as a color profile isn't required and it increases the size of the generated files, this option is false by default. But as it is required by PDF/A, a color profile will be embedded in PDF/A files.

  • Breaking Change: Now if you don't specify properties for pdf files in FlexCelPdfExport (like Author, Title, etc.), those will be read from the Excel file being exported. If you want to revert to the old behavior, you can set UseExcelProperties = false in FlexCelPdfExport.

  • New structure StandardMimeType returns the mime types for xls, xlsx, xlsm, pdf, etc. You can use StandardMimeType where you need to specify a mime type for a file generated with FlexCel, instead of having to manually search for the type.

  • Support for <#DBValue> tag in LINQ Reports. DBValue used to work only with datasets, now you can use it also with LINQ data providers like arrays or lists.

  • Breaking Change: VirtualDataTable doesn't have the MoveToRecord virtual method anymore, and instead it has a new GetValue(row, column). In order to provide an efficient support for dbvalue in LINQ reports, we needed to change the way to move to a random record. So we don't use MoveToRecord anymore an use GetValue(row, column) instead. This change is unlikely to affect you, unless you are writing your own VirtualDataTable descendent. If you are, then the compiler will point at the missing method implementation.

  • Improved Search and Replace. Now FlexCel preserves better the format of the cells being replaced. A new overload of XlsFile.Replace allows you to specify the format or the values of the replaced cells in a cell by cell basis.

  • Support for entering names referring to other files using Excel notation. A normal reference to another file has the filename inside brackets, like "[file1.xlsx]Sheet1!A1". But in the case of global names, Excel uses the notation "file1.xlsx!name1", without brackets, which makes it impossible to know if you are entering a name reference to another file (file1.xlsx) or a name reference to the same file, in a sheet named file1.xlsx. FlexCel didn't allow this way to specify the names, and it used to ask for brackets always so you would have to write [file1.xlsx]!name1 to enter the name. Now you can use the same notation as Excel, and FlexCel will allow it as long as you setup a TWorkbook before which includes file1.xlsx.

  • New constructor for XlsFile allows to specify the Excel version in one step. Now you can create a new file in for example Excel 2010 file format by writing XlsFile xls = new XlsFile(1, TExcelFileFormat.v2010, true); in C# or xls := XlsFile.Create(1, TExcelFileFormat.v2010, true); in Delphi.

  • New enumeration TExcelFieFormat.v2013. We now provide an specific TExcelFileFormat.v2013 enumeration to create Excel2013 files.

  • Support for format strings that specify fractions. Now when using a format string like "??/??" the numbers will be displayed as fractions. For example 0.75 will show as 3/4. All Excel formats for fractions are fully supported.

  • iOS and OS/X previewer compatibility improved. Some xlsx files generated by FlexCel that wouldn't show in iOS/OSX previewer will display now. Xlsx charts now update their caches so the previewer will show them correctly.

  • TFlxApplyFont as a new StyleEx property that allows for fine control of which styles are applied. Before this release you could only apply the full style of the font or nothing by changing the Style property. Now you can specify individual styles like bold or italics by changing the StyleEx property.

  • XlsFile.Sort does a stable sort. Now when you sort a range of cells, order will be preserved for items with the same values.

  • Shapes inside charts are now preserved in xlsx files.. Now xlsx charts will preserve the shapes inside.

  • Bug Fix. Local named ranges could lose their sheet when inserting sheets from other file.

  • Ability to preserve modification date in xlsx files. By default, FlexCel will set the modification date to the date the file was saved. But if you are modifying an existing file and want to preserve the original creation date, you can now do it by setting XlsFile.DocumentProperties.PreserveCreationDate to true.

  • Better support for Excel 4.0 macro sheets. Files with Excel 4.0 macros should load better.

  • Bug Fix. XlsFile.Replace might not keep existing cell formats when replacing dates.

  • Bug Fix. Chart.DeleteSeries could break the format of the remaining series when called in a serie at the middle of the chart.

  • Bug Fix. There could be an exception when deleting some ranges of cells with hyperlinks.

  • Bug Fix. Negative dates when in 1904 mode used to display as ####. Now they display as in Excel (see http://support.microsoft.com/kb/182247 ). Note that this is not a logical way to display dates, that is -1 doesn't mean 12/31/1903, but it means "-1/2/1904". Negative dates actually increase as the number get smaller.

  • Support for UTF16 surrogates when exporting to pdf. Now when exporting to pdf, FlexCel will correctly display UTF16 surrogates. FlexCel already was surrogate-aware in the rest of the codebase.

  • Support for space (" ") named styles. While Excel won't let you enter a cell style named " ", it will allow you to use it if you manually edit an xlsx file and create it there. To be able to deal with those files, FlexCel will now support reading and writing styles named with a space.

  • Now when adding controls with linked cells, the linked cells will be modified to match the initial value of the control. Now when adding comboboxes, listboxes or checkboxes linked to a cell, the cell will be modified to match. Note that the change applies to newly created objects, if you change the value of an existing control, the linked cell was always updated in all FlexCel versions that supported changing control states.

  • Bug Fix. Some xlsx files with charts could enter an infinite loop when loading.

  • Bug Fix. When replacing rich strings, the rtf runs could be wrong in border cases.

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: 6.1.0.0