mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
ExcelWriter.autoSizeColumn增加可选widthRatio参数,可配置中文字符宽度倍数
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user