标签:contents work puts stream ret return add exce .com
相关 jar 包:
jxl-2.6.jar
jar 包下载:http://files.cnblogs.com/files/liaolongjun/excel-jar.zip
	/**
	 * 返回上传的Excel表格的内容
	 */
	public static List<String[]> parseExcel(InputStream is) throws Exception {
		List<String[]> list = new ArrayList<>();
		Workbook wb = Workbook.getWorkbook(is);
		Sheet sheet = wb.getSheets()[0];
		int columns = sheet.getRow(0).length;
		for (int i = 0; i < sheet.getRows(); i++) {
			String[] line = new String[columns];
			for (int j = 0; j < columns; j++) {
				Cell cell = sheet.getCell(j, i);
				String content = null;
				if (cell != null) {
					content = cell.getContents();
				}
				if (content != null && content.trim().length() == 0) {
					content = null;
				}
				line[j] = content;
			}
			list.add(line);
		}
		return list;
	}
标签:contents work puts stream ret return add exce .com
原文地址:http://www.cnblogs.com/liaolongjun/p/6718358.html