poi操作excel合并单元格,java合并excel单元格
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
/**
* @ClassName 类名:ExcelDemo6
* @Author作者: hzh
* @Date时间:2018/12/4 14:56
* 合并单元格
**/
public class ExcelDemo6 {
public static void main(String[] args) throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("hi sheet");
Row row = sheet.createRow(1);
Cell cell = row.createCell(1);
cell.setCellValue("测试合并单元格");
sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 3));
FileOutputStream fileOutputStream = new FileOutputStream("D://file//合并.xls");
wb.write(fileOutputStream);
wb.close();
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/my773962804/article/details/84879346
内容来源于网络,如有侵权,请联系作者删除!