Free Support Forum - aspose.com

Code page problem

Hi,

I have a .CSV file that contains French Characters.

The file was created:

Dim ecp862 As Encoding = Encoding.GetEncoding(1252)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

oTargetFile = New StreamWriter(hshArguments.Item("OUTFILE"), False, ecp862)

'French data written.

When I open using UltraEdit, it needs to have FORMAT as 1252 and "Open As" set to ASCII Escaped Unicode.

I am trying to load the file using ASPOSE.CELLS and save to EXCEL format.

Dim oDataWB As New Workbook("c:\Copy of 301-payroll-retro-list_20130509_047476495.csv")

oDataWB.Save("c:\BeforeData.xls", SaveFormat.Xls)

The code above results in a spreadsheet that has weird characters in place of the French characters.

I can't seem to find out how to set the encoding. I could use a StreamReader, however the WORKBOOK function needs either a filename/path or a FILESTREAM.

Can you provide any suggestions?

Thanks

Bill McClenny

Hi,


Well, you may try specifying the Encoding using TxtLoadOptions when loading your CSV file, see the following sample code, e.g

TxtLoadOptions txtLoadOptions = new TxtLoadOptions(LoadFormat.CSV);
txtLoadOptions.Encoding = Encoding.ASCII;

Workbook workbook = new Workbook(“myfile.csv”, txtLoadOptions);

Let us know if you still find the issue.

Thanks, you pointed me in the right direction.

The solution is:

Dim txtLoadOptions As TxtLoadOptions = New TxtLoadOptions(LoadFormat.CSV)

txtLoadOptions.Encoding = Encoding.GetEncoding(1252)

Dim oDataWB As Workbook = New Aspose.Cells.Workbook(sDataFileName, txtLoadOptions)

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We are pleased to know that you found the solution to your mentioned problem. If you encounter any other issue, please feel free to post, we will be glad to help you further.