src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt
@@ -1,10 +1,10 @@
package cn.flightfeather.supervision.business.report
import cn.flightfeather.supervision.business.report.bean.BaseTemplateResult
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import java.io.File
import java.io.FileOutputStream
import java.io.OutputStream
import java.util.*
/**
 * 各模板合并输出为整体文档
@@ -16,10 +16,23 @@
    abstract val fileName: String
    // 中间结果对象 by hc 2024.12.06
    private val objectResults: MutableList<MutableList<BaseTemplateResult>> = mutableListOf()
    // excel文档
    private var workbook = HSSFWorkbook()
    fun getReportName(): String = "${dataSource.areaName()}-${fileName}.xls"
    fun getReportName(): String = "${dataSource.areaName()}-${fileName}.xlsx"
    // 输出到对象
    fun toObject() {
        templates.forEach {
            if (!it.isExecuted) {
                it.execute()
            }
            objectResults.add(it.toObject())
        }
    }
    fun toFile(path: String) {
        val fileName = getReportName()
@@ -33,7 +46,9 @@
    fun toOutputStream(out: OutputStream) {
        templates.forEach {
            it.execute()
            if (!it.isExecuted) {
                it.execute()
            }
            it.toWorkBook(workbook)
        }
        workbook.write(out)