XLSX ファイル rt.getFontAtIndex(i) の一部のセルでは、部分がクラッシュし、制御が関数を終了し、関数を呼び出すことさえあります。Out Swing ウィンドウはまだ開いています。例外がなければコントロールがコードの外に出る理由はわかりません。
public static String addLinkTagInRichTextForUnderscores(XSSFRichTextString rt) {
System.out.print("Was here 1\n");
if(rt.length()==0 || rt == null) {
return " ";
}
String outString = rt.toString();
//String finalString = "";
List<Integer> startIndexListOfUL = new ArrayList<Integer>();
boolean continuing = false;
System.out.println(outString +" A "+ rt.length() +"\n\n");
for(int i=1;i<rt.length();i++) {
System.out.print("Was here at font "+ i);
XSSFFont font = null;
try{
//font = rt.getFontAtIndex(i);
} catch(Error e){
e.fillInStackTrace();
}
System.out.print("Was here too" + rt.getFontAtIndex(i));
if(font!= null) {
if(XSSFFont.U_SINGLE == font.getUnderline()) {
if(!continuing){
startIndexListOfUL.add(new Integer(i));
continuing = true;
}
}else{
continuing = false;
}
} else {
//System.out.println("No font " + i);
}
}
System.out.println(startIndexListOfUL);
if(startIndexListOfUL.size()==0) {
//finalString = outString;
return " ";
} else {
int spacing = 0;
for(int i = 0; i<startIndexListOfUL.size(); i++) {
outString = insertStringAt(outString,startIndexListOfUL.get(i) + spacing,"<link>");
spacing = spacing + 6;
}
}
//just remove redundant <link> tags
outString = outString.replaceAll("(<link>[\\s]?<link>)", "<link>");
//System.out.println("Final >>>> " + outString);
return outString;
}