<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Bryan

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      37 Posts :: 3 Stories :: 24 Comments :: 0 Trackbacks

    Recently,we are maintaining a project and there is a bug "unreadable content in *.xls" when we export the excel report using the POI.For several days,we are unable to find the real reason.though from the beginning,we thought that It was the format,cell style,link problem.finally,we find that It is due to the Hyperlink problem.Of course ,there maybe other reasons which can cause this error.

    The example below comes from the POI website and I make some minor changes. By running it,we can get the error. whether It links to a url, file etc.

    public class POIExport{
     public static void main(String[] args) throws IOException{
      Workbook wb = new HSSFWorkbook(); //or new HSSFWorkbook();
         CreationHelper createHelper = wb.getCreationHelper();

         //cell style for hyperlinks
         //by default hypelrinks are blue and underlined
         CellStyle hlink_style = wb.createCellStyle();
         Font hlink_font = wb.createFont();
         hlink_font.setUnderline(Font.U_SINGLE);
         hlink_font.setColor(IndexedColors.BLUE.getIndex());
         hlink_style.setFont(hlink_font);

        
         Sheet sheet = wb.createSheet("Hyperlinks");
         //number of rows
         for (int i = 0; i < 14000 ; i++){
          Row row = sheet.createRow(i);
          //number of columns
          for(int j = 0 ; j < 5; j++){
           Cell cell = row.createCell((short)j);
           cell.setCellValue("URL Link");
           Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
           link.setAddress("http://poi.apache.org/");
           cell.setHyperlink(link);
           cell.setCellStyle(hlink_style);
          }
         }
         FileOutputStream out = new FileOutputStream("hyperinks.xls");
         wb.write(out);
         out.close();

     }

    }

    So we think that It's a bug of POI 3.5 and as a substitue,we try to use the formula to solve this issue.
    I have consulted with the POI development team and they say that the MS Excel can only have 64k Hyperlinks,but for this I have no idea. and I have also tested JXL which is another tool for generating the excel report and It has the same problem. for this question ,you can visit the url  for more details: https://issues.apache.org/bugzilla/show_bug.cgi?id=49654

    public class TestJXL {

    public static void main(String[] args) throws IOException, WriteException {

    String outputFile="jxl.xls";

    WorkbookSettings wb = new WorkbookSettings();

    wb.setLocale(new Locale("en", "EN"));

    WritableWorkbook book = Workbook.createWorkbook(new File(outputFile),wb);

    WritableSheet sheet= book.createSheet("Hyperlink",0);

    for(int i= 0 ;i < 6;i++)

    {

    for(int j = 0;j<10921; j ++){

    WritableHyperlink wh = new WritableHyperlink(i, j,

    new URL("http://www.andykhan.com/jexcelapi"));

    sheet.addHyperlink(wh);

    }

    }

    book.write();

    book.close();

    }

    }

    It seems that by POI and JXL, the excel report which can only have 65530 Hyperlinks and if It exceeds,It will give us the error.Anyone who have solution to this problem is welcome.Thanks.

    Meanwhile,if the output excel report has no format limitation,you can thinking of the following way instead.but if you have to set the format of the Hyperlink formula cell,the following method will not function.
    cell.setCellFormula("HYPERLINK(""http://mycsinfo.blog.hexun.com/26115547_d.html"",""Interpretation"")")

    posted on 2010-07-27 20:04 Life is no respector of any genius. 閱讀(506) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 久久成人免费大片| 黄色毛片免费网站| 99视频精品全部免费观看| 国产精品福利在线观看免费不卡| eeuss影院免费直达入口| 国产免费一区二区三区VR| 亚洲成a人片在线观看无码专区| 九九免费精品视频在这里| 免费观看激色视频网站(性色)| 国产成人3p视频免费观看| 亚洲国产精品无码观看久久| 好大好深好猛好爽视频免费| 亚洲精品成a人在线观看夫| 免费羞羞视频网站| 亚洲大码熟女在线观看| 波多野结衣视频在线免费观看| 亚洲电影在线免费观看| 日韩免费一区二区三区在线播放| 亚洲va乱码一区二区三区| 午夜dj在线观看免费视频| 日韩在线观看免费完整版视频| 国产国拍亚洲精品福利| 野花香在线视频免费观看大全| 凹凸精品视频分类国产品免费| 免费一级全黄少妇性色生活片| 亚洲中文字幕日产乱码高清app | 在线视频免费观看高清| 亚洲精品无码永久中文字幕| 亚洲色www永久网站| gogo免费在线观看| 亚洲av中文无码乱人伦在线咪咕| 中文字幕免费视频| 亚洲AV性色在线观看| 毛片免费观看视频| 亚洲综合视频在线观看| 四虎影视免费在线| 99精品免费视品| 亚洲不卡在线观看| 国产成人精品曰本亚洲79ren| 99精品免费观看| 精品亚洲成a人在线观看|