0
我正在使用Java和opencsv(2.3)创建csv文件。opencsv内容 - 逗号后的值
正确创建。但是当我打开文件时,我看到所有数据都出现在单列中。
为了在Excel
的数据标签的值对准到单独的列1.I选择“文本到列”
2.And我选择分隔符为“;”
- 我看到所有的值被分裂成正常separte列,但逗号后的值越来越消失
CSVWriter我用它来创建CSV文件:
File file = new File(fileName);
CSVWriter writer = new CSVWriter(new FileWriter(fileName, true), ';');
String[] col= new String[4];
for(Customer c : CustomerList) {
col[0] = c.getCustomerName();
col[1] = c.getCustomerId();
col[2] = c.getCustomerBirthDate();
col[3] = c.getRegFee(); /** 145,65**/
col[4] = c.getRegPlace();
writer.writeNext(col);
}
writer.close();
CSV文件 - 实际内容:
"Micky";"1";"19901220";"455,56";"Place1"
"Grace";"2";"199";"465,87";"Place2"
CSV文件 - 在使用Excel中打开:
"Micky";"1";"19901220";"455" // , 56 and Place1 are vanished
"Grace";"2";"199";"465" // , 87 and Place2 are vanished
不,我选择分号作为分隔符,可以将其与被链接数字格式,我的意思是千位和小数点分隔符? –
@AlagammalP我不这么认为。我将Excel配置为使用千位分隔符和逗号作为小数点分隔符。我仍然有和上面截图一样的结果。 –