简体   繁体   English

当协议与 http 不同时,未使用 ApachePOI 在 Numbers 中添加超链接地址

[英]HyperLink address not getting added in Numbers using ApachePOI when protocol is different from http

Code Snippet代码片段

  int rowNum = 1;
  Row row = sheet.createRow(rowNum++);
  Hyperlink href = createHelper.createHyperlink(HyperlinkType.URL);
 
  CellStyle hlink_style = workbook.createCellStyle();
  Font hlink_font = workbook.createFont();
  hlink_font.setUnderline(Font.U_SINGLE);
  hlink_font.setColor(IndexedColors.BLUE.getIndex());
  hlink_style.setFont(hlink_font);
  Cell cell = row.createCell(0);
  cell.setCellValue("URL Link");
  Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
  link.setAddress("myProtocol/someText");
  cell.setHyperlink(link);
  cell.setCellStyle(hlink_style);

if i print cell.getHyperlink().getAddress(), it is giving me correct value what i have set, but once execution is over and when i check the Numbers Sheet the url is not clickable and when i check in Format - > Add link, there is no link added at all如果我打印 cell.getHyperlink().getAddress(),它会给出我设置的正确值,但是一旦执行结束,当我检查数字表时,url 是不可点击的,当我检查格式 - > 添加链接,根本没有添加链接

Note: Same script works if i use say "https://www.google.com"注意:如果我使用说“https://www.google.com”,则相同的脚本有效

well this solves the above problem很好,这解决了上述问题

 cell.setCellFormula("HYPERLINK(\"myProtocol/someValue\", \"myLink\")");  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM