Exemple #1
0
  /**
   * Gets the column info record for the specified column. If no column is specified, null is
   * returned
   *
   * @param col the column
   * @return the ColumnInfoRecord if specified, NULL otherwise
   */
  public ColumnInfoRecord getColumnInfo(int col) {
    if (!columnInfosInitialized) {
      // Initialize the array
      Iterator i = columnInfosArray.iterator();
      ColumnInfoRecord cir = null;
      while (i.hasNext()) {
        cir = (ColumnInfoRecord) i.next();

        int startcol = Math.max(0, cir.getStartColumn());
        int endcol = Math.min(columnInfos.length - 1, cir.getEndColumn());

        for (int c = startcol; c <= endcol; c++) {
          columnInfos[c] = cir;
        }

        if (endcol < startcol) {
          columnInfos[startcol] = cir;
        }
      }

      columnInfosInitialized = true;
    }

    return col < columnInfos.length ? columnInfos[col] : null;
  }
Exemple #2
0
  /**
   * Gets the column width for the specified column
   *
   * @param col the column number
   * @return the column format, or the default format if no override is specified
   */
  public CellView getColumnView(int col) {
    ColumnInfoRecord cir = getColumnInfo(col);
    CellView cv = new CellView();

    if (cir != null) {
      cv.setDimension(cir.getWidth() / 256); // deprecated
      cv.setSize(cir.getWidth());
      cv.setHidden(cir.getHidden());
      cv.setFormat(formattingRecords.getXFRecord(cir.getXFIndex()));
    } else {
      cv.setDimension(settings.getDefaultColumnWidth()); // deprecated
      cv.setSize(settings.getDefaultColumnWidth() * 256);
    }

    return cv;
  }
Exemple #3
0
  /** Reads in the contents of this sheet */
  final void readSheet() {
    // If this sheet contains only a chart, then set everything to
    // empty and do not bother parsing the sheet
    // Thanks to steve.brophy for spotting this
    if (!sheetBof.isWorksheet()) {
      numRows = 0;
      numCols = 0;
      cells = new Cell[0][0];
      //      return;
    }

    SheetReader reader =
        new SheetReader(
            excelFile,
            sharedStrings,
            formattingRecords,
            sheetBof,
            workbookBof,
            nineteenFour,
            workbook,
            startPosition,
            this);
    reader.read();

    // Take stuff that was read in
    numRows = reader.getNumRows();
    numCols = reader.getNumCols();
    cells = reader.getCells();
    rowProperties = reader.getRowProperties();
    columnInfosArray = reader.getColumnInfosArray();
    hyperlinks = reader.getHyperlinks();
    conditionalFormats = reader.getConditionalFormats();
    autoFilter = reader.getAutoFilter();
    charts = reader.getCharts();
    drawings = reader.getDrawings();
    dataValidation = reader.getDataValidation();
    mergedCells = reader.getMergedCells();
    settings = reader.getSettings();
    settings.setHidden(hidden);
    rowBreaks = reader.getRowBreaks();
    columnBreaks = reader.getColumnBreaks();
    workspaceOptions = reader.getWorkspaceOptions();
    plsRecord = reader.getPLS();
    buttonPropertySet = reader.getButtonPropertySet();
    maxRowOutlineLevel = reader.getMaxRowOutlineLevel();
    maxColumnOutlineLevel = reader.getMaxColumnOutlineLevel();

    reader = null;

    if (!workbookSettings.getGCDisabled()) {
      System.gc();
    }

    if (columnInfosArray.size() > 0) {
      ColumnInfoRecord cir = (ColumnInfoRecord) columnInfosArray.get(columnInfosArray.size() - 1);
      columnInfos = new ColumnInfoRecord[cir.getEndColumn() + 1];
    } else {
      columnInfos = new ColumnInfoRecord[0];
    }

    // Add any local names
    if (localNames != null) {
      for (Iterator it = localNames.iterator(); it.hasNext(); ) {
        NameRecord nr = (NameRecord) it.next();
        if (nr.getBuiltInName() == BuiltInName.PRINT_AREA) {
          if (nr.getRanges().length > 0) {
            NameRecord.NameRange rng = nr.getRanges()[0];
            settings.setPrintArea(
                rng.getFirstColumn(), rng.getFirstRow(), rng.getLastColumn(), rng.getLastRow());
          }
        } else if (nr.getBuiltInName() == BuiltInName.PRINT_TITLES) {
          // There can be 1 or 2 entries.
          // Row entries have hardwired column entries (first and last
          //  possible column)
          // Column entries have hardwired row entries (first and last
          // possible row)
          for (int i = 0; i < nr.getRanges().length; i++) {
            NameRecord.NameRange rng = nr.getRanges()[i];
            if (rng.getFirstColumn() == 0 && rng.getLastColumn() == 255) {
              settings.setPrintTitlesRow(rng.getFirstRow(), rng.getLastRow());
            } else {
              settings.setPrintTitlesCol(rng.getFirstColumn(), rng.getLastColumn());
            }
          }
        }
      }
    }
  }