0
我是新来的Excel - Java(Apache POI),并试图找出一种方法将excel数据传输到文本文件。复制Excel数据到文本文件 - Java(POI)
我的Excel工作表看起来是这样的
name table latest_table Date
1 george table1 t459 2017-08-24
2 john table1 thi7 2017-07-23
3 mary table1 gdr99 2017-07-22
到目前为止我的代码
public static void excel_to_text(XSSFWorkbook wb) {
XSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
int cols = 0, tmp = 0;
XSSFRow row;
XSSFCell cell;
for(int i = 0; i < 10 || i < rows; i++) {
row = sheet.getRow(i);
if(row != null) {
tmp = sheet.getRow(i).getPhysicalNumberOfCells();
if(tmp > cols) cols = tmp;
}
}
for(int r = 0; r < rows; r++) {
row = sheet.getRow(r);
if(row != null) {
for(int c = 0; c < cols; c++) {
cell = row.getCell((short)c);
if(cell != null) {
*// code here*
}
}
}
}
}
任何帮助表示赞赏。
你的代码有什么问题? – 2017-08-24 15:51:51
文本文件应该如何显示?如果你的问题是关于如何将数据/字符串写入文件,请看这里: https://stackoverflow.com/questions/2885173/how-do-i-create-a-file-and-write-to- it-in-java – Piwo
如何存储数据,因为存在不同类型的数据。另外,有没有办法让文本文件看起来完全像表一样? – Chid