WritableWorkbook wwb = null;
try {
String[] fList = new String[] { "1.xls", "2.xls", "3.xls", "4.xls", "5.xls", "6.xls" };
wwb = Workbook.createWorkbook(new File("D:/union.xls"));
for (int i = 0; i < fList.length; i++) {
InputStream is = new FileInputStream(
"D:/" + fList[i]);
Workbook rwb = Workbook.getWorkbook(is);
Sheet st = rwb.getSheet(0); wwb.importSheet("Sheet" + (i + 1), i, st);
WritableSheet sheet = wwb.getSheet(i);
for (int row = 0; row < st.getRows(); row++) {
for (int col = 0; col < st.getColumns(); col++) {
Label label = new Label(col, row, st.getCell(col, row)
.getContents());
if (st.getCell(col, row).getCellFormat() != null) {
WritableCellFormat format = new WritableCellFormat(
st.getCell(col, row).getCellFormat());
label.setCellFormat(format);
sheet.addCell(label);
}
}
}
rwb.close();
}
wwb.write();
wwb.close();
} catch (IOException e) {
e.printStackTrace();
} catch (BiffException ex) {
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
------------------------------------------------------------------------------------------
这个合并sheet后,有以下警告:
Warning: Some cells exceeded the specified bounds. Resizing sheet dimensions from 3x19 to 4x19
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: Some cells exceeded the specified bounds. Resizing sheet dimensions from 7x46 to 8x46
......Warning: Could not merge cells A1-H1 as they clash with an existing set of merged cells.
Warning: Could not merge cells A1-H1 as they clash with an existing set of merged cells.
Warning: Range A1-D1 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-D1 contains more than one data cell. Setting the other cells to blank.是不是合并单元格的问题呢?原来的单个sheet中有合并的单元格,单合成一个Excel的多个sheet中以后,合并单元格的字都挤到一个单元格中了,请问该如何解决呢?
try {
String[] fList = new String[] { "1.xls", "2.xls", "3.xls", "4.xls", "5.xls", "6.xls" };
wwb = Workbook.createWorkbook(new File("D:/union.xls"));
for (int i = 0; i < fList.length; i++) {
InputStream is = new FileInputStream(
"D:/" + fList[i]);
Workbook rwb = Workbook.getWorkbook(is);
Sheet st = rwb.getSheet(0); wwb.importSheet("Sheet" + (i + 1), i, st);
WritableSheet sheet = wwb.getSheet(i);
for (int row = 0; row < st.getRows(); row++) {
for (int col = 0; col < st.getColumns(); col++) {
Label label = new Label(col, row, st.getCell(col, row)
.getContents());
if (st.getCell(col, row).getCellFormat() != null) {
WritableCellFormat format = new WritableCellFormat(
st.getCell(col, row).getCellFormat());
label.setCellFormat(format);
sheet.addCell(label);
}
}
}
rwb.close();
}
wwb.write();
wwb.close();
} catch (IOException e) {
e.printStackTrace();
} catch (BiffException ex) {
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
------------------------------------------------------------------------------------------
这个合并sheet后,有以下警告:
Warning: Some cells exceeded the specified bounds. Resizing sheet dimensions from 3x19 to 4x19
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: no filename property for drawing
Warning: Some cells exceeded the specified bounds. Resizing sheet dimensions from 7x46 to 8x46
......Warning: Could not merge cells A1-H1 as they clash with an existing set of merged cells.
Warning: Could not merge cells A1-H1 as they clash with an existing set of merged cells.
Warning: Range A1-D1 contains more than one data cell. Setting the other cells to blank.
Warning: Range A1-D1 contains more than one data cell. Setting the other cells to blank.是不是合并单元格的问题呢?原来的单个sheet中有合并的单元格,单合成一个Excel的多个sheet中以后,合并单元格的字都挤到一个单元格中了,请问该如何解决呢?
楼主【wudileiyu】截止到2008-07-08 13:34:47的历史汇总数据(不包括此帖):
发帖的总数量:37 发帖的总分数:1690 每贴平均分数:45
回帖的总数量:48 得分贴总数量:13 回帖的得分率:27%
结贴的总数量:37 结贴的总分数:1690
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
Warning: Could not merge cells A1-H1 as they clash with an existing set of merged cells.
---------------------------------------------------------------------------------------
这里单元格A1-H1 不能合并,因为和一个已经被合并的单元格有冲突,现在的问题就是A1-H1单元格的内容都挤到A1这一个单元格里了,很难看,该如何解决呢?
哪个部门的在哪个sheet 就可以了
不太懂,关注中
这个告警是指有些单元格的宽度太小,里面的内容超出了单元格的长度。无影响。