Exe size

I want to read csv files and xls and xlsx files. When I add VCL.FlexCel.Core, FlexCel.XlsAdapter to my uses clause and write

  FXLS: TExcelFile;
  FXLS := TXlsFile.Create(False);

my executable size increases from 17.5 MB to 20.5 MB. Is this to be expected?




Yes, this can be expected.The thing is, when you instantiate a TXlsFile object, you are embedding a mini-excel into your application. Even if you are only going to read simple files, we can't know if for example the xls/x file you are reading will contain say a =PPmt(...) function, so we need to have support for over 300 functions that your file might contain, and we need to be able to recalculate them. So the full recalculation engine is included. Same for the features in the xls/x file: Maybe you are never going to read a chart, but we can't know that when you create a TXlsFile object that you are never going to read charts, so the full chart engine is included too. Same for xlsx or csv, maybe you are only going to read xls files, but we don't know it, so the csv and xlsx engines need to be linked too. (and our own optimized xmlreader, xmlswriter and zip classes, to support xlsx). OR the encryption engine, maybe you are never going to read or write encrypted xls or xlsx files, but we can't know it, so the encryption engine is linked in the exe too.
A lot of stuff needs to be included, because we can't know if that stuff will be in the files you are trying to read or not. FlexCel 3 didn't support recalculatio or xlsx or encryption, so it could be smaller, but FlexCel 6 supports that all and more.

Besides the really big number of features we need to support because they might be in the files, there is also a problem with the Delphi compiler not optimizing enough, but we have tried to reduce that to the minimum. For example we use a lot of generics, and in Delphi generics can produce an incredible bloat (this being the reason why exe files get bigger in each delphi version, each delphi version replaces more and more TLists by TList<T>. This is also the reason FireMonkey is so big). But in our case, we have implemented our own lightweight generic classes, so we use our own TuList <T> instead of the default TList<T>. Our own classes are not only faster than the ones in Delphi, but they are also much smaller, and implement folding: Folding means that all list and dictionaries of objects share the same implementation and don't bloat the code, as the built in delphi classes do. 

We've put a lot of effort in making FlexCel as small as possible, and I think we've arrived to a good compromise. 3mb extra in your exe isn't that much for all the functionality built in, and it is much less than the about 8mb that the earlier FlexCel 5 version added, before we spent a lot of time making it as small as we could make it. And much less than the 1gb Excel itself uses if you install it. And most of those 3mb are actually needed functionality, not generics/rtti bloat as it used to be before we implemented our own containers.

Thanks Adrian.