From 99be60a4c8c1f39eb01d414460cbe0ac76ca97d3 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 21 七月 2022 17:47:40 +0800
Subject: [PATCH] 1. 巡查汇总报告功能添加整改跟踪提醒统计列; 2. 新增获取巡查任务统计信息接口;
---
src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt | 55 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
index 3bd21a9..f69a607 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
@@ -2,11 +2,11 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.ss.util.CellRangeAddress
-import java.io.File
import java.io.OutputStream
import java.time.LocalDate
import java.util.*
import kotlin.math.max
+
/**
* @author riku
@@ -18,7 +18,8 @@
var text: String,
var rowSpan: Int = 1,
var colSpan: Int = 1,
- var fontColor: Short? = null
+ var fontColor: Short? = null,
+ var isPercent:Boolean = false
)
/**
@@ -88,15 +89,26 @@
when (c) {
is MyCell -> {
rows.createCell(col).apply {
- c.fontColor?.let {fC ->
- val font = workbook.createFont()
+ if (c.isPercent) {
val cellStyle = workbook.createCellStyle()
-
- font.color = fC
- cellStyle.setFont(font)
+ val format = workbook.createDataFormat()
+ cellStyle.dataFormat = format.getFormat("0.0%")
setCellStyle(cellStyle)
+ val v = c.text.toDoubleOrNull()
+ if (v != null) {
+ setCellValue(v)
+ }
+ } else {
+ c.fontColor?.let {fC ->
+ val font = workbook.createFont()
+ val cellStyle = workbook.createCellStyle()
+
+ font.color = fC
+ cellStyle.setFont(font)
+ setCellStyle(cellStyle)
+ }
+ setCellValue(c.text)
}
- setCellValue(c.text)
}
println("write1-1: ${c.text};($rowIndex, ${col})")
}
@@ -150,7 +162,28 @@
when (c) {
is MyCell -> {
- rows.createCell(map.key).setCellValue(c.text)
+ rows.createCell(col).apply {
+ if (c.isPercent) {
+ val cellStyle = workbook.createCellStyle()
+ val format = workbook.createDataFormat()
+ cellStyle.dataFormat = format.getFormat("0.0%")
+ setCellStyle(cellStyle)
+ val v = c.text.toDoubleOrNull()
+ if (v != null) {
+ setCellValue(v)
+ }
+ } else {
+ c.fontColor?.let {fC ->
+ val font = workbook.createFont()
+ val cellStyle = workbook.createCellStyle()
+
+ font.color = fC
+ cellStyle.setFont(font)
+ setCellStyle(cellStyle)
+ }
+ setCellValue(c.text)
+ }
+ }
println("write2-1: ${c.text};($_rowIndex, ${map.key})")
}
is String -> {
@@ -191,10 +224,6 @@
workbook.close()
out.flush()
out.close()
- }
-
- fun write3() {
-
}
private fun getMaxRows(rowArray: Array<Any>): Int {
--
Gitblit v1.9.3