⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sheetimpl.java

📁 jxtl API Java中Excel的生成与导入解析参考文档
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    return col < columnInfos.length ? columnInfos[col] : null;  }  /**   * Gets all the column info records   *   * @return the ColumnInfoRecordArray   */  public ColumnInfoRecord[] getColumnInfos()  {    // Just chuck all the column infos we have into an array    ColumnInfoRecord[] infos = new ColumnInfoRecord[columnInfosArray.size()];    for (int i = 0; i < columnInfosArray.size(); i++)    {      infos[i] = (ColumnInfoRecord) columnInfosArray.get(i);    }    return infos;  }  /**   * Sets the visibility of this sheet   *   * @param h hidden flag   */  final void setHidden(boolean h)  {    hidden = h;  }  /**   * Clears out the array of cells.  This is done for memory allocation   * reasons when reading very large sheets   */  final void clear()  {    cells = null;    mergedCells = null;    columnInfosArray.clear();    sharedFormulas.clear();    hyperlinks.clear();    columnInfosInitialized = false;    if (!workbookSettings.getGCDisabled())    {      System.gc();    }  }  /**   * 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)        {          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());            }          }        }      }    }  }  /**   * Gets the hyperlinks on this sheet   *   * @return an array of hyperlinks   */  public Hyperlink[] getHyperlinks()  {    Hyperlink[] hl = new Hyperlink[hyperlinks.size()];    for (int i = 0; i < hyperlinks.size(); i++)    {      hl[i] = (Hyperlink) hyperlinks.get(i);    }    return hl;  }  /**   * Gets the cells which have been merged on this sheet   *   * @return an array of range objects   */  public Range[] getMergedCells()  {    if (mergedCells == null)    {      return new Range[0];    }    return mergedCells;  }  /**   * Gets the non-default rows.  Used when copying spreadsheets   *   * @return an array of row properties   */  public RowRecord[] getRowProperties()  {    RowRecord[] rp = new RowRecord[rowProperties.size()];    for (int i = 0; i < rp.length; i++)    {      rp[i] = (RowRecord) rowProperties.get(i);    }    return rp;  }  /**   * Gets the data validations.  Used when copying sheets   *   * @return the data validations   */  public DataValidation getDataValidation()  {    return dataValidation;  }  /**   * Gets the row record.  Usually called by the cell in the specified   * row in order to determine its size   *   * @param r the row   * @return the RowRecord for the specified row   */  RowRecord getRowInfo(int r)  {    if (!rowRecordsInitialized)    {      rowRecords = new RowRecord[getRows()];      Iterator i = rowProperties.iterator();      int rownum = 0;      RowRecord rr = null;      while (i.hasNext())      {        rr = (RowRecord) i.next();        rownum = rr.getRowNumber();        if (rownum < rowRecords.length)        {          rowRecords[rownum] = rr;        }      }      rowRecordsInitialized = true;    }    return r < rowRecords.length ? rowRecords[r] : null;  }  /**   * Gets the row breaks.  Called when copying sheets   *   * @return the explicit row breaks   */  public final int[] getRowPageBreaks()  {    return rowBreaks;  }  /**   * Gets the row breaks.  Called when copying sheets   *   * @return the explicit row breaks   */  public final int[] getColumnPageBreaks()  {    return columnBreaks;  }  /**   * Gets the charts.  Called when copying sheets   *   * @return the charts on this page   */  public final Chart[] getCharts()  {    Chart[] ch = new Chart[charts.size()];    for (int i = 0; i < ch.length; i++)    {      ch[i] = (Chart) charts.get(i);    }    return ch;  }  /**   * Gets the drawings.  Called when copying sheets   *   * @return the drawings on this page   */  public final DrawingGroupObject[] getDrawings()  {    DrawingGroupObject[] dr = new DrawingGroupObject[drawings.size()];    dr = (DrawingGroupObject[]) drawings.toArray(dr);    return dr;  }  /**   * Determines whether the sheet is protected   *   * @return whether or not the sheet is protected   * @deprecated in favour of the getSettings() api   */  public boolean isProtected()  {    return settings.isProtected();  }  /**   * Gets the workspace options for this sheet.  Called during the copy   * process   *   * @return the workspace options   */  public WorkspaceInformationRecord getWorkspaceOptions()  {    return workspaceOptions;  }  /**   * Accessor for the sheet settings   *   * @return the settings for this sheet   */  public SheetSettings getSettings()  {    return settings;  }  /**   * Accessor for the workbook.  In addition to be being used by this package,   * it is also used during the importSheet process   *   * @return  the workbook   */  public WorkbookParser getWorkbook()  {    return workbook;  }  /**   * Gets the column format for the specified column   *   * @param col the column number   * @return the column format, or NULL if the column has no specific format   * @deprecated use getColumnView instead   */  public CellFormat getColumnFormat(int col)  {    CellView cv = getColumnView(col);    return cv.getFormat();  }  /**   * Gets the column width for the specified column   *   * @param col the column number   * @return the column width, or the default width if the column has no   *         specified format   */  public int getColumnWidth(int col)  {    return getColumnView(col).getSize() / 256;  }  /**   * 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;  }  /**   * Gets the row height for the specified column   *   * @param row the row number   * @return the row height, or the default height if the row has no   *         specified format   * @deprecated use getRowView instead   */  public int getRowHeight(int row)  {    return getRowView(row).getDimension();  }  /**   * Gets the row view for the specified row   *   * @param row the row number   * @return the row format, or the default format if no override is             specified   */  public CellView getRowView(int row)  {    RowRecord rr = getRowInfo(row);    CellView cv = new CellView();    if (rr != null)    {      cv.setDimension(rr.getRowHeight()); //deprecated      cv.setSize(rr.getRowHeight());      cv.setHidden(rr.isCollapsed());      if (rr.hasDefaultFormat())      {        cv.setFormat(formattingRecords.getXFRecord(rr.getXFIndex()));      }    }    else    {      cv.setDimension(settings.getDefaultRowHeight());      cv.setSize(settings.getDefaultRowHeight()); //deprecated    }    return cv;  }  /**   * Used when copying sheets in order to determine the type of this sheet   *   * @return the BOF Record   */  public BOFRecord getSheetBof()  {    return sheetBof;  }  /**   * Used when copying sheets in order to determine the type of the containing   * workboook   *   * @return the workbook BOF Record   */  public BOFRecord getWorkbookBof()  {    return workbookBof;  }  /**   * Accessor for the environment specific print record, invoked when   * copying sheets   *   * @return the environment specific print record   */  public PLSRecord getPLS()  {    return plsRecord;  }  /**   * Accessor for the button property set, used during copying   *   * @return the button property set   */  public ButtonPropertySetRecord getButtonPropertySet()  {    return buttonPropertySet;  }  /**   * Accessor for the number of images on the sheet   *   * @return the number of images on this sheet   */  public int getNumberOfImages()  {    if (images == null)    {      initializeImages();    }    return images.size();  }  /**   * Accessor for the image   *   * @param i the 0 based image number   * @return  the image at the specified position   */  public Image getDrawing(int i)  {    if (images == null)    {      initializeImages();    }    return (Image) images.get(i);  }  /**   * Initializes the images   */  private void initializeImages()  {    if (images != null)    {      return;    }    images = new ArrayList();    DrawingGroupObject[] dgos = getDrawings();    for (int i = 0; i < dgos.length; i++)    {      if (dgos[i] instanceof Drawing)      {        images.add(dgos[i]);      }    }  }  /**   * Used by one of the demo programs for debugging purposes only   */  public DrawingData getDrawingData()  {    SheetReader reader = new SheetReader(excelFile,                                         sharedStrings,                                         formattingRecords,                                         sheetBof,                                         workbookBof,                                         nineteenFour,                                         workbook,                                         startPosition,                                         this);    reader.read();    return reader.getDrawingData();  }  /**   * Adds a local name to this shate   *   * @param nr the local name to add   */  void addLocalName(NameRecord nr)  {    if (localNames == null)    {      localNames = new ArrayList();    }    localNames.add(nr);  }  /**   * Gets the conditional formats   *   * @return the conditional formats   */  public ConditionalFormat[] getConditionalFormats()  {    ConditionalFormat[] formats =       new ConditionalFormat[conditionalFormats.size()];    formats = (ConditionalFormat[]) conditionalFormats.toArray(formats);    return formats;  }  /**   * Returns the autofilter   *   * @return the autofilter   */  public AutoFilter getAutoFilter()  {    return autoFilter;  }  /**    * Accessor for the maximum column outline level.  Used during a copy   *   * @return the maximum column outline level, or 0 if no outlines/groups   */  public int getMaxColumnOutlineLevel()   {    return maxColumnOutlineLevel;  }  /**    * Accessor for the maximum row outline level.  Used during a copy   *   * @return the maximum row outline level, or 0 if no outlines/groups   */  public int getMaxRowOutlineLevel()   {    return maxRowOutlineLevel;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -