Template store load errors


Using the template store and having lots of problems where previously was no problem.
Every time we try to load a file from the template we get an error message.

'Error reading Excel records. File invalid'


'the file "" is invalid'

please advise


Are those apps migrated from FlexCel 2.6?   We did change the way TemplateStore works in 3.0, and in old applications you need to refresh the store, or maybe delete the files and readd them if you are still having issues.

But other than that there shouldn't be problems, I am not aware of any, and the new system is actually much simpler than the old so it should have less problems.

 In the old way, as we couldn't read an xls file from a stream, the template store had to save a lot of separated parts and the put them together when you opened the file in a very messy and complicated process. In the new way, we just store the full xls file in the store, and open it from a stream. 

Can you mail me an example of  case where you are having issues?

Hello I am using 3.4 and RAD studio 2010

Here is the standard code...


    for p:=1 to FlexCelImport.SheetCount do

the problem first appeared after I added about 4 or 5 files to template store.

I found I could fix the problem in two stages...

1. by putting an incorrect file name to load then when I run it the error would say correctly invalid
2. then when i changed it back to correct name it worked fine.

However I now have about 8 files and because of the problem I deleted all the files from the templete store then reloaded them.
Now whatever I try the error occurs when I try to load any file!

This is a real problem as now my application is completely broken.

I can't imagine what might be going wrong. I have just tried it here with lots of xls files, removing them and adding new ones, I have also reviewed the code, and I can't see any evident bugs. From the exception you are getting it looks like the stream gets corrupted (most likely truncated), but as said, the code for saving is quite simple (just dump the full stream into the form/datamodule, and read the full stream from the datamodule/form into memory).

I will keep investigating, but it is hard for me to say much more without more data. Is there a way I can see the .dfm file of the form or datamodule where the TemplateStore is?  Also, which delphi version are you using?

I have tried delleting the flexcel components and replacing them but I still run into this problem.
what's your email address?


Hello Adrian

I tracked down a problem piece of code / third party component that appears to be causing the issue, I am not sure why.

I run the code at the start of form creation and the flexcel load procedure after.

The component is 'Kryvich's Delphi Localizer'


The component is a localiser for language strings, so I am guessing its causing a change to the string.

It is strange that the problem has got worse over time, yet the code for flexcel loading has not changed.

Thanks for you help.

Yes, I guess a localizer could mess with the files, since what FlexCelStore does is to save the xls file as a Base64 binary string inside the dfm. If the localizer tries to localize that "data string", it will most likely become invalid.

I agree it is strange that you started having issues now since we haven't changed much, but maybe the localizer changed?