feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
src/main/kotlin/cn/flightfeather/supervision/infrastructure/utils/ExcelUtil.kt
@@ -22,19 +22,20 @@
    /**
     * 自动处理行合并数据
     */
    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)
@@ -101,6 +102,7 @@
                        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)
@@ -151,6 +153,7 @@
                                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)