| 56 | |
| 57 | // 导出 |
| 58 | public static void poiExport(List<List<String>> list, String url) throws Exception { |
| 59 | //创建Excel工作薄 |
| 60 | HSSFWorkbook workbook = new HSSFWorkbook(); |
| 61 | //创建一个工作表shheet |
| 62 | HSSFSheet sheet = workbook.createSheet(); |
| 63 | for (int i = 0; i < list.size(); i++) { |
| 64 | HSSFRow row = sheet.createRow(i); |
| 65 | List<String> dataList = list.get(i); |
| 66 | for (int j = 0; j < dataList.size(); j++) { |
| 67 | HSSFCell cell = row.createCell(j); |
| 68 | cell.setCellValue(dataList.get(j)); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | FileOutputStream stream = FileUtils.openOutputStream(new File(url)); |
| 73 | workbook.write(stream); |
| 74 | stream.close(); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | public static void main(String[] args) { |