0
我使用apache poi包来创建表示形状(区域,周长,质心)特征的数字电子表格。的问题是,我有一个方法:writeDatabase(),因为它们被发现,其输出的形状的特征,输出电子表格看起来像这样: http://s23.postimg.org/hqsfg76jv/Capture.png使用Apache POI在Excel中启动新行的问题
所有的这些数字需要在同一直线上,并那么下一条记录需要换行。该writeDatabase方法如下所示
public static void writeDatabase(int value, int cellNum){
try {
Cell cell1=null;
FileInputStream file = new FileInputStream(new File("features.xls"));
Workbook workbook = new HSSFWorkbook(file);
Sheet sheet = workbook.getSheetAt(0);
int lastRow = sheet.getPhysicalNumberOfRows();
cell1 = sheet.createRow(lastRow).createCell(cellNum);
cell1.setCellValue(value);
FileOutputStream outFile =new FileOutputStream(new File("features.xls"));
workbook.write(outFile);
outFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
我认为这个问题是与该行中的每个时间被调用,但我不能认为一个替代的: INT LASTROW = sheet.getPhysicalNumberOfRows();
任何想法?