| | |
| | | package cn.flightfeather.supervision.business.report |
| | | |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook |
| | | import java.io.File |
| | | import java.io.FileOutputStream |
| | | import java.io.OutputStream |
| | | import java.util.* |
| | | |
| | | /** |
| | | * 各模板合并输出为整体文档 |
| | | * 单个数据源 |
| | | */ |
| | | abstract class BaseExcel(val dataSource: DataSource) { |
| | | |
| | |
| | | // excel文档 |
| | | private var workbook = HSSFWorkbook() |
| | | |
| | | fun getReportName(): String = "${dataSource.areaName()}-${fileName}.xls" |
| | | |
| | | fun toFile(path: String) { |
| | | val fileName = "${dataSource.areaName()}-${fileName}-${Date().time}.xls" |
| | | val out = FileOutputStream(path + fileName) |
| | | val fileName = getReportName() |
| | | val file = File(path + fileName) |
| | | if (!file.parentFile.exists()) { |
| | | file.parentFile.mkdirs() |
| | | } |
| | | val out = FileOutputStream(file) |
| | | toOutputStream(out) |
| | | } |
| | | |