Free Support Forum - aspose.com

Double quotes and when exporting as CSV continued

Hi I originally posted this item:

https://forum.aspose.com/t/104722

I appreciate the quick turn around.

One issue that we noticed is if the excel cell is empty, it will not populate the csv entry as “” as expected.

Instead of , it would be preferable to get “”,"","",""

Would it be possible to get this to work in this manner?

Thanks,

Chris

Hi,

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

We were able to observe this issue, please see the following screenshot for your reference.

However, please provide us your sample source files (csv, xls/xlsx) etc and the runnable sample code replicating this issue as you have described above.

We will soon look into this issue and help you asap.

I have also attached the source file and output csv file. Below is sample test code.

Java


Workbook workbook = new Workbook(“BaseSheet1.xlsx”);

WorksheetCollection worksheets = workbook.getWorksheets();


TxtSaveOptions opts = new TxtSaveOptions(SaveFormat.CSV);

opts.setSeparator(’#’);


opts.setAlwaysQuoted(true);


worksheets.setActiveSheetIndex(0);


workbook.save(“mycsvfile.csv”, opts);

Screenshot:

Code:
Workbook workbook = new Workbook();
workbook.open(inStream);
outStream = new ByteArrayOutputStream();
WorksheetCollection worksheets = workbook.getWorksheets();
TxtSaveOptions opts = new TxtSaveOptions(FileFormatType.CSV);
opts.setSeparator(’#’);

opts.setAlwaysQuoted(true);
worksheets.setActiveSheetIndex(0);
workbook.save(outStream, opts);

Input Excel:
Attached

Output CSV:
“CONTACT_ID”#“CONTACT_FIRST_NAME”#“CONTACT_LAST_NAME”
“1”#“WHO”#“CARES”
“2”#""#“I”
“3”#“REALLY”#"DON’T"

Thanks again,

Chris

Hi,

Thanks for your sample code.

We have logged this issue in our database. We will look into it and implement it. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40337.

Hi,

Any update on this?

Thanks,

Chris

Hi,

Thanks for your posting and using Aspose.Cells.

I am afraid, there is no update for you at this moment.

We will look into and fix your issue in coming week. Once, there is some progress related to your issue, we will let you know.

Also, we have added your comments against the issue id: CELLSJAVA-40337 so that it could be fixed earlier.

Hi,

Thanks for using Aspose.Cells for Java.

We are working over this issue. We will include it in our new fix (v7.3.2.2) that is scheduled to be released in next few (1~3) working days.

Hi,

Thanks for using Aspose.Cells for Java.

We have supported to quote empty cell values when exporting csv file with TxtValueQuoteType.ALWAYS option.

Please download and try the new fix:
Aspose.Cells for Java (Latest Version)


Java


TxtSaveOptions saveOpt = new TxtSaveOptions();

saveOpt.setSeparator(’#’);

saveOpt.setQuoteType(TxtValueQuoteType.ALWAYS);

workbook.save(…, saveOpt);