/** * Returns the plain string representation. */ public String toString() { return getString(); }
/** * Returns the number of characters in this string. */ public int length() { return getString().length(); }
/** * Get the value of the cell as a string * <p> * For numeric cells we throw an exception. For blank cells we return an empty string. * For formulaCells that are not string Formulas, we throw an exception * </p> * @return the value of the cell as a string */ @Override public String getStringCellValue() { return getRichStringCellValue().getString(); }
/** * Sets the font of the entire string. * @param font The font to use. */ public void applyFont(Font font) { String text = getString(); applyFont(0, text.length(), font); }
@Override public String getStringCellValue() { return _cell.getRichStringCellValue().getString(); }
/** * Removes any formatting that may have been applied to the string. */ public void clearFormatting() { String text = getString(); st.setRArray(null); st.setT(text); }
@Override public void cell(String cellRef, String formattedValue, XSSFComment comment) { if (firstCellOfRow) { firstCellOfRow = false; } else { output.append('\t'); } if (formattedValue != null) { checkMaxTextSize(output, formattedValue); output.append(formattedValue); } if (includeCellComments && comment != null) { String commentText = comment.getString().getString().replace('\n', ' '); output.append(formattedValue != null ? " Comment by " : "Comment by "); checkMaxTextSize(output, commentText); if (commentText.startsWith(comment.getAuthor() + ": ")) { output.append(commentText); } else { output.append(comment.getAuthor()).append(": ").append(commentText); } } }
/** * Applies the specified font to the entire string. * * @param fontIndex the font to apply. */ public void applyFont(short fontIndex) { XSSFFont font; if(styles == null) { font = new XSSFFont(); font.setFontName("#" + fontIndex); } else { font = styles.getFontAt(fontIndex); } String text = getString(); applyFont(0, text.length(), font); }
int sstIndex = Integer.parseInt(_cell.getV()); XSSFRichTextString rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(sstIndex)); String text = rt.getString(); return Boolean.parseBoolean(text); case NUMERIC:
int sstIndex = Integer.parseInt(_cell.getV()); XSSFRichTextString rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(sstIndex)); return rt.getString(); case NUMERIC: case ERROR:
/** * Set a rich string value for the cell. * * @param value value to set the cell to. For formulas: we'll set the formula * string, for String cells: we'll set its value. For other types we will * change the cell to a string cell and set its value. * If value is null then we will change the cell to a Blank cell. */ @Override public void setCellValue(RichTextString value) { XSSFRichTextString xvalue = (XSSFRichTextString)value; if (xvalue != null && xvalue.getString() != null) { ensureRichTextStringType(); if (xvalue.length() > SpreadsheetVersion.EXCEL2007.getMaxTextLength()) { throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters"); } ((RichTextValue)_value).setValue(xvalue); } else { setCellType(CellType.BLANK); } }
try { final int index = Integer.parseInt(value); result = new XSSFRichTextString(sharedStringsTable.getEntryAt(index)).getString(); } catch (NumberFormatException e) { result = value;
try { final int index = Integer.parseInt(value); result = new XSSFRichTextString(sharedStringsTable.getEntryAt(index)).getString(); } catch (NumberFormatException e) { result = value;
/** * Applies a font to the specified characters of a string. * * @param startIndex The start index to apply the font to (inclusive) * @param endIndex The end index to apply to font to (exclusive) * @param font The index of the font to use. */ public void applyFont(int startIndex, int endIndex, Font font) { if (startIndex > endIndex) throw new IllegalArgumentException("Start index must be less than end index, but had " + startIndex + " and " + endIndex); if (startIndex < 0 || endIndex > length()) throw new IllegalArgumentException("Start and end index not in range, but had " + startIndex + " and " + endIndex); if (startIndex == endIndex) return; if(st.sizeOfRArray() == 0 && st.isSetT()) { //convert <t>string</t> into a text run: <r><t>string</t></r> st.addNewR().setT(st.getT()); st.unsetT(); } String text = getString(); XSSFFont xssfFont = (XSSFFont)font; TreeMap<Integer, CTRPrElt> formats = getFormatMap(st); CTRPrElt fmt = CTRPrElt.Factory.newInstance(); setRunAttributes(xssfFont.getCTFont(), fmt); applyFont(formats, startIndex, endIndex, fmt); CTRst newSt = buildCTRst(text, formats); st.set(newSt); }
rPr.setLang("en-US"); rPr.setSz(1100); r.setT(str.getString());
rPr.setLang("en-US"); rPr.setSz(1100); r.setT(str.getString());
/** * Returns the plain string representation. */ public String toString() { return getString(); }
/** * Returns the number of characters in this string. */ public int length() { return getString().length(); }
public void cell(String cellRef, String formattedValue, XSSFComment comment) { try { // Handle any missing cells int colNum = (new CellReference(cellRef)).getCol(); for (int cn=lastSeenCol+1; cn<colNum; cn++) { xhtml.startElement("td"); xhtml.endElement("td"); } lastSeenCol = colNum; // Start this cell xhtml.startElement("td"); // Main cell contents if (formattedValue != null) { xhtml.characters(formattedValue); } // Comments if (comment != null) { xhtml.startElement("br"); xhtml.endElement("br"); xhtml.characters(comment.getAuthor()); xhtml.characters(": "); xhtml.characters(comment.getString().getString()); } xhtml.endElement("td"); } catch (SAXException e) { } }
/** * Get the value of the cell as a string * <p> * For numeric cells we throw an exception. For blank cells we return an empty string. * For formulaCells that are not string Formulas, we throw an exception * </p> * @return the value of the cell as a string */ @Override public String getStringCellValue() { return getRichStringCellValue().getString(); }