feiyu02
2025-09-30 a3cc1d220f8a1de11874bebceba0130d32157ff1
src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
@@ -36,6 +36,7 @@
    class MyHeader(
        var name: String,
        val type: CellType,
        val ignore: Boolean = false
    )
    private fun cellTypeName(type: CellType): String = when (type) {
@@ -74,8 +75,8 @@
        iterator.forEach {
            // 检查当前行每个单元格类型是否与表头定义匹配
            headers.forEachIndexed { i, h ->
                val t = it.getCell(i + 1).cellType
                if (t != CellType.BLANK || t != h.type) {
                val t = it.getCell(i)?.cellType ?: CellType.BLANK
                if (t != CellType.BLANK && !h.ignore && t != h.type) {
                    throw BizException("第${it.rowNum + 1}行,第${i + 1}列单元格格式错误,应该为${cellTypeName(h.type)}")
                }
            }
@@ -84,7 +85,7 @@
    }
    /**
     * 自动处理行合并数据
     * 写入excel
     */
    fun write(heads: List<Array<Any>>, contents: MutableList<Array<Any>>, workbook: HSSFWorkbook, sheetName: String
    = "sheet1") {
@@ -274,7 +275,7 @@
    }
    /**
     * 自动处理行合并数据
     * 写入excel
     */
    fun write2(out: OutputStream, heads: List<Array<Any>>, contents: MutableList<Array<Any>>, sheetName: String = "sheet1") {