public class ExcelTest {
/**
* @param args
* @throws IOException
* @throws BiffException
* @throws WriteException
*/
public static void main(String[] args) throws IOException, BiffException, WriteException {
Workbook wb = null;
WritableWorkbook wwb = null;
try {
wb = Workbook.getWorkbook(new File("src\\jxlrwtest.xls"));
wwb = Workbook.createWorkbook(new File("src\\jxlrwtest.xls"),wb); // 在原有工作簿jxlrwtest.xls上追加数据
if (wb != null && wwb != null) {
WritableSheet sheet = wwb.getSheet(0);
WritableCell cell = sheet.getWritableCell(0, 0); // 修改第一页的第一行第一列数据
if (cell.getType() == CellType.LABEL) {
Label l = (Label) cell;
l.setString("modified cell2353"); // 设置数据
}
wwb.write();
System.out.println("工作簿写入数据成功!");
}
wwb.close();// 关闭
} catch (Exception e) {
e.printStackTrace();
} finally {
wb.close();
}
}
}