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

📄 workbookparser.java~

📁 jxtl API Java中Excel的生成与导入解析参考文档
💻 JAVA~
📖 第 1 页 / 共 3 页
字号:
        BoundsheetRecord br = (BoundsheetRecord) boundsheets.get          (getNumberOfSheets());        s.setName(br.getName());        s.setHidden(br.isHidden());        addSheet(s);      }      else      {        logger.warn("BOF is unrecognized");        while (excelFile.hasNext() && r.getType() != Type.EOF)        {          r = excelFile.next();        }      }      // The next record will normally be a BOF or empty padding until      // the end of the block is reached.  In exceptionally unlucky cases,      // the last EOF  will coincide with a block division, so we have to      // check there is more data to retrieve.      // Thanks to liamg for spotting this      bof = null;      if (excelFile.hasNext())      {        r = excelFile.next();        if (r.getType() == Type.BOF)        {          bof = new BOFRecord(r);        }      }    }    // Add all the local names to the specific sheets    for (Iterator it = localNames.iterator() ; it.hasNext() ;)    {      NameRecord nr  = (NameRecord) it.next();      if (nr.getBuiltInName() == null)      {        logger.warn("Usage of a local non-builtin name");      }       else if (nr.getBuiltInName() == BuiltInName.PRINT_AREA ||                nr.getBuiltInName() == BuiltInName.PRINT_TITLES)      {        logger.debug("built in name");        // appears to use the internal tab number rather than the        // external sheet index        SheetImpl s = (SheetImpl) sheets.get(nr.getSheetRef() - 1);        s.addLocalName(nr);      }    }  }  /**   * Accessor for the formattingRecords, used by the WritableWorkbook   * when creating a copy of this   *   * @return the formatting records   */  public FormattingRecords getFormattingRecords()  {    return formattingRecords;  }  /**   * Accessor for the externSheet, used by the WritableWorkbook   * when creating a copy of this   *   * @return the external sheet record   */  public ExternalSheetRecord getExternalSheetRecord()  {    return externSheet;  }  /**   * Accessor for the MsoDrawingGroup, used by the WritableWorkbook   * when creating a copy of this   *   * @return the Mso Drawing Group record   */  public MsoDrawingGroupRecord getMsoDrawingGroupRecord()  {    return msoDrawingGroup;  }  /**   * Accessor for the supbook records, used by the WritableWorkbook   * when creating a copy of this   *   * @return the supbook records   */  public SupbookRecord[] getSupbookRecords()  {    SupbookRecord[] sr = new SupbookRecord[supbooks.size()];    return (SupbookRecord[]) supbooks.toArray(sr);  }  /**   * Accessor for the name records.  Used by the WritableWorkbook when   * creating a copy of this   *   * @return the array of names   */  public NameRecord[] getNameRecords()  {    NameRecord[] na = new NameRecord[nameTable.size()];    return (NameRecord[]) nameTable.toArray(na);  }  /**   * Accessor for the fonts, used by the WritableWorkbook   * when creating a copy of this   * @return the fonts used in this workbook   */  public Fonts getFonts()  {    return fonts;  }  /**   * Returns the cell for the specified location eg. "Sheet1!A4".     * This is identical to using the CellReferenceHelper with its   * associated performance overheads, consequently it should   * be use sparingly   *   * @param loc the cell to retrieve   * @return the cell at the specified location   */  public Cell getCell(String loc)  {    Sheet s = getSheet(CellReferenceHelper.getSheet(loc));     return s.getCell(loc);  }  /**   * Gets the named cell from this workbook.  If the name refers to a   * range of cells, then the cell on the top left is returned.  If   * the name cannot be found, null is returned   *   * @param  name the name of the cell/range to search for   * @return the cell in the top left of the range if found, NULL   *         otherwise   */  public Cell findCellByName(String name)  {    NameRecord nr = (NameRecord) namedRecords.get(name);    if (nr == null)    {      return null;    }    NameRecord.NameRange[] ranges = nr.getRanges();    // Go and retrieve the first cell in the first range    Sheet s = getSheet(getExternalSheetIndex(ranges[0].getExternalSheet()));    int col = ranges[0].getFirstColumn();    int row = ranges[0].getFirstRow();    // If the sheet boundaries fall short of the named cell, then return    // an empty cell to stop an exception being thrown    if (col > s.getColumns() || row > s.getRows())    {      return new EmptyCell(col, row);    }        Cell cell = s.getCell(col, row);    return cell;  }  /**   * Gets the named range from this workbook.  The Range object returns   * contains all the cells from the top left to the bottom right   * of the range.   * If the named range comprises an adjacent range,   * the Range[] will contain one object; for non-adjacent   * ranges, it is necessary to return an array of length greater than   * one.   * If the named range contains a single cell, the top left and   * bottom right cell will be the same cell   *   * @param name the name to find   * @return the range of cells   */  public Range[] findByName(String name)  {    NameRecord nr = (NameRecord) namedRecords.get(name);    if (nr == null)    {      return null;    }    NameRecord.NameRange[] ranges = nr.getRanges();    Range[] cellRanges = new Range[ranges.length];    for (int i = 0; i < ranges.length; i++)    {      cellRanges[i] = new RangeImpl        (this,         getExternalSheetIndex(ranges[i].getExternalSheet()),         ranges[i].getFirstColumn(),         ranges[i].getFirstRow(),         getLastExternalSheetIndex(ranges[i].getExternalSheet()),         ranges[i].getLastColumn(),         ranges[i].getLastRow());    }    return cellRanges;  }  /**   * Gets the named ranges   *   * @return the list of named cells within the workbook   */  public String[] getRangeNames()  {    Object[] keys = namedRecords.keySet().toArray();    String[] names = new String[keys.length];    System.arraycopy(keys, 0, names, 0, keys.length);    return names;  }  /**   * Method used when parsing formulas to make sure we are trying   * to parse a supported biff version   *   * @return the BOF record   */  public BOFRecord getWorkbookBof()  {    return workbookBof;  }  /**   * Determines whether the sheet is protected   *   * @return whether or not the sheet is protected   */  public boolean isProtected()  {    return wbProtected;  }  /**   * Accessor for the settings   *   * @return the workbook settings   */  public WorkbookSettings getSettings()  {    return settings;  }  /**   * Accessor/implementation method for the external sheet reference   *   * @param sheetName the sheet name to look for   * @return the external sheet index   */  public int getExternalSheetIndex(String sheetName)  {    return 0;  }  /**   * Accessor/implementation method for the external sheet reference   *   * @param sheetName the sheet name to look for   * @return the external sheet index   */  public int getLastExternalSheetIndex(String sheetName)  {    return 0;  }  /**   * Gets the name at the specified index   *   * @param index the index into the name table   * @return the name of the cell   */  public String getName(int index)  {    Assert.verify(index >= 0 && index < nameTable.size());    return ((NameRecord) nameTable.get(index)).getName();  }  /**   * Gets the index of the name record for the name   *   * @param name the name to search for   * @return the index in the name table   */  public int getNameIndex(String name)  {    NameRecord nr = (NameRecord) namedRecords.get(name);    return nr != null ? nr.getIndex() : 0;  }  /**   * Accessor for the drawing group   *   * @return  the drawing group   */  public DrawingGroup getDrawingGroup()  {    return drawingGroup;  }  /**   * Accessor for the CompoundFile.  For this feature to return non-null   * value, the propertySets feature in WorkbookSettings must be enabled   * and the workbook must contain additional property sets.  This   * method is used during the workbook copy   *   * @return the base compound file if it contains additional data items   *         and property sets are enabled   */  public CompoundFile getCompoundFile()  {    return excelFile.getCompoundFile();  }  /**   * Accessor for the containsMacros   *   * @return TRUE if this workbook contains macros, FALSE otherwise   */  public boolean containsMacros()  {    return containsMacros;  }  /**   * Accessor for the button property set, used during copying   *   * @return the button property set   */  public ButtonPropertySetRecord getButtonPropertySet()  {    return buttonPropertySet;  }  /**   * Accessor for the country record, using during copying   *   * @return the country record read in   */  public CountryRecord getCountryRecord()  {    return countryRecord;  }  /**   * Accessor for addin function names   *   * @return list of add in function names   */  public String[] getAddInFunctionNames()  {    String[] addins = new String[0];    return (String[]) addInFunctions.toArray(addins);  }  /**   * Gets the sheet index in this workbook.  Used when importing a sheet   *   * @param sheet the sheet   * @return the 0-based sheet index, or -1 if it is not found   */  public int getIndex(Sheet sheet)  {    String name = sheet.getName();    int index = -1;    int pos = 0;    for (Iterator i = boundsheets.iterator() ; i.hasNext() && index == -1 ;)    {      BoundsheetRecord br = (BoundsheetRecord) i.next();      if (br.getName().equals(name))      {        index = pos;      }      else      {        pos++;      }    }    return index;  }}

⌨️ 快捷键说明

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