//使用FileWriter导出为CSV的Java代码。
Java Code :
FileWriter fileWriterForCsv;
fileWriterForCsv.append(4.500);
fileWriterForCsv.append(",");
fileWriterForCsv.append("Mani");
fileWriterForCsv.append(",");
fileWriterForCsv.append("March");
//导出的CSV文件的内容如下所述 生成的CSV ______________
Actual Result : 4.5,Mani,March
Expected Result : 4.500,Mani,March
Please let me know whether i need to change the java code?? or how to proceed to get the expected result as above mentioned
还尝试将列类型更改为CSV模板中的文本。没有得到预期的结果。
答案 0 :(得分:0)
尝试格式化数字输出。这应该在最后用CRLF写出整行。
fileWriterForCsv.format("%.3f,%s,%s%n", 4.5, "Mani", "March");