File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
tang-commons/src/main/kotlin/com/tang/commons/utils/poi Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change 22
22
23
23
* Add questionnaire system
24
24
* Add compute string width method
25
+ * Add ` Excel ` export width auto size
25
26
26
27
## 1.6.6
27
28
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.tang.commons.constants.ContentType
6
6
import com.tang.commons.constants.FileType
7
7
import com.tang.commons.enumeration.poi.Type
8
8
import com.tang.commons.exception.file.FileTypeMismatchException
9
+ import com.tang.commons.kotlin.extensions.width
9
10
import com.tang.commons.utils.Assert
10
11
import com.tang.commons.utils.DictUtils
11
12
import com.tang.commons.utils.LogUtils
@@ -396,7 +397,8 @@ object Excels {
396
397
cell.cellStyle = cellStyle
397
398
398
399
// 设置列宽
399
- sheet.setColumnWidth(lastCellNum, excel.width * 256 )
400
+ val width = if (excel.width == - 1 ) excel.name.width() + 1 else excel.width
401
+ sheet.setColumnWidth(lastCellNum, width * 256 )
400
402
401
403
// 设置行高
402
404
titleRow.height = (excel.titleHeight * 20 ).toShort()
You can’t perform that action at this time.
0 commit comments