一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 

一、引入包

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.0.0</version>
</dependency>

二、代码

public class TestTable {
    public static void main(String[] args) throws IOException {
        String path = "F:\\web\\vue-ts\\back_web_page\\public/workTable.xlsx";
        FileInputStream fileInputStream = new FileInputStream(path);
        XSSFWorkbook excel = new XSSFWorkbook(fileInputStream);
        fileInputStream.close();
        XSSFSheet sheet = excel.getSheetAt(0);

        sheet.getRow(0).getCell(0).setCellValue(30);
        sheet.getRow(1).getCell(0).setCellValue(30);

        FileOutputStream fileOutputStream = new FileOutputStream(path);
        excel.write(fileOutputStream);
        fileOutputStream.close();
        excel.close();
    }
}

三、注意

编辑后的excel需要【公式 -> 重算工作簿】

 

posted on 2021-10-12 00:08  一路繁花似锦绣前程  阅读(329)  评论(0编辑  收藏  举报