本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFRichTextString.numFormattingRuns方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFRichTextString.numFormattingRuns方法的具體用法?Java HSSFRichTextString.numFormattingRuns怎麽用?Java HSSFRichTextString.numFormattingRuns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.hssf.usermodel.HSSFRichTextString
的用法示例。
在下文中一共展示了HSSFRichTextString.numFormattingRuns方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHSSFRichString
import org.apache.poi.hssf.usermodel.HSSFRichTextString; //導入方法依賴的package包/類
/**
* 03版本複雜數據
* @param rich
* @return
*/
private String getHSSFRichString(HSSFRichTextString rich) {
int nums = rich.numFormattingRuns();
StringBuilder sb = new StringBuilder();
String text = rich.toString();
int currentIndex = 0;
sb.append(text.substring(0, rich.getIndexOfFormattingRun(0)));
for (int i = 0; i < nums; i++) {
sb.append("<span ");
sb.append("class='font_" + rich.getFontOfFormattingRun(i));
sb.append("_");
sb.append(cssRandom);
sb.append("'>");
currentIndex = rich.getIndexOfFormattingRun(i);
if (i < nums - 1) {
sb.append(XmlEscapers.xmlContentEscaper()
.escape(text.substring(currentIndex, rich.getIndexOfFormattingRun(i + 1))));
} else {
sb.append(XmlEscapers.xmlContentEscaper()
.escape(text.substring(currentIndex, text.length())));
}
sb.append("</span>");
}
return sb.toString();
}
示例2: getHSSFRichString
import org.apache.poi.hssf.usermodel.HSSFRichTextString; //導入方法依賴的package包/類
/**
* 03版本複雜數據
* @param rich
* @return
*/
private String getHSSFRichString(HSSFRichTextString rich) {
int nums = rich.numFormattingRuns();
StringBuilder sb = new StringBuilder();
String text = rich.toString();
int currentIndex = 0;
sb.append(text.substring(0, rich.getIndexOfFormattingRun(0)));
for (int i = 0; i < nums; i++) {
sb.append("<span ");
sb.append("class='font_" + rich.getFontOfFormattingRun(i));
sb.append("_");
sb.append(cssRandom);
sb.append("'>");
currentIndex = rich.getIndexOfFormattingRun(i);
if (i < nums - 1) {
sb.append(XmlEscapers.xmlContentEscaper().escape(
text.substring(currentIndex, rich.getIndexOfFormattingRun(i + 1))));
} else {
sb.append(XmlEscapers.xmlContentEscaper().escape(
text.substring(currentIndex, text.length())));
}
sb.append("</span>");
}
return sb.toString();
}