将数据写入excel文件

@param list 数据列表
@param <T>  泛型
@return 写入结果
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;
	}
1115373
public static String arrayListToCSV(List<String> list) {
        StringBuilder csv = new StringBuilder();
        for (String str : list) {
            csv.append(str);
            csv.append(",");
        }
        int lastIndex = csv.length() - 1;
        char last = csv.charAt(lastIndex);
        if (last == ',') {
            return csv.substring(0, lastIndex);
        }
        return csv.toString();
    }
1138951
public static final StringBuffer asStringBuffer(WsByteBuffer[] list) {
        StringBuffer sb = new StringBuffer();
        String data = asString(list);
        if (null != data) {
            sb.append(data);
        }
        return sb;
    }
214158
public static <T> File writeUtf8Lines(Collection<T> list, String path) throws IORuntimeException {
		return writeLines(list, path, CharsetUtil.CHARSET_UTF_8);
	}
648866
protected List<ExcelFile> getExcelFiles() {
		if (excelFiles == null) {
			excelFiles = newArrayListWithCapacity(3);

			for (int i = 0;; ++i) {
				String baseKey = String.format("dataSource.%s.%d", getName(), i);
				String path = configuration.get(baseKey + ".path");
				if (path == null) {
					break;
				}
				String doString = configuration.get(baseKey + ".dataOrientation", "rowbased");
				DataOrientation dataOrientation = DataOrientation.valueOf(doString);

				log.info("Opening Excel file: {}", path);
				ExcelFile file = new ExcelFile(new File(path), dataOrientation, dataFormatter);

				try {
					file.load();
				} catch (InvalidFormatException ex) {
					throw new JFunkException(ex.getMessage(), ex);
				} catch (IOException ex) {
					throw new JFunkException(ex.getMessage(), ex);
				}

				excelFiles.add(file);
			}
		}
		return excelFiles;
	}
685000
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
        return XlsUtil.list2Xls(config, list, outputStream);
    }
568411
public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
        //创建目录
        File file = new File(filePath);
        if (!(file.exists())) {
            if (!file.mkdirs()) {
                throw new RuntimeException("创建导出目录失败!");
            }
        }
        OutputStream outputStream = null;
        try {
            if (!fileName.toLowerCase().endsWith(EXCEL)) {
                fileName += EXCEL;
            }
            File excelFile = new File(filePath + "/" + fileName);
            outputStream = new FileOutputStream(excelFile);
            return list2Xls(config, list, outputStream);
        } catch (Exception e1) {
            return false;
        } finally {
            if(outputStream != null){
                outputStream.close();
            }
        }
    }
292257
public static <T> T[] toArray(List<T> list) {
    return toArray(getClass(list.get(0)), list);
  }
1057975
public static <T> List<T> tail(List<T> list)
	{
		if (list.isEmpty())
			return Collections.emptyList();
		else
			return list.subList(1, list.size());
	}
1078055
public static <T> T head(List<T> list)
	{
		if (list.isEmpty())
			return null;
		else
			return list.get(0);
	}
1118242
public static <T> String generateCommaSeparatedList(Collection<T> list) {
        if (list == null || list.size() == 0) {
            return "";
        }
        StringBuilder result = new StringBuilder();
        for (Object obj : list) {
            result.append(',').append(obj.toString());
        }
        return result.length() == 0 ? "" : result.substring(1);
    }
48566
public static List<String> normalizeTagsForUpload(List<String> list) {
        if (isNullOrEmpty(list)) {
            return null;
        }
        List<String> tmp = new ArrayList<String>();
        for (String s : list) {
            if (s.contains(" ")) {
                tmp.add("\"" + s + "\"");
            } else {
                tmp.add(s);
            }
        }
        return tmp;
    }
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;
    }
31426
public static String serializeList(List<?> list) {
        if (list == null) {
            list = new ArrayList<String>();
        }
        XStream xstream = new XStream(new DomDriver());
        return xstream.toXML(list);
    }
499142
public static ImmutableList<File> loadFileList(final File fileList) throws IOException {
    return loadFileList(Files.asCharSource(fileList, Charsets.UTF_8));
  }
704760
public static <T> List<T> toImmutableList(final List<? extends T> list) {
    switch (list.size()) {
      case 0:
        return Collections.emptyList();
      case 1:
        return Collections.singletonList(list.get(0));
      default:
        return Collections.unmodifiableList(list);
    }
  }
12026
public static List<Map<String, Object>> readExcelToMapList(File file, Integer scale) throws ReadExcelException {
        return XLSReader.readExcel(file, scale).getDatas();
    }