/** Gets Cell text by given row and column, it handling */ public static String getRichCellHtmlText(SSheet sheet, int row, int column) { final SCell cell = sheet.getCell(row, column); String text = ""; if (!cell.isNull()) { final SCellStyle style = cell.getCellStyle(); boolean wrap = style.isWrapText(); boolean vtxt = style.getRotation() == 255; // ZSS-918 final FormatResult ft = EngineFactory.getInstance() .createFormatEngine() .format(cell, new FormatContext(ZssContext.getCurrent().getLocale())); if (ft.isRichText()) { final SRichText rstr = ft.getRichText(); text = vtxt ? getVRichTextHtml(rstr, wrap) : getRichTextHtml(rstr, wrap); // ZSS-918 } else { text = vtxt ? escapeVText(ft.getText(), wrap) : escapeText(ft.getText(), wrap, true); // ZSS-918 } final SHyperlink hlink = cell.getHyperlink(); if (hlink != null) { text = getHyperlinkHtml(text, hlink, sheet, cell, style, ft, null); // ZSS-1018 } } return text; }
// ZSS-725: separate inner and font style to avoid the conflict between // vertical alignment, subscript and superscript. public String getFontHtmlStyle() { if (!_cell.isNull()) { final StringBuffer sb = new StringBuffer(); final SFont font = _cellStyle.getFont(); // sb.append(BookHelper.getFontCSSStyle(_book, font)); sb.append(getFontCSSStyle(_cell, font)); // condition color final FormatResult ft = _formatEngine.format(_cell, new FormatContext(ZssContext.getCurrent().getLocale())); final boolean isRichText = ft.isRichText(); if (!isRichText) { final SColor color = ft.getColor(); if (color != null) { final String htmlColor = color.getHtmlColor(); sb.append("color:").append(htmlColor).append(";"); } } return sb.toString(); } return ""; }
/** Gets Cell text by given row and column */ public static String getCellHtmlText(SSheet sheet, int row, int column) { final SCell cell = sheet.getCell(row, column); String text = ""; if (cell != null) { boolean wrap = cell.getCellStyle().isWrapText(); final FormatResult ft = EngineFactory.getInstance() .createFormatEngine() .format(cell, new FormatContext(ZssContext.getCurrent().getLocale())); if (ft.isRichText()) { final SRichText rstr = ft.getRichText(); text = rstr.getText(); } else { text = ft.getText(); } text = escapeText(text, wrap, true); } return text; }
// ZSS-725 public static String getRichTextEditCellHtml(SSheet sheet, int row, int column) { final SCell cell = sheet.getCell(row, column); String text = ""; if (!cell.isNull()) { boolean wrap = cell.getCellStyle().isWrapText(); final FormatResult ft = EngineFactory.getInstance() .createFormatEngine() .format(cell, new FormatContext(ZssContext.getCurrent().getLocale())); if (ft.isRichText()) { final SRichText rstr = ft.getRichText(); text = RichTextHelper.getCellRichTextHtml(rstr, wrap); } else { text = RichTextHelper.getFontTextHtml( escapeText(ft.getText(), wrap, true), cell.getCellStyle().getFont()); } } return text; }
// 20150303, henrichen: The fix for ZSS-945 is super dirty! // ZSS-945 // @since 3.8.0 // @Internal public FormatResult getFormatResult() { return _cell == null ? null : _formatEngine.format(_cell, new FormatContext(ZssContext.getCurrent().getLocale())); }
public String getCellEditText() { return _formatEngine.getEditText(_cell, new FormatContext(ZssContext.getCurrent().getLocale())); }
public String getCellFormattedText() { final FormatResult ft = _formatEngine.format(_cell, new FormatContext(ZssContext.getCurrent().getLocale())); return ft.getText(); }
@After public void tearDown() throws Exception { ZssContext.setThreadLocal(null); }
@Before public void startUp() throws Exception { ZssContext.setThreadLocal(new ZssContext(Locale.TAIWAN, -1)); }