如何使用Java POI生成Excel表文件
1个回答
展开全部
1234567891011121314151617181920212223242526272829 private static void WriteExcel2010() throws IOException { String path="C:\\poi2.xlsx"; XSSFWorkbook workbook=new XSSFWorkbook(); XSSFSheet sheet=workbook.createSheet("我的Sheet"); XSSFRow row=sheet.createRow(0); XSSFCell cell=row.createCell(0); cell.setCellValue("我是POI写入的"); XSSFRow row1=sheet.createRow(1); XSSFCell cell1=row1.createCell(0); cell1.setCellValue("2010"); FileOutputStream outputStream=new FileOutputStream(path); workbook.write(outputStream); outputStream.close(); } private static void WriteExcel2003() throws IOException { String path="C:\\poi2.xls"; HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet sheet=workbook.createSheet("我的Excel"); HSSFRow row=sheet.createRow(0); HSSFCell cell=row.createCell(0); cell.setCellValue("我是POI写入的"); FileOutputStream outputStream=new FileOutputStream(path); workbook.write(outputStream); outputStream.close(); }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询