import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class excelWrite { public static void main(String[] args) throws IOException, InvalidFormatException { //创建路径 File testFile = new File("/Users/liuxiangru/Desktop/testa.xlsx"); //创建输出流 FileOutputStream fileOutputStream = new FileOutputStream(testFile); //创建工作薄 HSSFWorkbook xssfWorkbook=new HSSFWorkbook(); //创建Sheet页->创建Row->创建cell->填写单元格内容 xssfWorkbook.createSheet("one") .createRow(0).createCell(0) .setCellValue("age=18"); //把excel工作簿写入硬盘 xssfWorkbook.write(fileOutputStream); fileOutputStream.flush(); fileOutputStream.close(); } }
poi 创建excel表格->简单实现
最新推荐文章于 2023-10-24 14:16:51 发布