POI Excel 模板往固定位置插入内容

话不多说上代码
依赖

<dependency>
	<!-- LEVEL-PLT:操作EXCEL所需要的包 -->
	<groupId>org.apache.poi</groupId>
	<artifactId>poi</artifactId>
	<version>3.13</version>
</dependency>
<dependency>
	<!-- LEVEL-PLT:提供对office的word,excel,visio,ppt的操作 -->
	<groupId>org.apache.poi</groupId>
	<artifactId>poi-ooxml</artifactId>
	<version>3.13</version>
</dependency>

代码

 public static void createExcel(VBqDocumentPlan plan, VActWfWnProcess wnProcess, String tempFilePath, String outPath) {
   

	try {
   
		// excel模板路径
		File fi = new File(tempFilePath);
		InputStream in = new FileInputStream(fi);
		// 读取excel模板
		XSSFWorkbook wb = new XSSFWorkbook(in);
		// 读取了模板内所有sheet内容
		XSSFSheet sheet = wb.getSheetAt(0);
		// 如果这行没有了,整个公式都不会有自动计算的效果的
		sheet.setForceFormulaRecalculation(true);

		// 在相应的单元格进行赋值
		XSSFCell cell = sheet.getRow(2).getCell(4);// 所属部门
		if (NullUtil.isNotNull(plan.getRespDeptName())) {
   
			cell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值