bsp book string str row gets 内容 数组集合
相关 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;
- }
Java 将 Excel 解析为数组集合
来源: http://www.bubuko.com/infodetail-2027360.html