I am new to Excel - Java (Apache POI) and trying to figure out a way to transfer excel data to a text file.
My excel sheet looks something like this
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
My Code so far
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*
}
}
}
}
}
Any help is appreciated.