| | |
| | | class MyHeader( |
| | | var name: String, |
| | | val type: CellType, |
| | | val ignore: Boolean = false |
| | | ) |
| | | |
| | | private fun cellTypeName(type: CellType): String = when (type) { |
| | |
| | | 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)}") |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 自动处理行合并数据 |
| | | * 写入excel |
| | | */ |
| | | fun write(heads: List<Array<Any>>, contents: MutableList<Array<Any>>, workbook: HSSFWorkbook, sheetName: String |
| | | = "sheet1") { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 自动处理行合并数据 |
| | | * 写入excel |
| | | */ |
| | | fun write2(out: OutputStream, heads: List<Array<Any>>, contents: MutableList<Array<Any>>, sheetName: String = "sheet1") { |
| | | |