0
我想修改一個excel文件。我無法做到這一點。 我做了一些計算並得到答案。我想將該答案存儲在excel文件中。再次打開它,存儲並保存。在Excel文件中修改文本
但是,在這裏,我無法做到這一點。 每當我得到一個值,我想在Excel中存儲該值,然後再打開並存儲它。
static int count=0;
public static void main(String[] args)
{
try {
for(int i=0;i<5;i++)
update(i);
} catch (Exception e) {
}
}
public static void update(int i) throws BiffException, IOException, RowsExceededException, WriteException
{
count++;
Workbook existingWorkbook = Workbook.getWorkbook(new File("try.xls"));
WritableWorkbook workbookCopy = Workbook.createWorkbook(new File("try2.xls"), existingWorkbook);
WritableSheet sheetToEdit = workbookCopy.getSheet(0);
Label l = new Label(4, count, String.valueOf(i));
sheetToEdit.addCell(l);
workbookCopy.write();
workbookCopy.close();
existingWorkbook.close();
}