您的位置:首页 > 编程语言 > Java开发

java 使用poi写入已存在的文档

2013-07-29 20:19 465 查看
下载地址:
http://poi.apache.org/download.html#POI-3.9
Binary Distribution:

poi-bin-3.9-20121203.zip

使用两个jar包:poi-ooxml-3.9-20121203.jar, poi-3.9-20121203.jar

    InputStream inp = new FileInputStream("wb.xls");

    WorkbookFactory WorkbookFactory=new WorkbookFactory();

    Workbook wb =
WorkbookFactory.create(inp);

    Sheet sheet = wb.getSheetAt(0);

    Row row = sheet.createRow((short)6);

    row.createCell(0).setCellValue(1.1);

    row.createCell(1).setCellValue(new Date());

    row.createCell(2).setCellValue(Calendar.getInstance());

    row.createCell(3).setCellValue("a string");

    row.createCell(4).setCellValue(true);

    row.createCell(5).setCellType(Cell.CELL_TYPE_ERROR);

    FileOutputStream fileOut =
new FileOutputStream("wb.xls");

    wb.write(fileOut);

    fileOut.close();

原文地址:http://stackoverflow.com/questions/521274/edit-existing-excel-files-using-jxl-api-apache-poi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Java poi