导出list对象到excel

@param list     导出的list
@param xmlPath  xml完整路径
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果，true成功，false失败
@throws Exception
778934
public static boolean list2Xls(List<?> list, String xmlPath, String filePath, String fileName) throws Exception {
        //创建目录
        File file = new File(filePath);
        if (!(file.exists())) {
            if (!file.mkdirs()) {
                throw new RuntimeException("创建导出目录失败!");
            }
        }
        try {
            ExcelConfig config = getEasyExcel(xmlPath);
            return list2Xls(config, list, filePath, fileName);
        } catch (Exception e1) {
            return false;
        }
    }
246899
private NodeList getNodeListUsingJavaXPath(String xpath) throws Exception {
		XPathFactory xpathFac = XPathFactory.newInstance();
		XPath theXpath = xpathFac.newXPath();

		String html = getGUIDriver().getHtmlSource();
		html = html.replaceAll(">\\s+<", "><");
		InputStream input = new ByteArrayInputStream(html.getBytes(Charset.forName("UTF-8")));

		XMLReader reader = new Parser();
		reader.setFeature(Parser.namespacesFeature, false);
		Transformer transformer = TransformerFactory.newInstance().newTransformer();

		DOMResult result = new DOMResult();
		transformer.transform(new SAXSource(reader, new InputSource(input)), result);

		Node htmlNode = result.getNode(); // This code gets a Node from the
											// result.
		NodeList nodes = (NodeList) theXpath.evaluate(xpath, htmlNode, XPathConstants.NODESET);

		return nodes;
	}
1371424
public File[] listFiles(String directoryPath) {
        File[] result = null;
        File directory = null;
        directory = new File(directoryPath);
        if (directory.isDirectory()) {
            result = directory.listFiles();
        }
        return result;
    }
925203
public void writeToExcel(List<? extends Object> datas, boolean hasTitle,
                             OutputStream outputStream, int inMemory,
                             boolean transverse) throws IOException {
        log.info("准备将数据写入excel");
        //这里使用SXSSFWorkbook而不是XSSFWorkbook，这样将会节省内存，但是内存中仅仅存在inMemory行数据，如果超出那么会将
        //index最小的刷新到本地，后续不能通过getRow方法获取到该行
        SXSSFWorkbook wb = new SXSSFWorkbook(inMemory);
        writeToExcel(datas, hasTitle, wb, transverse);
        log.info("数据写入excel完毕，准备写入本地文件");
        wb.write(outputStream);
        log.debug("删除临时文件，关闭Workbook");
        wb.dispose();
        wb.close();
    }
485819
public static void createFile(String filePath) throws IOException {
    Path storagePath = Paths.get(filePath);
    Files.createDirectories(storagePath.getParent());
    Files.createFile(storagePath);
  }
326313
static void export(String path, List<Queue> queueList, DbConn cnx) throws JqmXmlException
    {
        // Argument tests
        if (path == null)
        {
            throw new IllegalArgumentException("file path cannot be null");
        }
        if (queueList == null || queueList.isEmpty())
        {
            throw new IllegalArgumentException("queue list cannot be null or empty");
        }
        if (cnx == null)
        {
            throw new IllegalArgumentException("database connection cannot be null");
        }

        // Create XML document
        Element root = new Element("jqm");
        Document document = new Document(root);
        Element queues = new Element("queues");
        root.addContent(queues);

        for (Queue q : queueList)
        {
            Element queue = getQueueElement(q, cnx);
            queues.addContent(queue);
        }

        // Done: save the file
        try
        {
            XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
            out.output(document, new FileOutputStream(path));
        }
        catch (java.io.IOException e)
        {
            throw new JqmXmlException("Coul npot save the XML file", e);
        }
    }
888203
public static void compressList(String srcFilePath, String destFilePath) throws Exception {
		File src = new File(srcFilePath);
		if (!src.exists() || !src.isDirectory()) {
			throw new RuntimeException(srcFilePath + "不存在");
		}
		File zipFile = new File(destFilePath);
		ZipOutputStream zos=null;
		try {
			FileOutputStream fos = new FileOutputStream(zipFile);
			CheckedOutputStream cos = new CheckedOutputStream(fos, new CRC32());
			zos = new ZipOutputStream(cos);
			String baseDir = "";
			File[] files = src.listFiles();
			for (File file : files) {
				compressbyType(file, zos, baseDir);
			}			
		} finally {
			if(zos!=null)
			{
				zos.close();
			}
		}
	}
685000
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
        return XlsUtil.list2Xls(config, list, outputStream);
    }
1346024
public synchronized void loadConfig(String filePath) throws Exception {

        if (isLoaded) {
            return;
        }

        String filePathInternal = filename;

        // 指定的路径
        if (filePath != null) {
            filePathInternal = filePath;
        }

        // -d 的路径
        // 优先使用 系统参数或命令行导入
        String disconfFilePath = System.getProperty(DISCONF_CONF_FILE_PATH_ARG);
        if (disconfFilePath != null) {
            filePathInternal = disconfFilePath;
        }

        try {
            DisconfAutowareConfig.autowareConfig(INSTANCE, filePathInternal);
        } catch (Exception e) {
            LOGGER.warn("cannot find " + filePathInternal + ", using sys var or user input.");
        }

        // 使用system env 导入
        DisconfAutowareConfig.autowareConfigWithSystemEnv(INSTANCE);

        isLoaded = true;
    }
1012256
public static List<?> workbook2List(String xmlPath, Workbook wb) throws Exception {
        //获取配置文件
        ExcelConfig config = getEasyExcel(xmlPath);
        return workbook2List(config, wb);
    }
7480
def filelist(jottapath, JFS):
    """"""
    log.debug("filelist %r", jottapath)
    try:
        jf = JFS.getObject(jottapath)
    except JFSNotFoundError:
        return set() # folder does not exist, so pretend it is an empty folder
    if not isinstance(jf, JFSFolder):
        return False
    return set([f.name for f in jf.files() if not f.is_deleted()])
330846
public <T> boolean write(List<T> list, Class<T> clazz) {
		
		List<Object[]> rows = ExcelBeanHelper.beanToExcelValueArrays(list, clazz);
		try {
			Sheet sheet = workbook.getSheetAt(0);
			for (int i = 2; i < rows.size(); i++) {
				Row excelRow = sheet.getRow(i);
				Object[] vals = rows.get(i);
				for (int j = 0; j < vals.length; j++) {
					Cell cell = excelRow.getCell(j);
					cell.setCellValue(vals[j] == null ? "" : vals[j].toString());
				}
			}
			workbook.write(outputStream);
			return true;
		} catch (IOException e) {
			LOG.error("流异常", e);
		} catch (Exception e) {
			LOG.error("其他异常", e);
		} 
		return false;
	}
141418
public void exportObjects2CSV(List<?> data, Class clazz, boolean isWriteHeader, String path)
            throws Excel4JException {

        try {
            Writer writer = new FileWriter(path);
            exportCSVByMapHandler(data, clazz, isWriteHeader, writer);
        } catch (Excel4JException | IOException e) {
            throw new Excel4JException(e);
        }
    }
147557
public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
        return XlsUtil.list2Xls(config, list, filePath, fileName);
    }
778124
public void writeToExcel(List<? extends Object> datas, boolean hasTitle, String path,
                             boolean transverse) throws IOException {
        writeToExcel(datas, hasTitle, path, IN_MEMORY, transverse);
    }
54885
public void exportObjects2Excel(String templatePath, List<?> data, Class clazz, OutputStream os)
            throws Excel4JException {

        exportObjects2Excel(templatePath, 0, data, null, clazz, true, os);
    }
115760
public static List<?> xls2List(String xmlPath, File xlsFile) throws Exception {
        return XlsUtil.xls2List(xmlPath, xlsFile);
    }