Problem Saving Data in Russian language in XLS (UTF-8 Encoding)

Hi,


We are using Aspose Com Object within our PHP script to create an Excel File (XLS format) with the data from MYSQL DB (utf8) in Russian Language.
The fileName and the data within the Excel file created by Aspose is not correct. See attached the sample file. How can we set the encoding to UTF8 for XLS files?

Thanks & Regards,

Hi James,

Thanks for your posting and using Aspose.Cells.

When Workbook object is saved in XLS format, then no encoding is specified. It is saved like this.


//Create a workbook object

Workbook workbook = new Workbook();


//Save in XLS format

workbook.Save(“output.xls”, SaveFormat.Excel97To2003);


We also tried to enter some Russian text in cell A1 using the following code and it generated the correct XLS file without any issue. We have attached the output XLS file and screenshot showing MS-Excel displays the file at our end correctly.

C#

string russianText = “Это образец русской текст. Россия также девятое в мире по численности населения страна с 143 млн человек по состоянию на 2012 г. [11], простирающихся по всей полноте Северной Азии и большинстве стран Восточной Европы, Россия охватывает девять часовых поясов и включает в себя широкий спектр сред и рельефа. Eto obrazets russkoy tekst. Rossiya takzhe devyatoye v mire po chislennosti naseleniya strana s 143 mln chelovek po sostoyaniyu na 2012 g. [11], prostirayushchikhsya po vsey polnote Severnoy Azii i bol’shinstve stran Vostochnoy Yevropy, Rossiya okhvatyvayet devyat’ chasovykh poyasov i vklyuchayet v sebya shirokiy spektr sred i rel’yefa.”;


//Create a workbook object

Workbook workbook = new Workbook();


//Access the first worksheet

Worksheet worksheet = workbook.Worksheets[0];


//Enter russian text in cell A1

Cell cell = worksheet.Cells[“A1”];

cell.PutValue(russianText);


//Save in XLS format

workbook.Save(“output.xls”, SaveFormat.Excel97To2003);

Hi there,


Thanks for your response.

I have just run the same code with the Aspose COM library but with no luck. Please see attached the output file. The data is still not correct.

Could you please confirm the environment / regional settings etc you are running your code from?

We are using Aspose 7.3.1 on Windows 2008 R2 Server (Sp1) with Format (English-United States)

Thanks & Regards

Hi James,

Thanks for your feedback and using Aspose.Cells.

I have tested this issue on Windows 7 - 64 bit, English environment settings and also on Windows XP with English environment settings and was not able to replicate it.

I have attached the Windows 7 Environment settings for your reference.

I have also tested this issue with the Aspose.Cells for .NET v7.3.1 and with the latest version: Aspose.Cells
for .NET v8.1.2.4
. Give a try to latest version and see if it makes any difference.

It seems your string gets corrupted before it is entered into cell, so you should try to diagnose this issue in your COM environment and eliminate it.