在使用Jexcelapi JAVA库的同时将超链接添加到Excel

我正在用Java编写一个应用程序,使用JexcelAPI创build一个Excel 2003文件,向其中写入数据(17列,15,000行)。 数据是从可靠的数据stream中接收的。 到目前为止这么好 – 它完美的作品。 当我尝试在一些单元格中放置超文本时(实际上是在一列中),问题就开始了。 从这一分钟的文件保存失败。 代码:

public class partsData { private final static String PdbFileName = "partsDB.xls"; private static WorkbookSettings PdbWorkSheet = null; private static WritableWorkbook PdbWorkbook = null; private static WritableSheet PdbWritableSheet = null; WritableHyperlink wh = null; public static void main (String args[]) { Int linesCounter = 2; try { PdbWorkSheet = new WorkbookSettings(); PdbWorkbook = Workbook.createWorkbook(new File(PdbFileName), PdbWorkSheet); PdbWritableSheet = PdbWorkbook.createSheet(PdbFileName, 0); } catch (IOException e) { filesClose("File open failed - program aborts\n"); } try { // Write to the cells lr = new Label(10, linesCounter, splitLine[0]); PdbWritableSheet.addCell(lr); } catch (WriteException e) { logFileWrite("Write failure - #" + linesCounter); } // Create hyperlink fields based on the data already embedded in the Excel String sStr = <File name and path> String tStr = <field text> if ((sStr != "") && (tStr != "") && (linesCounter > 1)) { file = new File (sStr); wh = new WritableHyperlink(4, linesCounter, file); try { PdbWritableSheet.addHyperlink(wh); } catch (RowsExceededException e) { logFileWrite("REE); } catch (WriteException e) { logFileWrite("WE); } } else logFileWrite("No hyperlink"); } try { PdbWorkbook.write(); // This is where the exception occurs PdbWorkbook.close(); } catch (IOException | WriteException e) { logFileWrite("close failure); }; logFileWrite(message); } } 

错误消息:

 Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java.lang.String.charAt(Unknown Source) at jxl.write.biff.HyperlinkRecord.getFileData(HyperlinkRecord.java:1011) at jxl.write.biff.HyperlinkRecord.getData(HyperlinkRecord.java:518) at jxl.biff.WritableRecordData.getBytes(WritableRecordData.java:71) at jxl.write.biff.File.write(File.java:147) at jxl.write.biff.SheetWriter.write(SheetWriter.java:570) 

任何帮助将不胜感激关心甘尼斯