Package org.zkoss.poi.ss.usermodel

Examples of org.zkoss.poi.ss.usermodel.Workbook


   */
  public static Range range(Worksheet sheet, String reference) {
    AreaReference ref = getAreaReference(sheet, reference);
    if (ref == null) {
      //try NamedRange
      final Workbook wb = sheet.getWorkbook();
        final Name range = wb.getName(reference);
        if (range != null) {
          ref = getAreaReference(sheet, range.getRefersToFormula());
        } else {
          throw new IllegalArgumentException("Cannot find the named range '" + reference + "'");
        }
View Full Code Here


  }
 
  public static Set<Ref>[] setCellHyperlink(Cell cell, int linkTarget, String address) {
    Hyperlink hlink = cell.getHyperlink();
    if (hlink == null) {
      Workbook wb = cell.getSheet().getWorkbook();
      CreationHelper createHelper = wb.getCreationHelper();
      Hyperlink link = createHelper.createHyperlink(linkTarget);
      link.setAddress(address);
     
      cell.setHyperlink(link);
    } else {
View Full Code Here

    final Comment srcComment = srcCell.getCellComment();
    Comment dstComment = dstCell.getCellComment();
    if (srcComment != null) {
      if (dstComment == null) {
        final Worksheet dstSheet = (Worksheet)dstCell.getSheet();
        final Workbook dstBook = dstSheet.getWorkbook();
        final CreationHelper dstFactory = dstBook.getCreationHelper();
        final Drawing drawing = dstSheet.createDrawingPatriarch();
        final ClientAnchor anchor = dstFactory.createClientAnchor();
        dstComment = drawing.createCellComment(anchor);
      }
      dstComment.setString(srcComment.getString());
View Full Code Here

      final int lCol = ref.getLeftCol();
      final int bRow = ref.getBottomRow();
      final int rCol = ref.getRightCol();
      final RefSheet refSheet = ref.getOwnerSheet();
      final Worksheet sheet = BookHelper.getSheet(_sheet, refSheet);
      final Workbook book = sheet.getWorkbook();
     
      for(int row = tRow; row <= bRow; ++row) {
        for (int col = lCol; col <= rCol; ++col) {
          final Cell cell = BookHelper.getCell(sheet, row, col);
          final CellStyle style = cell != null ? cell.getCellStyle() : null;
          final String oldFormat = style != null ? style.getDataFormatString() : null;
          if (oldFormat == null || "General".equals(oldFormat)) {
            CellStyle newCellStyle = book.createCellStyle();
            if (style != null) {
              newCellStyle.cloneStyleFrom(style);
            }
            BookHelper.setDataFormat(book, newCellStyle, formatString); //prepare a DataFormat with the specified formatString
            BookHelper.setCellStyle(sheet, row, col, row, col, newCellStyle);
View Full Code Here

      @Override
      public void handle(CellVisitorContext context) {
        String srcColor = context.getFontColor();
        if (!srcColor.equalsIgnoreCase(color)) {
          final Workbook book = sheet.getWorkbook();
          Font srcFont = context.getFont();

          Color fontColor = BookHelper.HTMLToColor(book, color);
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), fontColor, srcFont.getFontHeight(), srcFont.getFontName(),
              srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
View Full Code Here

      @Override
      public void handle(CellVisitorContext context) {
        String srcFontName = context.getFontFamily();

        if (srcFontName != fontName) {
          final Workbook book = sheet.getWorkbook();
          Font srcFont = context.getFont();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont), srcFont.getFontHeight(), fontName,
              srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
View Full Code Here

      @Override
      public void handle(CellVisitorContext context) {
        short srcFontHgh = context.getFontHeight();
        if (srcFontHgh != fontHeight) {
          final Workbook book = sheet.getWorkbook();
          Font srcFont = context.getFont();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont), fontHeight, srcFont.getFontName(),
            srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
View Full Code Here

      @Override
      public void handle(CellVisitorContext context) {
        boolean srcBold = context.isBold();
        if (srcBold != isBold) {
          final Workbook book = sheet.getWorkbook();
          Font srcFont = context.getFont();
          Font newFont = context.getOrCreateFont(isBold ? Font.BOLDWEIGHT_BOLD : Font.BOLDWEIGHT_NORMAL, BookHelper.getFontColor(book, srcFont), srcFont.getFontHeight(), srcFont.getFontName(),
              srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
View Full Code Here

      public void handle(CellVisitorContext context) {
        Font srcFont = context.getFont();
        boolean srcItalic = context.isItalic();

        if (srcItalic != isItalic) {
          final Workbook book = sheet.getWorkbook();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont), srcFont.getFontHeight(), srcFont.getFontName(),
              isItalic, srcFont.getStrikeout(), srcFont.getTypeOffset(), srcFont.getUnderline());
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
          context.getRange().setStyle(newStyle);
View Full Code Here

      public void handle(CellVisitorContext context) {
        Font srcFont = context.getFont();
        byte srcUnderline = srcFont.getUnderline();

        if (srcUnderline != underline) {
          final Workbook book = sheet.getWorkbook();
          Font newFont = context.getOrCreateFont(srcFont.getBoldweight(), BookHelper.getFontColor(book, srcFont),
            srcFont.getFontHeight(), srcFont.getFontName(),
            srcFont.getItalic(), srcFont.getStrikeout(), srcFont.getTypeOffset(), underline);
          CellStyle newStyle = context.cloneCellStyle();
          newStyle.setFont(newFont);
View Full Code Here

TOP

Related Classes of org.zkoss.poi.ss.usermodel.Workbook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.