We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Doesn't recognise character (display hex question mark instead)

Hi !
Tried a simple functionality: Load a csv file into a workbook and save it. Code:

string csvData = pathToTemp + “rep_data.csv”;
Workbook workbook = new Workbook(csvData);
sNewReport = pathToTemp + “LM5.xlsx”;

There are 2 characters that are displaying as question marks (normal windows message for unknown chars). Attach below print screen with chars and the data file (csv)
Character_Issue.PNG (39.3 KB)
rep_data.zip (1.3 KB)

@Remus87,

You need to specify proper encoding type when loading the CSV file via Aspose.Cells APIs. You may simply try using the following sample code, it will work fine as I tested.
e.g.
Sample code:

TxtLoadOptions opts = new TxtLoadOptions(LoadFormat.Csv);
opts.Encoding = System.Text.Encoding.Default;
Workbook workbook = new Workbook("e:\\test2\\rep_data.csv", opts);

workbook.Save("e:\\test2\\out1.xlsx", SaveFormat.Xlsx);

Let us know if you still find any issue.

@Remus87

The encoding of your source csv file is cp1252. Please try the following code:

TxtLoadOptions opts = new TxtLoadOptions(LoadFormat.Csv);
opts.Encoding = System.Text.Encoding.GetEncoding(1252);
Workbook workbook = new Workbook("e:\\test2\\rep_data.csv", opts);

workbook.Save("e:\\test2\\out1.xlsx", SaveFormat.Xlsx);

Thank you! That fixed the issue.

@Remus87,

Good to know that the suggested code segments work for your needs. In the event of further queries or issue, feel free to write us back.