浏览 7114 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-10-05
已经解决了: String outputFile="D:/导出接口.xls"; try { Workbook wb=Workbook.getWorkbook(new File(outputFile)); //Excel获得文件 //打开一个文件的副本,并且指定数据写回到原文件 WritableWorkbook book=Workbook.createWorkbook(new File(outputFile),wb); WritableSheet sheet=book.createSheet("导出目标",0); //添加一个工作表 String[] oriSheetNames=wb.getSheetNames(); //获得源excel文件中的所有sheet名称 for(int i=0;i<book.getNumberOfSheets();i++) { sheet.addCell(new Label(0,i+1,String.valueOf(i+1))); //第一列写入编号 /** * public WritableHyperlink(int col,int row,java.lang.String desc,WritableSheet sheet,int destcol,int destrow) * Constructs a hyperlink to some cells within this workbook * col - the column containing this hyperlink * row - the row containing this hyperlink * desc - the cell contents for this hyperlink * sheet - the sheet containing the cells to be linked to * destcol - the column number of the first destination linked cell * destrow - the row number of the first destination linked cell * */ sheet.addHyperlink(new WritableHyperlink(1,i+1,oriSheetNames[i],book.getSheet(oriSheetNames[i]),0,0)); book.write(); book.close(); wb.close(); }catch(IOException e) { System.out.println("异常: "+e); } catch(BiffException e) { System.out.println("异常: "+e); } catch(RowsExceededException e) { System.out.println("异常: "+e); } catch(WriteException e) { System.out.println("异常: "+e); } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-10-05
借楼主地一下,一直有一个问题没解决,就是如何设置一个cell的宽和高?有谁知道
|
|
返回顶楼 | |