本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFRichTextString.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFRichTextString.toString方法的具體用法?Java HSSFRichTextString.toString怎麽用?Java HSSFRichTextString.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.hssf.usermodel.HSSFRichTextString
的用法示例。
在下文中一共展示了HSSFRichTextString.toString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
示例3: getCellValue
import org.apache.poi.hssf.usermodel.HSSFRichTextString; //導入方法依賴的package包/類
public static String getCellValue(final HSSFSheet sheet, final int r, final int c) {
final HSSFRow row = sheet.getRow(r);
if (row == null) {
return null;
}
final HSSFCell cell = row.getCell(c);
if (cell == null) {
return null;
}
final HSSFRichTextString cellValue = cell.getRichStringCellValue();
return cellValue.toString();
}
示例4: getCellValue
import org.apache.poi.hssf.usermodel.HSSFRichTextString; //導入方法依賴的package包/類
public static String getCellValue(HSSFSheet sheet, int r, int c) {
HSSFRow row = sheet.getRow(r);
if (row == null) {
return null;
}
HSSFCell cell = row.getCell(c);
if (cell == null) {
return null;
}
HSSFRichTextString cellValue = cell.getRichStringCellValue();
return cellValue.toString();
}
示例5: isTextEmpty
import org.apache.poi.hssf.usermodel.HSSFRichTextString; //導入方法依賴的package包/類
protected boolean isTextEmpty( HSSFCell cell )
{
final String value;
switch ( cell.getCellType() )
{
case HSSFCell.CELL_TYPE_STRING:
// XXX: enrich
value = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_FORMULA:
switch ( cell.getCachedFormulaResultType() )
{
case HSSFCell.CELL_TYPE_STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
if ( str == null || str.length() <= 0 )
return false;
value = str.toString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
HSSFCellStyle style = cell.getCellStyle();
if ( style == null )
{
return false;
}
value = ( _formatter.formatRawCellContents(
cell.getNumericCellValue(), style.getDataFormat(),
style.getDataFormatString() ) );
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf( cell.getBooleanCellValue() );
break;
case HSSFCell.CELL_TYPE_ERROR:
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
value = ExcelToHtmlUtils.EMPTY;
break;
}
break;
case HSSFCell.CELL_TYPE_BLANK:
value = ExcelToHtmlUtils.EMPTY;
break;
case HSSFCell.CELL_TYPE_NUMERIC:
value = _formatter.formatCellValue( cell );
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf( cell.getBooleanCellValue() );
break;
case HSSFCell.CELL_TYPE_ERROR:
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
return true;
}
return ExcelToHtmlUtils.isEmpty( value );
}