使用Apache POI合并单元格在Excel中 [英] Merging cells in Excel using Apache POI

查看:246
本文介绍了使用Apache POI合并单元格在Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有合并使用Apache POI库细胞在Excel中任何其他方式?

我试着用以下,但它不工作

  //选择地区工作表合并数据
的CellRangeAddress区= CellRangeAddress.valueOf(A+ rowNo +:D
            + rowNo);

//合并区域
sheet1.addMergedRegion(区);
 

解决方案

您可以使用 sheet.addMergedRegion(rowFrom,rowTo,colFrom,colTo);

例如 sheet.addMergedRegion(新的CellRangeAddress(1,1,4,1)); 将从B2合并E2。请记住它是零的索引。

有关详细信息请参阅 BusyDeveloper指南

Is there any other way to merge cells in Excel using Apache POI library?

I was trying using the following, but its not working

// selecting the region in Worksheet for merging data
CellRangeAddress region = CellRangeAddress.valueOf("A" + rowNo + ":D"
            + rowNo);

// merging the region
sheet1.addMergedRegion(region);

解决方案

You can use sheet.addMergedRegion(rowFrom,rowTo,colFrom,colTo);

example sheet.addMergedRegion(new CellRangeAddress(1,1,4,1)); will merge from B2 to E2. Remember it is zero based indexing.

for detail refer BusyDeveloper's Guide

这篇关于使用Apache POI合并单元格在Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆