Ejemplo 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;
  }
Ejemplo 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 "";
  }
Ejemplo 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;
  }
Ejemplo 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 "";
  }
Ejemplo n.º 5
0
  // @since 3.8.0
  public String getRealHtmlStyle(FormatResult ft, SCellStyle tbCellStyle) { // ZSS-977
    if (!_cell.isNull()) {
      final StringBuffer sb = new StringBuffer();
      sb.append(
          getFontHtmlStyle(
              _sheet, _cell, _cell.getCellStyle(), ft, tbCellStyle)); // ZSS-977, ZSS-1018
      sb.append(getIndentCSSStyle(_cell));
      return sb.toString();
    }

    return "";
  }
Ejemplo n.º 6
0
  public String getInnerHtmlStyle() {
    if (!_cell.isNull()) {

      final StringBuffer sb = new StringBuffer();
      sb.append(getTextCSSStyle(_cell));

      // vertical alignment
      VerticalAlignment verticalAlignment = _cellStyle.getVerticalAlignment();
      sb.append("display: table-cell;");
      switch (verticalAlignment) {
        case TOP:
          sb.append("vertical-align: top;");
          break;
        case CENTER:
          sb.append("vertical-align: middle;");
          break;
        case BOTTOM:
        default:
          sb.append("vertical-align: bottom;");
          break;
      }

      // 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 "";
  }
Ejemplo 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;
  }