Exemplo n.º 1
0
  /** Gets Cell text by given row and column, it handling */
  public static String getRichCellHtmlText(
      SSheet sheet, int row, int column, FormatResult ft, SCellStyle tbStyle) { // ZSS-1018
    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

      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, tbStyle); // ZSS-1018
      }
    }
    return text;
  }
Exemplo n.º 2
0
  // ZSS-945, ZSS-1018
  // @since 3.8.0
  // @Internal
  public static String getFontHtmlStyle(
      SSheet sheet,
      SCell cell,
      SCellStyle cellStyle,
      FormatResult ft,
      SCellStyle tbCellStyle) { // ZSS-977
    if (!cell.isNull()) {

      final StringBuffer sb = new StringBuffer();
      // ZSS-977
      SFont font = StyleUtil.getFontStyle(sheet.getBook(), cellStyle, tbCellStyle);
      ;
      sb.append(getFontCSSStyle(cell, font));

      // condition color
      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 "";
  }
Exemplo n.º 3
0
  /** 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;
  }
Exemplo n.º 4
0
  // 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 "";
  }
Exemplo n.º 5
0
  /** Gets Cell text by given row and column */
  public static String getCellHtmlText(
      SSheet sheet, int row, int column, FormatResult ft, SCellStyle tbStyle) { // ZSS-1018
    final SCell cell = sheet.getCell(row, column);
    String text = "";
    if (cell != null) {
      boolean wrap = cell.getCellStyle().isWrapText();

      if (ft.isRichText()) {
        final SRichText rstr = ft.getRichText();
        text = rstr.getText();
      } else {
        text = ft.getText();
      }
      text = escapeText(text, wrap, true);
    }
    return text;
  }
Exemplo n.º 6
0
  /** 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;
  }
Exemplo n.º 7
0
  // 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;
  }