将WorkBook里的所有Sheet里的记录封装成beanMap放入List中。

@param workbook 指定WorkBook
@return 无结果返回空List
@throws ReadExcelException
514828
public static List<Map<String, Object>> handleWorkBookToMapList(Workbook workbook) throws ReadExcelException {
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        // 遍历WorkBook所有Sheet
        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
            // 获取Sheet
            Sheet sheet = workbook.getSheetAt(i);
            // 将每个Sheet页获取到的beanMap均放入listMap中
            listMap.addAll(ReadExcelUtils.handleSheetToMapList(sheet));
        }

        return listMap;
    }
831056
@Programmatic
    public List<List<?>> fromExcel(
            final Blob excelBlob,
            final List<WorksheetSpec> worksheetSpecs) throws ExcelService.Exception {
        try {
            return newExcelConverter().fromBytes(worksheetSpecs, excelBlob.getBytes());
        } catch (final IOException | InvalidFormatException e) {
            throw new ExcelService.Exception(e);
        }
    }
693334
private void initWorkbook() throws Docx4JException
    {
        if(pkg == null)
            return;

        wbp = pkg.getWorkbookPart();
        sheets = ((org.xlsx4j.sml.Workbook)wbp.getJaxbElement()).getSheets().getSheet();
        wbrp = wbp.getRelationshipsPart();
        if(wbrp == null)
        {
            wbrp = new RelationshipsPart();
            wbrp.setPartName(new PartName("/xl/_rels/workbook.xml.rels"));

            //wbrp = new RelationshipsPart(new PartName("/xl/_rels/workbook.xml.rels"));
            wbp.addTargetPart(wbrp);
        }

        prp = pkg.getRelationshipsPart();
        if(prp == null)
        {
            prp = new RelationshipsPart();
            pkg.addTargetPart(prp);
        }

        PartName ssPart = new PartName("/xl/sharedStrings.xml");
        sharedStrings = (SharedStrings)pkg.getParts().get(ssPart);
        if(sharedStrings == null)
        {
            sharedStrings = new SharedStrings(ssPart);
            sharedStrings.setJaxbElement(new CTSst());
            wbp.addTargetPart(sharedStrings);
        }
        strings = sharedStrings.getJaxbElement();

        PartName stylesPart = new PartName("/xl/styles.xml");
        styles = (Styles)pkg.getParts().get(stylesPart);
        if(styles == null)
        {
            styles = new Styles(stylesPart);
            CTStylesheet styleSheet = new CTStylesheet();
            styles.setJaxbElement(styleSheet);
            wbp.addTargetPart(styles);
        }
        stylesheet = styles.getJaxbElement();

        fonts = stylesheet.getFonts();
        if(fonts == null)
        {
            fonts = new CTFonts();
            stylesheet.setFonts(fonts);
        }

        cellXfs = stylesheet.getCellXfs();
        if(cellXfs == null)
        {
            cellXfs = new CTCellXfs();
            stylesheet.setCellXfs(cellXfs);
        }

        cellStyles = stylesheet.getCellStyles();
        if(cellStyles == null)
        {
            cellStyles = new CTCellStyles();
            stylesheet.setCellStyles(cellStyles);
        }

        cellStyleXfs = stylesheet.getCellStyleXfs();
        if(cellStyleXfs == null)
        {
            cellStyleXfs = new CTCellStyleXfs();
            stylesheet.setCellStyleXfs(cellStyleXfs);
        }

        borders = stylesheet.getBorders();
        if(borders == null)
        {
            borders = new CTBorders();
            stylesheet.setBorders(borders);
        }

        fills = stylesheet.getFills();
        if(fills == null)
        {
            fills = new CTFills();
            stylesheet.setFills(fills);
        }

        if(sheets != null) 
        {
            for(int i = 0; i < sheets.size(); i++)
            {
                Sheet sheet = (Sheet)sheets.get(i);
                WorksheetPart wsp = (WorksheetPart)wbrp.getPart(sheet.getId());
                if(wsp != null)
                    worksheets.put(sheet.getName(), new XlsxWorksheet(this, wsp));
            }
        }

        //printFontInfo();
    }
633275
private void parse(Workbook ws) throws ParseException {
    LOG.info("Parsing XLS file...");
    Sheet sheet = ws.getSheet(SHEET_NAME);
    if (sheet == null) {
      sheet = ws.getSheetAt(0);
    }
    if (sheet == null) {
      throw new ParseException("No sheet found");
    }

    int firstRow = sheet.getFirstRowNum();
    int lastRow = sheet.getLastRowNum();
    LOG.info("first row is:" + firstRow + ", last row is:" + lastRow);

    // first row is expected to be the header.
    analyzeHeader(sheet.getRow(firstRow));

    for (int i = firstRow + 1; i <= lastRow; i++) {
      Row r = sheet.getRow(i);
      extractRowData(r, cellMap);
    }
    LOG.info("Parsing of XLS file finished.");
  }
148121
public static XlsxWorkbook getWorkbook(InputStream stream) throws IOException
    {
        try
        {
            return new XlsxWorkbook(stream);
        }
        catch(Docx4JException e)
        {
            throw new IOException(e);
        }
    }
1085644
private byte[] getExcelOutput(FileColumn[] columns, List<String[]> lines) throws IOException
    {
        // Create the workbook
        baos = new ByteArrayOutputStream(1024);
        if(existing != null)
            workbook = Workbook.createWorkbook(format, baos, existing);
        else
            workbook = Workbook.createWorkbook(format, baos);

        workbook.setHeaders(hasHeaders());

        if(append && workbook.getSheet(worksheet) != null)
            workbook.appendToSheet(columns, lines, worksheet);
        else
            workbook.createSheet(columns, lines, worksheet);

        // Write out the workbook to the stream
        workbook.write();
        workbook.close();

        // The contents returned is the byte array
        return baos.toByteArray();
    }
115033
public List<String> getSheetNames() {
		final int totalSheet = workbook.getNumberOfSheets();
		List<String> result = new ArrayList<>(totalSheet);
		for (int i = 0; i < totalSheet; i++) {
			result.add(this.workbook.getSheetAt(i).getSheetName());
		}
		return result;
	}
196146
public static List<?> xls2List(ExcelConfig config, File xlsFile) throws Exception {
        return XlsUtil.xls2List(config, xlsFile);
    }
216368
public static List<Map<String, Object>> handleSheetToMapList(Sheet sheet) throws ReadExcelException {
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        // 得到Sheet里的列名
        List<String> columnList = ReadExcelUtils.getColumnOfSheet(sheet);
        for (int i = 2; i < sheet.getLastRowNum() + 1; i++) {
            Map<String, Object> beanMap = new HashMap<String, Object>();
            // 得到行
            Row row = sheet.getRow(i);
            // 遍历列
            for (int j = 0; j < row.getLastCellNum(); j++) {
                // 获取单元格
                Cell cell = row.getCell(j);
                if (cell != null) {
                    // 单元格对应列名
                    String key = columnList.get(j);
                    // 单元格对应值
                    Object value = ReadExcelUtils.getCellValue(cell.getCellType(), cell);
                    // key-value pairs 放入map
                    if (value != null) {
                        beanMap.put(key, value);
                    }
                }
            }
            // 将每个beanMap放入List中
            if (!beanMap.isEmpty()) {
                listMap.add(beanMap);
            }
        }
        return listMap;
    }
677771
@SuppressWarnings("unchecked")
	public <T> List<T> read(int headerRowIndex, int startRowIndex, int endRowIndex, Class<T> beanType) {
		checkNotClosed();
		final List<Map<String, Object>> mapList = read(headerRowIndex, startRowIndex, endRowIndex);
		if (Map.class.isAssignableFrom(beanType)) {
			return (List<T>) mapList;
		}

		final List<T> beanList = new ArrayList<>(mapList.size());
		for (Map<String, Object> map : mapList) {
			beanList.add(BeanUtil.mapToBean(map, beanType, false));
		}
		return beanList;
	}
70041
public XceliteSheet getSheet(String sheetName) {
    Sheet sheet = workbook.getSheet(sheetName);
    if (sheet == null) {
      throw new XceliteException(String.format("Could not find sheet named \"%s\"", sheetName));
    }
    return new XceliteSheetImpl(sheet, file);
  }
194958
public static Cell[] getRow(final Sheet sheet, final int row) {
        ArgUtils.notNull(sheet, "sheet");

        Row rows = sheet.getRow(row);
        if(rows == null) {
            rows = sheet.createRow(row);
        }
        int maxColumn = getColumns(sheet);
        Cell[] cells = new Cell[maxColumn];
        for(int i=0; i < maxColumn; i++) {
            Cell cell = rows.getCell(i);
            if(cell == null) {
                cell = rows.createCell(i, CellType.BLANK);
            }
            cells[i] = cell;
        }

        return cells;
    }
1073991
public static XLSReader readExcel(File file, Integer scale) throws ReadExcelException {
        POIFSFileSystem fs = null;
        XLSReader reader = null;
        try {
            fs = new POIFSFileSystem(file);
            reader = new XLSReader(fs, scale);
            reader.process();
        } catch (Exception e) {
            throw new ReadExcelException(e.getMessage());
        } finally {
            if (fs != null) {
                try {
                    fs.close();
                } catch (IOException e) {
                    throw new ReadExcelException(e.getMessage());
                }
            }
        }
        return reader;
    }
44813
public static function getInstance(PHPExcel $workbook = NULL) {
		if ($workbook !== NULL) {
    		if (isset(self::$_workbookSets[$workbook->getID()])) {
    			return self::$_workbookSets[$workbook->getID()];
    		}
			return new PHPExcel_Calculation($workbook);
		}

		if (!isset(self::$_instance) || (self::$_instance === NULL)) {
			self::$_instance = new PHPExcel_Calculation();
		}

		return self::$_instance;
	}
300057
public void process() throws ReadExcelException {
        MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this);
        formatListener = new FormatTrackingHSSFListenerPlus(listener);

        HSSFEventFactory factory = new HSSFEventFactory();
        HSSFRequest request = new HSSFRequest();

        if (outputFormulaValues) {
            request.addListenerForAllRecords(formatListener);
        } else {
            workbookBuildingListener = new EventWorkbookBuilder.SheetRecordCollectingListener(formatListener);
            request.addListenerForAllRecords(workbookBuildingListener);
        }

        try {
            factory.processWorkbookEvents(request, fs);
        } catch (IOException e) {
            throw new ReadExcelException(e.getMessage());
        }
        //解析完后，判断用户是否设置了limit，若设置了执行以下操作
        if (this.limit > 0) {
            if (!this.datas.isEmpty()) {
                if (this.callback != null) {
                    //若数据不为空且回调函数被设置，则调用回调函数
                    this.callback.callback(this.currentRowInSheet, this.currentSheetInExcel, this.realRowInSheet,
                            this.realRowInExcel, this.allSheetInExcel, this.titles, this.columns, this.datas);
                }
                this.datas.clear();
            }
        }
    }
1298448
public static List<List<String>> readTable(int sheetIndex) {
        setXssfSheet(xssfWorkbook.getSheetAt(sheetIndex));
        return readTable();
    }
977517
public WorkbookWriter addRow(@NonNull Iterable<? extends Object> fields) {
    Row row;
    if (sheet.getLastRowNum() == 0 && sheet.getPhysicalNumberOfRows() == 0)
      row = sheet.createRow(0);
    else
      row = sheet.createRow(sheet.getLastRowNum() + 1);

    int i = 0;
    for (Object o : fields) {
      Cell cell = row.createCell(i);
      if (o != null) {
        if (o instanceof Boolean)
          cell.setCellValue((Boolean) o);
        else if (o instanceof Calendar)
          cell.setCellValue((Calendar) o);
        else if (o instanceof Date)
          cell.setCellValue((Date) o);
        else if (o instanceof Double)
          cell.setCellValue((Double) o);
        else if (o instanceof RichTextString)
          if ((o instanceof HSSFRichTextString
              && workbook instanceof HSSFWorkbook)
              || (o instanceof XSSFRichTextString
                  && workbook instanceof XSSFWorkbook)) {
            cell.setCellValue((RichTextString) o);
          } else {
            cell.setCellValue(o.toString());
          }
        else if (o instanceof Hyperlink)
          cell.setHyperlink((Hyperlink) o);
        else if (o instanceof Number)
          cell.setCellValue(((Number) o).doubleValue());
        else
          cell.setCellValue(o.toString());
      }
      i++;
    }
    return this;
  }