mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
增加ExcelWriter.addIgnoredErrors,支持忽略警告小标
This commit is contained in:
parent
0b7133a185
commit
3ca8babb84
@ -14,8 +14,10 @@ package org.dromara.hutool.poi.excel;
|
||||
|
||||
import org.apache.poi.common.usermodel.Hyperlink;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.dromara.hutool.core.bean.BeanUtil;
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.comparator.IndexedComparator;
|
||||
@ -561,6 +563,26 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置忽略错误,即Excel中的绿色警告小标,只支持XSSFSheet<br>
|
||||
* 见:https://stackoverflow.com/questions/23488221/how-to-remove-warning-in-excel-using-apache-poi-in-java
|
||||
*
|
||||
* @param cellRangeAddress 指定单元格范围
|
||||
* @param ignoredErrorTypes 忽略的错误类型列表
|
||||
* @return this
|
||||
* @throws UnsupportedOperationException 如果sheet不是XSSFSheet
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public ExcelWriter addIgnoredErrors(final CellRangeAddress cellRangeAddress, final IgnoredErrorType... ignoredErrorTypes) throws UnsupportedOperationException {
|
||||
final Sheet sheet = this.sheet;
|
||||
if (sheet instanceof XSSFSheet) {
|
||||
((XSSFSheet) sheet).addIgnoredErrors(cellRangeAddress, ignoredErrorTypes);
|
||||
return this;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Only XSSFSheet supports addIgnoredErrors");
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加下拉列表
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user