| | |
| | | /** |
| | | * 自动处理行合并数据 |
| | | */ |
| | | fun write2(heads: List<Array<String>>, contents: List<Array<Any>>, workbook: HSSFWorkbook, sheetName: String = "sheet1") { |
| | | fun write2(heads: List<Array<Any>>, contents: MutableList<Array<Any>>, workbook: HSSFWorkbook, sheetName: String = "sheet1") { |
| | | |
| | | val sheet = workbook.createSheet(sheetName) |
| | | |
| | | var rowIndex = 0 |
| | | |
| | | heads.forEach { |
| | | val rows = sheet.createRow(rowIndex) |
| | | for (i in it.indices) { |
| | | rows.createCell(i).setCellValue(it[i]) |
| | | } |
| | | rowIndex++ |
| | | } |
| | | // heads.forEach { |
| | | // val rows = sheet.createRow(rowIndex) |
| | | // for (i in it.indices) { |
| | | // rows.createCell(i).setCellValue(it[i]) |
| | | // } |
| | | // rowIndex++ |
| | | // } |
| | | contents.addAll(0, heads) |
| | | |
| | | contents.forEach { |
| | | val maxRow = getMaxRows(it) |
| | |
| | | rows.createCell(col).setCellValue(c) |
| | | println("write1-2: ${c};($rowIndex, ${col})") |
| | | } |
| | | is Int -> rows.createCell(col).setCellValue(c.toDouble()) |
| | | is Double -> rows.createCell(col).setCellValue(c) |
| | | is Boolean -> rows.createCell(col).setCellValue(c) |
| | | is Date -> rows.createCell(col).setCellValue(c) |
| | |
| | | rows.createCell(map.key).setCellValue(c) |
| | | println("write2-2: ${c};($_rowIndex, ${map.key})") |
| | | } |
| | | is Int -> rows.createCell(col).setCellValue(c.toDouble()) |
| | | is Double -> rows.createCell(map.key).setCellValue(c) |
| | | is Boolean -> rows.createCell(map.key).setCellValue(c) |
| | | is Date -> rows.createCell(map.key).setCellValue(c) |