使用Apache POI合并单元格在Excel中

编程入门 行业动态 更新时间:2024-10-15 14:14:01
本文介绍了使用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中

本文发布于:2023-11-30 08:54:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   Apache   POI   Excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!