【发布时间】:2018-07-10 17:50:55
【问题描述】:
我正在尝试使用 apache poi 在 java 中编写一个 excel 文件。我想以 csv 逗号分隔我的 excel 文件格式。我该怎么做 ? 这是我现在正在使用的代码 -
public class ReadRfdsDump {
public void readRfdsDump()
{
try
{
FileInputStream file = new FileInputStream(new File("C:\\Users\\esatnir\\Videos\\sprint\\sprintvision.sprint.com_Trackor Browser_RF Design Sheet_07062018122740.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
DataFormatter df = new DataFormatter();
for(int i=0;i<2;i++)
{
Row row= sheet.getRow(i);
System.out.println(df.formatCellValue(row.getCell(1)));
}
try {
FileOutputStream out = new FileOutputStream(new File("C:\\CQ ADD\\Write CQ File\\"+s+".csv"));
workbook.write(out);
out.close();
System.out.println("Excel has been written successfully on disk.");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
我正在使用 .csv 编写 excel 文件,但我不知道它是否是 csv 的正确格式(逗号分隔)?或者我如何以 .csv(逗号分隔)格式编写 excel 文件??
【问题讨论】:
标签: java excel string collections apache-poi