Package jxl

Examples of jxl.CellView


    }
  }

  protected void setColumnWidth(int col, int width)
  {
    CellView cv = new CellView();
    cv.setSize(43 * width);
    sheet.setColumnView(col, cv);
  }
View Full Code Here


                                            + sfreq + topKey + "Download"), cfobj));
                        }
                    }
                    for (int i = 0; i < headerCell; i++)
                    {
                        final CellView view = sheet.getColumnView(i);
                        view.setAutosize(true);
                        sheet.setColumnView(i, view);
                    }
                    sheetNumber++;
                }
                sheet.addCell(new Label(0, r, I18nUtil
View Full Code Here

    // I know of no explanation for this yet, other than that it seems to
    // give the right answer

    // Get the width of the image within the first col, allowing for
    // fractional offsets
    CellView cellView = sheet.getColumnView(firstCol);
    int firstColWidth = cellView.getSize();
    double firstColImageWidth =  (1 - (x - firstCol)) * firstColWidth;
    double pointSize = (cellView.getFormat() != null) ?
      cellView.getFormat().getFont().getPointSize() : DEFAULT_FONT_SIZE;
    double firstColWidthInPoints = firstColImageWidth * 0.59 * pointSize / 256;

    // Get the height of the image within the last row, allowing for
    // fractional offsets
    int lastColWidth = 0;
    double lastColImageWidth = 0;
    double lastColWidthInPoints = 0;
    if (lastCol != firstCol)
    {
      cellView = sheet.getColumnView(lastCol);
      lastColWidth = cellView.getSize();
      lastColImageWidth = (x + width - lastCol) * lastColWidth;
      pointSize = (cellView.getFormat() != null) ?
        cellView.getFormat().getFont().getPointSize() : DEFAULT_FONT_SIZE;
      lastColWidthInPoints = lastColImageWidth * 0.59 * pointSize / 256;
    }
   
    // Now get all the columns in between
    double width = 0;
    for (int i = 0 ; i < lastCol - firstCol - 1 ; i++)
    {
      cellView = sheet.getColumnView(firstCol + 1 +i);
      pointSize = (cellView.getFormat() != null) ?
        cellView.getFormat().getFont().getPointSize() : DEFAULT_FONT_SIZE;
      width += cellView.getSize() * 0.59 * pointSize / 256;
    }

    // Add on the first and last row contributions to get the height in twips
    double widthInPoints = width +
      firstColWidthInPoints + lastColWidthInPoints;
View Full Code Here

    WritableFont wf = new WritableFont(WritableFont.ARIAL, 12);
    wf.setItalic(true);

    WritableCellFormat wcf = new WritableCellFormat(wf);

    CellView cv = new CellView();
    cv.setSize(25 * 256);
    cv.setFormat(wcf);
    ws.setColumnView(0, cv);
    ws.setColumnView(1, 15);

    for (int i =  0; i < 61; i++)
    {
      Label l1 = new Label(0, i, "Common Label");
      Label l2 = new Label(1, i, "Distinct label number " + i);
      ws.addCell(l1);
      ws.addCell(l2);
    }

    // Frig this test record - it appears exactly on the boundary of an SST
    // continue record

    Label l3 = new Label(0, 61, "Common Label", wcf);
    Label l4 = new Label(1, 61, "1-1234567890", wcf);
    Label l5 = new Label(2, 61, "2-1234567890", wcf);
    ws.addCell(l3);
    ws.addCell(l4);
    ws.addCell(l5);

    for (int i =  62; i < 200; i++)
    {
      Label l1 = new Label(0, i, "Common Label");
      Label l2 = new Label(1, i, "Distinct label number " + i);
      ws.addCell(l1);
      ws.addCell(l2);
    }

    // Add in a last label which doesn't take the jxl.common.format
    wf = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD);
    wf.setColour(Colour.RED);
    WritableCellFormat wcf2 = new WritableCellFormat(wf);
    wcf2.setWrap(true);
    Label l = new Label(0, 205, "Different format", wcf2);
    ws.addCell(l);

    // Add some labels to column 5 for autosizing
    Label l6 = new Label(5, 2, "A column for autosizing", wcf2);
    ws.addCell(l6);
    l6 = new Label(5, 4, "Another label, longer this time and " +
                   "in a different font");
    ws.addCell(l6);

    CellView cf = new CellView();
    cf.setAutosize(true);
    ws.setColumnView(5, cf);
  }
View Full Code Here

    ws.setColumnView(2, 20);
    WritableCellFormat wcf = new WritableCellFormat();
    wcf.setAlignment(Alignment.RIGHT);
    wcf.setWrap(true);
    CellView cv = new CellView();
    cv.setSize(25 * 256);
    cv.setFormat(wcf);
    ws.setColumnView(3, cv);

    // Add in the formulas
    Formula f = null;
    Label l = null;
View Full Code Here

      return _styles.get( _styleName );
    }
    else {
      final Cell styleCell = getTemplateCell( _styleName );
      if (null != styleCell) {
        final CellView styleFormat = _isRow ? this.templateSheet.getRowView( styleCell.getRow() )
            : this.templateSheet.getColumnView( styleCell.getColumn() );
        final CellView targetFormat = new CellView();

        copyRowOrColAttributes( styleFormat, targetFormat );

        _styles.put( _styleName, targetFormat );
        return targetFormat;
View Full Code Here

  }


  private void styleRow( String _styleName, WritableWorkbook _xwb, WritableSheet _xs, int _row ) throws JXLException
  {
    final CellView style = getRowStyle( _styleName );
    if (null != style) {
      _xs.setRowView( _row, style.getSize() );
    }
  }
View Full Code Here

    }
  }

  private void styleColumn( String _styleName, WritableWorkbook _xwb, WritableSheet _xs, int _col )
  {
    final CellView style = getColumnStyle( _styleName );
    if (null != style) {
      _xs.setColumnView( _col, style );
    }
  }
View Full Code Here

      if (log.isTraceEnabled())
      {
         log.trace("Applying column settings #0 on column #1", columnStyle, columnIndex);
      }
      CellView cellView = worksheet.getColumnView(columnIndex);
      if (columnStyle.autoSize != null)
      {
         cellView.setAutosize(columnStyle.autoSize);
      }
      if (columnStyle.hidden != null)
      {
         cellView.setHidden(columnStyle.hidden);
      }
      if (columnStyle.width != null)
      {
         cellView.setSize(columnStyle.width);
      }
      worksheet.setColumnView(columnIndex, cellView);
   }
View Full Code Here

            throw new ExcelWorkbookException(
                    "Must define starting and ending columns when grouping columns");
        }
        // JExcelAPI bug workaround
        for (int i = command.getStartColumn(); i <= command.getEndColumn(); i++) {
            worksheet.setColumnView(i, new CellView());
        }
        boolean collapse = command.getCollapse() == null ? false : command
                .getCollapse();
        try {
            worksheet.setColumnGroup(command.getStartColumn(), command
View Full Code Here

TOP

Related Classes of jxl.CellView

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.