package cn.flightfeather.supervision.business.location
|
|
import cn.flightfeather.supervision.common.utils.DateUtil
|
import cn.flightfeather.supervision.common.utils.ExcelUtil
|
import cn.flightfeather.supervision.domain.ds1.entity.Scense
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
import java.io.File
|
import java.io.FileOutputStream
|
import java.util.*
|
|
/**
|
*
|
* @date 2024/10/24
|
* @author feiyu02
|
*/
|
class UtilExcelDistance(head: List<Array<Any>>) {
|
|
private val heads = mutableListOf<Array<Any>>()
|
private val contents = mutableListOf<Array<Any>>()
|
var index = 1
|
|
init {
|
heads.addAll(head)
|
}
|
|
fun reset() {
|
index = 1
|
contents.clear()
|
}
|
|
fun addRow(row: List<Any>) {
|
contents.add(row.toTypedArray())
|
}
|
|
fun updateLastRow(index: Int, cell: Any) {
|
contents.last()[index] = cell
|
}
|
|
/**
|
* 生成一行excel数据
|
*/
|
fun parseRow(row: Array<Any>) {
|
contents.add(row)
|
index++
|
}
|
|
fun outPutToFile(districtName: String) {
|
val workbook = HSSFWorkbook()
|
val fileName = "${districtName}点位距国控点距离-${DateUtil.DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls"
|
val filePath = "C:\\work\\工作\\第三方监管\\点位距国控点距离\\$fileName"
|
val file = File(filePath)
|
if (!file.parentFile.exists()) {
|
file.parentFile.mkdirs()
|
}
|
val out = FileOutputStream(file)
|
ExcelUtil.write(heads, contents, workbook)
|
workbook.write(out)
|
workbook.close()
|
out.flush()
|
out.close()
|
}
|
}
|