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中以后,合并单元格的字都挤到一个单元格中了,请问该如何解决呢?

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【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  %                  
    敬礼!
      

  2.   

    合并sheet的单元格还是有问题,谁对jxl处理Excel熟悉呢?
      

  3.   

    主要是单元格合并的问题:
    Warning:  Could not merge cells A1-H1 as they clash with an existing set of merged cells. 
    ---------------------------------------------------------------------------------------
    这里单元格A1-H1 不能合并,因为和一个已经被合并的单元格有冲突,现在的问题就是A1-H1单元格的内容都挤到A1这一个单元格里了,很难看,该如何解决呢?
      

  4.   

    可以设置大标题一样.
    哪个部门的在哪个sheet   就可以了
      

  5.   

    用jxl操作Excel如何合并单元格呢?就是第0行第0列的那个单元格,它为什么自己合并而不是第0行的从A1到H1都合并了呢(Warning:  Could not merge cells A1-H1 as they clash with an existing set of merged cells. )?
      

  6.   

    Some cells exceeded the specified bounds.  Resizing sheet dimensions from 3x19 to 4x19 一些单元超出了指定的边界,恢复表格尺寸从3x19 到 4x19 是不是少了一列呀,是不是在合并单元格的那个表中其实还是被认为是一列,而到新表中被认为是两列呀?
    不太懂,关注中
      

  7.   

    jxl是框架吗?遇到Excel我就头痛,不知怎么处理。
      

  8.   

    Warning: Some cells exceeded the specified bounds. Resizing sheet dimensions from 3x19 to 4x19.
    这个告警是指有些单元格的宽度太小,里面的内容超出了单元格的长度。无影响。