导入xls到List

@param config  配置
@param xlsFile xls文件路径
@return List对象
@throws Exception
196146
public static List<?> xls2List(ExcelConfig config, File xlsFile) throws Exception {
        return XlsUtil.xls2List(config, xlsFile);
    }
888029
public function open($file, $config = array())
    {
        $fs = new Filesystem();
        $config['TempDir'] = $fs->getAbsolutePath();
        $this->reader = new \SpreadsheetReader_XLSX($file, $config);
    }
727923
public static ExcelConfig getXmlConfig(String xmlPath) {
        ExcelConfig config = XmlUtil.fromXml(new File(xmlPath), ExcelConfig.class);
        try {
            Class clazz = Class.forName(config.getClazz());
            //自动补充没有填写type的列
            for (int i = 0; i < config.getColumns().getColumns().size(); i++) {
                if (config.getColumn(i).getType() == null || config.getColumn(i).getType().equals("")) {
                    Field field = FieldUtil.getField(clazz, config.getColumn(i).getName());
                    config.getColumn(i).setType(field.getCanonicalName());
                }
            }
        } catch (ClassNotFoundException e) {
            //ignore
        }
        return config;
    }
508067
public static XlsxWorkbook getWorkbook(File file) throws IOException
    {
        try
        {
            return new XlsxWorkbook(file);
        }
        catch(Docx4JException e)
        {
            if(e.getCause() != null
                && e.getCause() instanceof IOException)
                throw (IOException)e.getCause();
            else
                throw new IOException(e);
        }
    }
1200710
File appendSheet(final List<WorksheetContent> worksheetContents) throws IOException {
        final ImmutableSet<String> worksheetNames = FluentIterable.from(worksheetContents)
                .transform(new Function<WorksheetContent, String>() {
                    @Nullable @Override public String apply(@Nullable final WorksheetContent worksheetContent) {
                        return worksheetContent.getSpec().getSheetName();
                    }
                }).toSet();
        if(worksheetNames.size() < worksheetContents.size()) {
            throw new IllegalArgumentException("Sheet names must have distinct names");
        }
        for (final String worksheetName : worksheetNames) {
            if(worksheetName.length() > 30) {
                throw new IllegalArgumentException(
                        String.format("Sheet name cannot exceed 30 characters (invalid name: '%s')",
                                worksheetName));
            }
        }

        final XSSFWorkbook workbook = new XSSFWorkbook();
        final File tempFile =
                File.createTempFile(ExcelConverter.class.getName(), UUID.randomUUID().toString() + XLSX_SUFFIX);
        final FileOutputStream fos = new FileOutputStream(tempFile);

        for (WorksheetContent worksheetContent : worksheetContents) {
            final WorksheetSpec spec = worksheetContent.getSpec();
            appendSheet(workbook, worksheetContent.getDomainObjects(), spec.getFactory(), spec.getSheetName());
        }
        workbook.write(fos);
        fos.close();
        return tempFile;
    }
126819
public static TileSheetsConfig imports(Media configSheets)
    {
        final Xml nodeSheets = new Xml(configSheets);

        final Xml nodeTileSize = nodeSheets.getChild(NODE_TILE_SIZE);
        final int tileWidth = nodeTileSize.readInteger(ATT_TILE_WIDTH);
        final int tileHeight = nodeTileSize.readInteger(ATT_TILE_HEIGHT);

        final Collection<String> sheets = importSheets(nodeSheets);

        return new TileSheetsConfig(tileWidth, tileHeight, sheets);
    }
1145413
@Programmatic
    public Blob toExcel(final List<WorksheetContent> worksheetContents, final String fileName) {
        try {
            final File file = newExcelConverter().appendSheet(worksheetContents);
            return excelFileBlobConverter.toBlob(fileName, file);
        } catch (final IOException ex) {
            throw new ExcelService.Exception(ex);
        }
    }
244720
private List<TransformEntry> readTransformEntries(File file) throws Exception {

        List<TransformEntry> result = new ArrayList<>();
        try (FileInputStream fis = new FileInputStream(file)) {
            byte[] data = CmsFileUtil.readFully(fis, false);
            Document doc = CmsXmlUtils.unmarshalHelper(data, null, false);
            for (Node node : doc.selectNodes("//transform")) {
                Element elem = ((Element)node);
                String xslt = elem.attributeValue("xslt");
                String conf = elem.attributeValue("config");
                TransformEntry entry = new TransformEntry(conf, xslt);
                result.add(entry);
            }
        }
        return result;
    }
409735
private List<File> getConfigFiles(File dir) {
		String[] extensions = { "xml" };
		List<File> configFiles = new ArrayList<File>();

		Collection<File> files = FileUtils.listFiles(dir, extensions, true);
		for (Iterator<File> iterator = files.iterator(); iterator.hasNext();) {
			File file = (File) iterator.next();
			if (file.getName().equals("config.xml")) {
				configFiles.add(file);
			}

		}
		return configFiles;
	}
977560
public static <T> List<T> handleWorkBookToBeans(Class<T> clazz, Workbook workbook) throws ReadExcelException {
        List<Map<String, Object>> listMap = ReadExcelUtils.handleWorkBookToMapList(workbook);
        List<T> beans = new ArrayList<T>();
        for (Map<String, Object> map : listMap) {
            T bean = CommonUtils.toBean(map, clazz);
            if (bean != null) {
                beans.add(bean);
            }
        }

        return beans;
    }
865968
public void noTemplateSheet2Excel(List<NoTemplateSheetWrapper> sheets, OutputStream os)
            throws Excel4JException, IOException {

        try (Workbook workbook = exportExcelNoTemplateHandler(sheets, true)) {
            workbook.write(os);
        }
    }
685000
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
        return XlsUtil.list2Xls(config, list, outputStream);
    }
365030
public static void convertMXML(String path) throws Exception{
		Map<Integer, String> lines = new HashMap<>();
		List<Integer> lineNumbers = new ArrayList<>();
		String actualLine = "";
		int lineNumber = 0;
		File mxmlfile = new File(path);
		try {
			File file = new File(mxmlfile.getAbsolutePath().substring(0,mxmlfile.getAbsolutePath().indexOf('.'))+"sequentialSort.txt");
			FileWriter output = new FileWriter(file, true);
			XMLInputFactory inputFactory = XMLInputFactory.newInstance();
			XMLStreamReader stax = inputFactory.createXMLStreamReader(new StreamSource(new File(path)));
			boolean element = false;
		
			while (stax.hasNext()) {
				switch (stax.next()) {
				case XMLStreamConstants.START_ELEMENT:
					element = stax.getLocalName().equals("WorkflowModelElement");
					if (stax.getLocalName().equals("ProcessInstance")) {
						String id = getID(stax);
						lineNumber = Integer.parseInt(id.substring(id.indexOf("Case")+4));
						lineNumbers.add(lineNumber);
					}
					break;
				case XMLStreamConstants.CDATA:
				case XMLStreamConstants.CHARACTERS:
					if (!stax.isWhiteSpace() && element) {
						actualLine += stax.getText();
					}
					break;
				case XMLStreamConstants.END_ELEMENT:
					if (stax.getLocalName().equals("ProcessInstance")) {
						actualLine += '\n';
						lines.put(lineNumber, actualLine);
						actualLine = "";
					} else if(stax.getLocalName().equals("WorkflowModelElement")){
						actualLine += '	';
					}
				}
			}
			System.out.println(lineNumbers);
			Collections.sort(lineNumbers);
			System.out.println(lineNumbers);
			for(int line: lineNumbers){
//				System.out.println("write line: "+line);
				output.write(lines.get(line));
			}
			output.close();
		} catch (IOException | XMLStreamException | NumberFormatException e) {
			throw new RuntimeException(e);
		}
	}
1152052
@Programmatic
    public <T> List<T> fromExcel(
            final Blob excelBlob,
            final WorksheetSpec worksheetSpec) throws ExcelService.Exception {
        final List<List<?>> listOfList =
                fromExcel(excelBlob, Collections.singletonList(worksheetSpec));
        return (List<T>) listOfList.get(0);
    }
734532
@Override
	public List<XLog> parse(InputStream is)
			throws Exception {
		is = new GZIPInputStream(new BufferedInputStream(is));
		return super.parse(is);
	}
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;
    }
1372515
public static List<?> xls2List(String xmlPath, InputStream inputStream) throws Exception {
        Workbook wb = null;
        List<?> list = null;
        try {
            wb = Workbook.getWorkbook(inputStream);
            list = workbook2List(xmlPath, wb);
        } catch (Exception e) {
            throw new Exception("转换xls出错:" + e.getMessage());
        } finally {
            if (wb != null) {
                wb.close();
            }
        }
        return list;
    }