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

📄 sheetreader.java

📁 JAVA 文章管理系统源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        settings.setPrintGridLines(printGridLinesRecord.getPrintGridLines());
      }
      else if (r.getType() == Type.PRINTHEADERS)
      {
        printHeadersRecord = new PrintHeadersRecord(r);
        settings.setPrintHeaders(printHeadersRecord.getPrintHeaders());
      }
      else if (r.getType() == Type.WINDOW2)
      {
        window2Record = new Window2Record(r);

        settings.setShowGridLines(window2Record.getShowGridLines());
        settings.setDisplayZeroValues(window2Record.getDisplayZeroValues());
        settings.setSelected(true);
      }
      else if (r.getType() == Type.PANE)
      {
        PaneRecord pr = new PaneRecord(r);

        if (window2Record != null &&
            window2Record.getFrozen())
        {
          settings.setVerticalFreeze(pr.getRowsVisible());
          settings.setHorizontalFreeze(pr.getColumnsVisible());
        }
      }
      else if (r.getType() == Type.CONTINUE)
      {
        ;
      }
      else if (r.getType() == Type.NOTE)
      {
        if (!workbookSettings.getDrawingsDisabled())
        {
          NoteRecord nr = new NoteRecord(r);

          // Get the comment for the object id
          Comment comment = (Comment) comments.remove
            (new Integer(nr.getObjectId()));

          if (comment == null)
          {
            logger.warn(" cannot find comment for note id " +
                        nr.getObjectId() + "...ignoring");
          }
          else
          {
            comment.setNote(nr);

            drawings.add(comment);

            addCellComment(comment.getColumn(),
                           comment.getRow(),
                           comment.getText(),
                           comment.getWidth(),
                           comment.getHeight());
          }
        }
      }
      else if (r.getType() == Type.ARRAY)
      {
        ;
      }
      else if (r.getType() == Type.PROTECT)
      {
        ProtectRecord pr = new ProtectRecord(r);
        settings.setProtected(pr.isProtected());
      }
      else if (r.getType() == Type.SHAREDFORMULA)
      {
        if (sharedFormula == null)
        {
          logger.warn("Shared template formula is null - " +
                      "trying most recent formula template");
          SharedFormulaRecord lastSharedFormula =
            (SharedFormulaRecord) sharedFormulas.get(sharedFormulas.size() - 1);

          if (lastSharedFormula != null)
          {
            sharedFormula = lastSharedFormula.getTemplateFormula();
          }
        }

        SharedFormulaRecord sfr = new SharedFormulaRecord
          (r, sharedFormula, workbook, workbook, sheet);
        sharedFormulas.add(sfr);
        sharedFormula = null;
      }
      else if (r.getType() == Type.FORMULA || r.getType() == Type.FORMULA2)
      {
        FormulaRecord fr = new FormulaRecord(r,
                                             excelFile,
                                             formattingRecords,
                                             workbook,
                                             workbook,
                                             sheet,
                                             workbookSettings);

        if (fr.isShared())
        {
          BaseSharedFormulaRecord prevSharedFormula = sharedFormula;
          sharedFormula = (BaseSharedFormulaRecord) fr.getFormula();

          // See if it fits in any of the shared formulas
          sharedFormulaAdded = addToSharedFormulas(sharedFormula);

          if (sharedFormulaAdded)
          {
            sharedFormula = prevSharedFormula;
          }

          // If we still haven't added the previous base shared formula,
          // revert it to an ordinary formula and add it to the cell
          if (!sharedFormulaAdded && prevSharedFormula != null)
          {
            // Do nothing.  It's possible for the biff file to contain the
            // record sequence
            // FORMULA-SHRFMLA-FORMULA-SHRFMLA-FORMULA-FORMULA-FORMULA
            // ie. it first lists all the formula templates, then it
            // lists all the individual formulas
            addCell(revertSharedFormula(prevSharedFormula));
          }
        }
        else
        {
          Cell cell = fr.getFormula();
          try
          {
            // See if the formula evaluates to date
            if (fr.getFormula().getType() == CellType.NUMBER_FORMULA)
            {
              NumberFormulaRecord nfr = (NumberFormulaRecord) fr.getFormula();
              if (formattingRecords.isDate(nfr.getXFIndex()))
              {
                cell = new DateFormulaRecord(nfr,
                                             formattingRecords,
                                             workbook,
                                             workbook,
                                             nineteenFour,
                                             sheet);
              }
            }
            
            addCell(cell);
          }
          catch (FormulaException e)
          {
            // Something has gone wrong trying to read the formula data eg. it
            // might be unsupported biff7 data
            logger.warn
              (CellReferenceHelper.getCellReference
               (cell.getColumn(), cell.getRow()) + " " + e.getMessage());
          }
        }
      }
      else if (r.getType() == Type.LABEL)
      {
        LabelRecord lr = null;

        if (workbookBof.isBiff8())
        {
          lr = new LabelRecord(r, formattingRecords, sheet, workbookSettings);
        }
        else
        {
          lr = new LabelRecord(r, formattingRecords, sheet, workbookSettings,
                               LabelRecord.biff7);
        }
        addCell(lr);
      }
      else if (r.getType() == Type.RSTRING)
      {
        RStringRecord lr = null;

        // RString records are obsolete in biff 8
        Assert.verify(!workbookBof.isBiff8());
        lr = new RStringRecord(r, formattingRecords,
                               sheet, workbookSettings,
                               RStringRecord.biff7);
        addCell(lr);
      }
      else if (r.getType() == Type.NAME)
      {
        ;
      }
      else if (r.getType() == Type.PASSWORD)
      {
        PasswordRecord pr = new PasswordRecord(r);
        settings.setPasswordHash(pr.getPasswordHash());
      }
      else if (r.getType() == Type.ROW)
      {
        RowRecord rr = new RowRecord(r);

        // See if the row has anything funny about it
        if (!rr.isDefaultHeight() ||
            !rr.matchesDefaultFontHeight() ||
            rr.isCollapsed() ||
            rr.hasDefaultFormat())
        {
          rowProperties.add(rr);
        }
      }
      else if (r.getType() == Type.BLANK)
      {
        if (!workbookSettings.getIgnoreBlanks())
        {
          BlankCell bc = new BlankCell(r, formattingRecords, sheet);
          addCell(bc);
        }
      }
      else if (r.getType() == Type.MULBLANK)
      {
        if (!workbookSettings.getIgnoreBlanks())
        {
          MulBlankRecord mulblank = new MulBlankRecord(r);

          // Get the individual cell records from the multiple record
          int num = mulblank.getNumberOfColumns();

          for (int i = 0; i < num; i++)
          {
            int ixf = mulblank.getXFIndex(i);

            MulBlankCell mbc = new MulBlankCell
              (mulblank.getRow(),
               mulblank.getFirstColumn() + i,
               ixf,
               formattingRecords,
               sheet);
            
            addCell(mbc);
          }
        }
      }
      else if (r.getType() == Type.SCL)
      {
        SCLRecord scl = new SCLRecord(r);
        settings.setZoomFactor(scl.getZoomFactor());
      }
      else if (r.getType() == Type.COLINFO)
      {
        ColumnInfoRecord cir = new ColumnInfoRecord(r);
        columnInfosArray.add(cir);
      }
      else if (r.getType() == Type.HEADER)
      {
        HeaderRecord hr = null;
        if (workbookBof.isBiff8())
        {
          hr = new HeaderRecord(r, workbookSettings);
        }
        else
        {
          hr = new HeaderRecord(r, workbookSettings, HeaderRecord.biff7);
        }

        HeaderFooter header = new HeaderFooter(hr.getHeader());
        settings.setHeader(header);
      }
      else if (r.getType() == Type.FOOTER)
      {
        FooterRecord fr = null;
        if (workbookBof.isBiff8())
        {
          fr = new FooterRecord(r, workbookSettings);
        }
        else
        {
          fr = new FooterRecord(r, workbookSettings, FooterRecord.biff7);
        }

        HeaderFooter footer = new HeaderFooter(fr.getFooter());
        settings.setFooter(footer);
      }
      else if (r.getType() == Type.SETUP)
      {
        SetupRecord sr = new SetupRecord(r);
        if (sr.isPortrait())
        {
          settings.setOrientation(PageOrientation.PORTRAIT);
        }
        else
        {
          settings.setOrientation(PageOrientation.LANDSCAPE);
        }
        settings.setPaperSize(PaperSize.getPaperSize(sr.getPaperSize()));
        settings.setHeaderMargin(sr.getHeaderMargin());
        settings.setFooterMargin(sr.getFooterMargin());
        settings.setScaleFactor(sr.getScaleFactor());
        settings.setPageStart(sr.getPageStart());
        settings.setFitWidth(sr.getFitWidth());
        settings.setFitHeight(sr.getFitHeight());
        settings.setHorizontalPrintResolution
          (sr.getHorizontalPrintResolution());
        settings.setVerticalPrintResolution(sr.getVerticalPrintResolution());
        settings.setCopies(sr.getCopies());

        if (workspaceOptions != null)
        {
          settings.setFitToPages(workspaceOptions.getFitToPages());
        }
      }
      else if (r.getType() == Type.WSBOOL)
      {
        workspaceOptions = new WorkspaceInformationRecord(r);
      }
      else if (r.getType() == Type.DEFCOLWIDTH)
      {
        DefaultColumnWidthRecord dcwr = new DefaultColumnWidthRecord(r);
        settings.setDefaultColumnWidth(dcwr.getWidth());
      }
      else if (r.getType() == Type.DEFAULTROWHEIGHT)
      {
        DefaultRowHeightRecord drhr = new DefaultRowHeightRecord(r);
        if (drhr.getHeight() != 0)
        {
          settings.setDefaultRowHeight(drhr.getHeight());
        }
      }
      else if (r.getType() == Type.LEFTMARGIN)
      {
        MarginRecord m = new LeftMarginRecord(r);
        settings.setLeftMargin(m.getMargin());
      }
      else if (r.getType() == Type.RIGHTMARGIN)
      {
        MarginRecord m = new RightMarginRecord(r);
        settings.setRightMargin(m.getMargin());
      }
      else if (r.getType() == Type.TOPMARGIN)
      {
        MarginRecord m = new TopMarginRecord(r);
        settings.setTopMargin(m.getMargin());
      }
      else if (r.getType() == Type.BOTTOMMARGIN)
      {
        MarginRecord m = new BottomMarginRecord(r);
        settings.setBottomMargin(m.getMargin());
      }
      else if (r.getType() == Type.HORIZONTALPAGEBREAKS)
      {
        HorizontalPageBreaksRecord dr = null;

        if (workbookBof.isBiff8())
        {
          dr = new HorizontalPageBreaksRecord(r);
        }
        else
        {
          dr = new HorizontalPageBreaksRecord
            (r, HorizontalPageBreaksRecord.biff7);
        }
        rowBreaks = dr.getRowBreaks();
      }
      else if (r.getType() == Type.PLS)
      {
        plsRecord = new PLSRecord(r);
      }
      else if (r.getType() == Type.DVAL)
      {
        // Leave these until another day.  They need to be wrapped inside
        // an implementation of DrawingGroupObject
        //        DataValidityListRecord dvlr = new DataValidityListRecord(r);
        //        dataValidation = new DataValidation(dvlr);
      }
      else if (r.getType() == Type.DV)
      {
        // Leave these until another day.  They need to be wrapped inside
        // an implementation of DrawingGroupObject
        //        DataValiditySettingsRecord dvsr = new DataValiditySettingsRecord(r);
        //        dataValidation.add(dvsr);
      }
      else if (r.getType() == Type.OBJ)
      {
        objRecord = new ObjRecord(r);

        if (!workbookSettings.getDrawingsDisabled())
        {
          handleObjectRecord(objRecord, msoRecord, comments);
        }

        // Save chart handling until the chart BOF record appears
        if (objRecord.getType() != ObjRecord.CHART)
        {
          objRecord = null;
          msoRecord = null;
        }
      }
      else if (r.getType() == Type.MSODRAWING)
      {
        if (!workbookSettings.getDrawingsDisabled())
        {
          if (msoRecord != null)
          {
            // For form controls, a rogue MSODRAWING record can crop up
            // after the main one.  Add these into the drawing data
            drawingData.addRawData(msoRecord.getData());
          }
          msoRecord = new MsoDrawingRecord(r);

          if (firstMsoRecord)
          {
            msoRecord.setFirst();
            firstMsoRecord = false;
          }
        }
      }
      else if (r.getType() == Type.BUTTONPROPERTYSET)
      {
        buttonPropertySet = new ButtonPropertySetRecord(r);
      }
      else if (r.getType() == Type.BOF)
      {
        BOFRecord br = new BOFRecord(r);
        Assert.verify(!br.isWorksheet());

        int startpos = excelFile.getPos() - r.getLength() - 4;

        // Skip to the end of the nested bof
        // Thanks to Rohit for spotting this
        Record r2 = excelFile.next();
        while (r2.getCode() != Type.EOF.value)
        {
          r2 = excelFile.next();
        }

        if (br.isChart())
        {
          if (drawingData == null)
          {
            drawingData = new DrawingData();
          }
          
          if (!workbookSettings.getDrawingsDisabled())
          {
            Chart chart = new Chart(msoRecord, objRecord, drawingData,
                                    startpos, excelFile.getPos(),
                                    excelFile, workbookSettings);
            charts.add(chart);

            if (workbook.getDrawingGroup() != null)
            {
              workbook.getDrawingGroup().add(chart);
            }
          }

          // Reset the drawing records
          msoRecord = null;
          objRecord = null;
        }

        // If this worksheet is just a chart, then the EOF reached
        // represents the end of the sheet as well as the end of the chart
        if (sheetBof.isChart())
        {
          cont = false;
        }
      }
      else if (r.getType() == Type.EOF)
      {
        cont = false;
      }
    }

⌨️ 快捷键说明

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