1
0
mirror of https://gitee.com/dromara/hutool.git synced 2025-04-05 17:37:59 +08:00

ExcelWriter.autoSizeColumn增加可选widthRatio参数,可配置中文字符宽度倍数

This commit is contained in:
Looly 2024-08-08 11:23:32 +08:00
parent 0aaa9019ad
commit a05fb1a000
3 changed files with 4 additions and 6 deletions
CHANGELOG.md
hutool-poi/src/main/java/cn/hutool/poi/excel

View File

@ -16,6 +16,7 @@
* 【core 】 优化IndexedComparator性能pr#1240@Gitee
* 【http 】 改进ContentType.get忽略空格pr#3664@Github
* 【http 】 CompressUtil.createExtractor支持tgz自动识别pr#3674@Github
* 【poi 】 ExcelWriter.autoSizeColumn增加可选widthRatio参数可配置中文字符宽度倍数pr#3689@Github
### 🐞Bug修复
* 【core 】 修复因RFC3986理解有误导致的UrlPath处理冒号转义问题issue#IAAE88@Gitee

View File

@ -152,11 +152,7 @@ public class BigExcelWriter extends ExcelWriter {
@Override
public BigExcelWriter autoSizeColumnAll() {
final SXSSFSheet sheet = (SXSSFSheet) this.sheet;
sheet.trackAllColumnsForAutoSizing();
super.autoSizeColumnAll();
sheet.untrackAllColumnsForAutoSizing();
return this;
return autoSizeColumnAll(0);
}
@Override

View File

@ -305,9 +305,10 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* @since 5.8.30
*/
public ExcelWriter autoSizeColumn(int columnIndex, boolean useMergedCells, float widthRatio) {
sheet.autoSizeColumn(columnIndex, useMergedCells);
if (widthRatio > 0) {
sheet.setColumnWidth(columnIndex, (int) (sheet.getColumnWidth(columnIndex) * widthRatio));
} else {
sheet.autoSizeColumn(columnIndex, useMergedCells);
}
return this;
}