Free Support Forum - aspose.com

Reading a CSV file

Hi,

I am trying to read a CSV file.It is giving me the following error at the line:

workbook.open("D:/sample.csv",FileFormatType.CSV);

java.io.UnsupportedEncodingException: GBK

at sun.io.Converters.getConverterClass(Unknown Source)

at sun.io.Converters.newConverter(Unknown Source)

at sun.io.ByteToCharConverter.getConverter(Unknown Source)

at sun.nio.cs.StreamDecoder$ConverterSD.(Unknown Source)

at sun.nio.cs.StreamDecoder$ConverterSD.(Unknown Source)

at sun.nio.cs.StreamDecoder.forInputStreamReader(Unknown Source)

at java.io.InputStreamReader.(Unknown Source)

at com.aspose.cells.dF.a(Unknown Source)

at com.aspose.cells.dF.a(Unknown Source)

at com.aspose.cells.Workbook.open(Unknown Source)

at com.aspose.cells.Workbook.open(Unknown Source)

Can anybody help me out with this?

Hi,

Thanks for considering Aspose.

Could you post your template csv file here, we will check it soon.

Thank you.

Ya i am attaching the file here

Hi,

Well I tested your template csv file and I don't find any error reading / adding values to the file.

Following is my testing code which works fine.

Workbook workbook = new Workbook();
workbook.open("e:\\Files\\sample.csv",FileFormatType.CSV);
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
// Access the "A10" cell in the sheet.
Cell cell = worksheet.getCells().getCell("A10");
cell.setValue("hello");
workbook.save("e:\\Files\\mycsv.csv",FileFormatType.CSV);

Which version of Aspose.Cells for Java you are using, Could you try the 1.9.4.10 latest fix attached @ the thread: <A href="</A> </P> <P>Thank you.<BR></P>

Yes I tried it but it is giving me the same error.

Hi,

Do you read / work with other excel files fine or you get the error. Could you give us some more details. What is your environment, which JDK version and OS you are using.

We will further investigate your issue.

Thank you.

Hi,

Please try this attached fix. When read the CSV file, if not specified the encoding of CSV file, we will take the system's default file encoding now. If the encoding of CSV file is not same with system's default encoding, please use open(String,char,boolean,String) in place of open(String,int) to specify its encoding.

Ya it works with the new version.Thank you.