简单的java poi 导出
public class ExcelWriteTest {
String PATH = "E:\\Software\\software";
@Test
public void testWrite03() throws IOException {
//创建一个工作簿
Workbook workbook = new HSSFWorkbook();
//创建一个工作表
Sheet sheet = workbook.createSheet("测试表");
//创建第一行
Row row1 = sheet.createRow(0);
//创建第一个单元格,并设值(0,0)
Cell cell11 = row1.createCell(0);
cell11.setCellValue("今天天气");
//第一行第二个单元格((0,1)
Cell cell12 = row1.createCell(1);
cell12.setCellValue("晴朗");
//第二行
Row row2 = sheet.createRow(1);
//第二行第一个单元格(1,0)
Cell cell21 = row2.createCell(0);
cell21.setCellValue("今天心情");
//(1,1)
Cell cell22 = row2.createCell(1);
cell22.setCellValue("美滋滋");
//生成一张表(IO流)
FileOutputStream fileOutputStream = new FileOutputStream(PATH + "测试表.xls");
workbook.write(fileOutputStream);
//关闭流
fileOutputStream.close();
System.out.println("文件生成完毕");
}
}