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

📄 sheetreader.java~

📁 jxtl API Java中Excel的生成与导入解析参考文档
💻 JAVA~
📖 第 1 页 / 共 4 页
字号:
   * @return the data validations   */  final DataValidation getDataValidation()  {    return dataValidation;  }  /**   * Accessor   *   * @return the ranges   */  final Range[] getMergedCells()  {    return mergedCells;  }  /**   * Accessor   *   * @return the sheet settings   */  final SheetSettings getSettings()  {    return settings;  }  /**   * Accessor   *   * @return the row breaks   */  final int[] getRowBreaks()  {    return rowBreaks;  }  /**   * Accessor   *   * @return the column breaks   */  final int[] getColumnBreaks()  {    return columnBreaks;  }  /**   * Accessor   *   * @return the workspace options   */  final WorkspaceInformationRecord getWorkspaceOptions()  {    return workspaceOptions;  }  /**   * Accessor   *   * @return the environment specific print record   */  final PLSRecord getPLS()  {    return plsRecord;  }  /**   * Accessor for the button property set, used during copying   *   * @return the button property set   */  final ButtonPropertySetRecord getButtonPropertySet()  {    return buttonPropertySet;  }  /**   * Adds a cell comment to a cell just read in   *   * @param col the column for the comment   * @param row the row for the comment   * @param text the comment text   * @param width the width of the comment text box   * @param height the height of the comment text box   */  private void addCellComment(int col,                               int row,                               String text,                               double width,                              double height)  {    Cell c = cells[row][col];    if (c == null)    {      logger.warn("Cell at " + CellReferenceHelper.getCellReference(col, row) +                  " not present - adding a blank");      MulBlankCell mbc = new MulBlankCell(row,                                          col,                                          0,                                          formattingRecords,                                          sheet);      CellFeatures cf = new CellFeatures();      cf.setReadComment(text, width, height);      mbc.setCellFeatures(cf);      addCell(mbc);      return;    }    if (c instanceof CellFeaturesAccessor)    {      CellFeaturesAccessor cv = (CellFeaturesAccessor) c;      CellFeatures cf = cv.getCellFeatures();      if (cf == null)      {        cf = new CellFeatures();        cv.setCellFeatures(cf);      }      cf.setReadComment(text, width ,height);    }    else    {      logger.warn("Not able to add comment to cell type " +                  c.getClass().getName() +                  " at " + CellReferenceHelper.getCellReference(col, row));    }  }  /**   * Adds a cell comment to a cell just read in   *   * @param col1 the column for the comment   * @param row1 the row for the comment   * @param col2 the row for the comment   * @param row2 the row for the comment   * @param dvsr the validation settings   */  private void addCellValidation(int col1,                                  int row1,                                  int col2,                                 int row2,                                 DataValiditySettingsRecord dvsr)  {    for (int row = row1; row <= row2; row++)    {      for (int col = col1; col <= col2; col++)      {        Cell c = null;        if (cells.length > row && cells[row].length > col)        {          c = cells[row][col];        }        if (c == null)        {          logger.warn("Cell at " +                       CellReferenceHelper.getCellReference(col, row) +                      " not present - adding a blank");          MulBlankCell mbc = new MulBlankCell(row,                                              col,                                              0,                                              formattingRecords,                                              sheet);          CellFeatures cf = new CellFeatures();          cf.setValidationSettings(dvsr);          mbc.setCellFeatures(cf);          addCell(mbc);          return;        }        if (c instanceof CellFeaturesAccessor)        {          CellFeaturesAccessor cv = (CellFeaturesAccessor) c;          CellFeatures cf = cv.getCellFeatures();          if (cf == null)          {            cf = new CellFeatures();            cv.setCellFeatures(cf);          }          cf.setValidationSettings(dvsr);        }        else        {          logger.warn("Not able to add comment to cell type " +                      c.getClass().getName() +                      " at " + CellReferenceHelper.getCellReference(col, row));        }      }    }  }  /**   * Reads in the object record   *   * @param objRecord the obj record   * @param msoRecord the mso drawing record read in earlier   * @param comments the hash map of comments   */  private void handleObjectRecord(ObjRecord objRecord,                                  MsoDrawingRecord msoRecord,                                  HashMap comments)  {    if (msoRecord == null)    {      logger.warn("Object record is not associated with a drawing " +                  " record - ignoring");      return;    }        try    {    // Handle images    if (objRecord.getType() == ObjRecord.PICTURE)    {      if (drawingData == null)      {        drawingData = new DrawingData();      }      Drawing drawing = new Drawing(msoRecord,                                    objRecord,                                    drawingData,                                    workbook.getDrawingGroup(),                                    sheet);      drawings.add(drawing);      return;    }    // Handle comments    if (objRecord.getType() == ObjRecord.EXCELNOTE)    {      if (drawingData == null)      {        drawingData = new DrawingData();      }      Comment comment = new Comment(msoRecord,                                    objRecord,                                    drawingData,                                    workbook.getDrawingGroup(),                                    workbookSettings);      // Sometimes Excel writes out Continue records instead of drawing      // records, so forcibly hack all of these into a drawing record      Record r2 = excelFile.next();      if (r2.getType() == Type.MSODRAWING || r2.getType() == Type.CONTINUE)      {        MsoDrawingRecord mso = new MsoDrawingRecord(r2);        comment.addMso(mso);        r2 = excelFile.next();      }      Assert.verify(r2.getType() == Type.TXO);      TextObjectRecord txo = new TextObjectRecord(r2);      comment.setTextObject(txo);      r2 = excelFile.next();      Assert.verify(r2.getType() == Type.CONTINUE);      ContinueRecord text = new ContinueRecord(r2);      comment.setText(text);      r2 = excelFile.next();      if (r2.getType() == Type.CONTINUE)      {        ContinueRecord formatting = new ContinueRecord(r2);        comment.setFormatting(formatting);      }      comments.put(new Integer(comment.getObjectId()), comment);      return;    }    // Handle combo boxes    if (objRecord.getType() == ObjRecord.COMBOBOX)    {      if (drawingData == null)      {        drawingData = new DrawingData();      }      ComboBox comboBox = new ComboBox(msoRecord,                                       objRecord,                                       drawingData,                                       workbook.getDrawingGroup(),                                       workbookSettings);      drawings.add(comboBox);      return;    }    // Handle form buttons    if (objRecord.getType() == ObjRecord.BUTTON)    {      if (drawingData == null)      {        drawingData = new DrawingData();      }      Button button = new Button(msoRecord,                                 objRecord,                                 drawingData,                                 workbook.getDrawingGroup(),                                 workbookSettings);      Record r2 = excelFile.next();      if (r2.getType() == Type.MSODRAWING)      {        MsoDrawingRecord mso = new MsoDrawingRecord(r2);        button.addMso(mso);        r2 = excelFile.next();      }      Assert.verify(r2.getType() == Type.TXO);      TextObjectRecord txo = new TextObjectRecord(r2);      button.setTextObject(txo);      r2 = excelFile.next();      Assert.verify(r2.getType() == Type.CONTINUE);      ContinueRecord text = new ContinueRecord(r2);      button.setText(text);      r2 = excelFile.next();      if (r2.getType() == Type.CONTINUE)      {        ContinueRecord formatting = new ContinueRecord(r2);        button.setFormatting(formatting);      }      drawings.add(button);      return;    }    // Handle other types    if (objRecord.getType() != ObjRecord.CHART)    {      logger.warn(objRecord.getType() + " on sheet \"" +                  sheet.getName() +                  "\" not supported - omitting");      if (drawingData == null)      {        drawingData = new DrawingData();      }      drawingData.addData(msoRecord.getData());      if (workbook.getDrawingGroup() != null) // can be null for Excel 95      {        workbook.getDrawingGroup().setDrawingsOmitted(msoRecord,                                                      objRecord);      }      return;    }    }    catch (DrawingDataException e)    {      logger.warn(e.getMessage() +                   "...disabling drawings for the remainder of the workbook");      workbookSettings.setDrawingsDisabled(true);    }  }  /**   * Gets the drawing data - for use as part of the Escher debugging tool   */  DrawingData getDrawingData()  {    return drawingData;  }  /**   * Handle any cells which fall outside of the bounds specified within   * the dimension record   */  private void handleOutOfBoundsCells()  {    int resizedRows = numRows;    int resizedCols = numCols;    // First, determine the new bounds    for (Iterator i = outOfBoundsCells.iterator() ; i.hasNext() ;)    {      Cell cell = (Cell) i.next();      resizedRows = Math.max(resizedRows, cell.getRow() + 1);      resizedCols = Math.max(resizedCols, cell.getColumn() + 1);    }    logger.warn("Some cells exceeded the specified bounds.  Resizing " +                 "sheet dimensions from " +                 numCols + "x"+numRows + " to " +                 resizedCols + "x" + resizedRows);    // Resize the columns, if necessary    if (resizedCols > numCols)    {      for (int r = 0 ; r < numRows ; r++)      {        Cell[] newRow = new Cell[resizedCols];        Cell[] oldRow = cells[r];        System.arraycopy(oldRow, 0, newRow, 0, oldRow.length);        cells[r] = newRow;      }    }    // Resize the rows, if necessary    if (resizedRows > numRows)    {      Cell[][] newCells = new Cell[resizedRows][];      System.arraycopy(cells, 0, newCells, 0, cells.length);      cells = newCells;      // Create the new rows      for (int i = numRows; i < resizedRows; i++)      {        newCells[i] = new Cell[resizedCols];      }    }    numRows = resizedRows;    numCols = resizedCols;    // Now add all the out of bounds cells into the new cells    for (Iterator i = outOfBoundsCells.iterator(); i.hasNext(); )    {      Cell cell = (Cell) i.next();      addCell(cell);    }    outOfBoundsCells.clear();  }  /**    * Accessor for the maximum column outline level   *   * @return the maximum column outline level, or 0 if no outlines/groups   */  public int getMaxColumnOutlineLevel()   {    return maxColumnOutlineLevel;  }  /**    * Accessor for the maximum row outline level   *   * @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 + -