poi操作excel入门

poi是apache的一个开源框架,用来操作excel,先写一个简单易用的demo,后续会跟上详细介绍

    

public static void main(String[] args) throws IOException {
		//创建文件流
		FileOutputStream fileOutputStream = new FileOutputStream(new File("D:/workbook.xlsx"));
		//创建工作簿
		XSSFWorkbook sheets = new XSSFWorkbook();
		//创建表格
		XSSFSheet sheet = sheets.createSheet("sheetname");
		//创建行
		XSSFRow row = sheet.createRow(0);
		//创建列
		XSSFCell cell = row.createCell(0);
		//向列中写入数据
		cell.setCellValue("successful");
		//将工作簿中的内容写入文件
		sheets.write(fileOutputStream);
		fileOutputStream.close();
		sheets.close();
	}

猜你喜欢

转载自blog.csdn.net/weixin_39841589/article/details/82626869