关于java生成Excel文件时合并单元格出现的问题

_超级赛亚人_ 2011-04-15 08:34:26
在用java生成Excel中合并单元格时代码如下:(截取出去Warning的部分)
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
ws.addCell(new Label(j, i, "标题", center));
}
}
ws.mergeCells(0, 0, 10, 3);// 合并单元格

for (int i = 0; i < 11; i++) {
if (i < 7) {
ws.addCell(new Label(i, 4, "", center));
} else {
ws.addCell(new Label(i, 4, "学位办公室制", center));
}
}
ws.mergeCells(7, 4, 10, 4);
但是会有这样的Warning:
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-K4 contains more than one data cell. Setting the other cells to blank.
Warning: Range H5-K5 contains more than one data cell. Setting the other cells to blank.
Warning: Range H5-K5 contains more than one data cell. Setting the other cells to blank.
Warning: Range H5-K5 contains more than one data cell. Setting the other cells to blank.
求解!!!
...全文
1187 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
_超级赛亚人_ 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 kai27ks 的回复:]
在用java生成Excel中合并单元格时代码如下:(截取出去Warning的部分)
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
ws.addCell(new Label(j, i, "标题", center));
}
}
i从0到3,j从0到9.一共也才4*10=40
[/Quote]
恩。。那个是得改成9
但是我刚才试了下。。为什么我在空白Excel里面合并两个单元格的时候也会出现那个警告
怎么在合并之后把覆盖的单元格置成blank
kai27ks 2011-04-15
  • 打赏
  • 举报
回复
在用java生成Excel中合并单元格时代码如下:(截取出去Warning的部分)
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
ws.addCell(new Label(j, i, "标题", center));
}
}
i从0到3,j从0到9.一共也才4*10=40
kai27ks 2011-04-15
  • 打赏
  • 举报
回复
4行11列?那就是问题所在了。。。 你生成的一共才4行10列啊!!
_超级赛亚人_ 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 kai27ks 的回复:]
警告:有超过一列的数据列,将其它的(未处理的)数据列设置为空。
解释下这句:ws.mergeCells(0, 0, 10, 3);
我好给你检查下。
[/Quote]
将第0列0行对应的单元格 到 10列3行对应的单元格合并
也就是说将总共4行行11列的单元格合并
kai27ks 2011-04-15
  • 打赏
  • 举报
回复
警告:有超过一列的数据列,将其它的(未处理的)数据列设置为空。
解释下这句:ws.mergeCells(0, 0, 10, 3);
我好给你检查下。
kai27ks 2011-04-15
  • 打赏
  • 举报
回复
不兼容你的IE版本啊。你查看下插件说明。针对哪些浏览器有效。IE也有分版本的 例如IE6,7,8
_超级赛亚人_ 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 kai27ks 的回复:]
坦白说这个类我没用过。你可以找下它的API
[/Quote]
还是谢谢你哈。。。我重新用POI插件做了。。但是上面的问题还是没解决。。

再有就是:请问下导出(Excel或则dbf文件)我在火狐下都好使,但是在IE下就是不弹出保存框,后台也不报错,请问怎么解决
kai27ks 2011-04-15
  • 打赏
  • 举报
回复
坦白说这个类我没用过。你可以找下它的API

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧