Excel 95


I use ReadingFiles project from Demo examples for readign excel 95 file. File reading, but I see unreadable characters (hieroglyph) in cells with сyrillic characters. How i may fix this phoblem?


Can you email me a file with the problem to adrian@tmssoftware.com ?

Excel 95, different from newer Excels, uses a codepage instead of unicode to store the strings. FlexCel correctly handles the codepage, but xls95 files today are almost always created not by Excel 95, but by some third party tool, which might not set the codepage correctly in the file.

If I can see how the codepage is set in your file, we might be able to provide a workaround. 

Adrian, file sent. Subject of email: Excel 95 

Thanks, I got the file. Now, what do you see when you open this file in Excel?

I see the same as FlexCel shows:

And it would be as expected, since the file declares a "win1252" codepage (western codepage), and seems to be using cyrillic instead. I've end tried with a VM and setting it to a russian language, and it still displays the same. Maybe a cyrillic Excel version can show this different, but it would be an error since the file declares win1252, not cyrilllic.

As an extra note, this file also has wrong OLE headers, I am not sure on what we will do with this. FlexCel 6 includes an OLE validator to avoid malicious files to do unexpected things, and while it is not catching this case, it should. So probably next update won't even be able to open this file unless I find a way to ignore the wrong headers which is also safe from a security point of view and can't throw Excel or flexCel into infinite loops or memory corruption.

And a final note: By manually editing the file so it declares a win1251 codepage instead of 1252, both Excel and FlexCel will load it fine:

But as long as it says it uses 1252, it will show the wrong characters.

Thanks,  Adrian.

When I open this file in Excel (ms office 2010), i see readable characters, but in Reading Files unreadable characters. If resave file with Excel 2010 and reopen, Reading Files opened perfect.

May I know the codepage of opened file using FlexCel? 

May I reopen this file with know codepage?

I've tried it here with Excel XP, 2003 and 2007, and all of those show the unreadable characters. Maybe you have a cyrillic Excel version which is ignoring the codepage set in the file?

The thing is, you could define the code page if the file itself didn't declare it has a 1252 codepage. When FlexCel finds a codepage declared in the file, it gives it maximum priority because well, we believe the file. If it says it is codepage 1252, then it should be.

We could add another option "IgnoreCodePageInFile", but I don't like adding millions of options for corner cases, then the option will live forever and won't be of much use to nobody, it will just make the API more complex.

So before going that way, I would like to ask you: Do you have any control over the file, or do you have a way to make it write the correct codepage? This would also fix it for people like me opening the file in Excel and seeing it wrong.

I don`t have any control over the file, but I agree with you that " millions of options for corner cases, then the option will live forever...".

I make resave this file using Ole objects, but it is bad way in may case.

How i may know code page this file using Excel or different programs?

How i may know which  Excel version with ignoring the codepage or without it?

Let me check, I'll see if we can add a way to force the codepage so you can read this file. I'll write later when I figure out if there is a way.

Thank you, I'll wait impatiently.


Just to let you know that 6.1 will have a way to force the codepage when opening xls95 files. Note that still, for most '95 files you shouldn't force a codepage, since the codepage is embedded in the file. You only need to force a codepage if the file has the embedded codepage wrong, but this shouldn't happen often.

The way to force it would be to specify it in xls.Open, like this:
  MyEncoding: TEncoding;
  xls := TXlsFile.Create(true);
  MyEncoding := TEncoding.GetEncoding(1251); //or whatever encoding you know the file is in.
    xls.Open('Excel_95.xls', TFileFormats.Xls, ' ', 1, 1, nil, MyEncoding, false);
    xls.Save(zConsts.Write + '95encodingfixed.xls');

Luckily I could reuse an "Open" overload that was used to open text files, so I didn't had to add a new method to the API (which already has enough and doesn't need a new one just to deal with buggy files)

FlexCel 6.1 is being building right now, it should be available on TMS page some days from now.


Adrian, I try on as you told me but result remained the same.

may be the case in FlexCel version? I use 5.6.9.


This support was added in 6.1, which isn't available yet, but will be very soon now. Please retest once 6.1 is out.

Thank you, I'll wait impatiently new release.

Hi, Adrian!

It works  in 6.1.

Thanks a lot.