mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
增加GlobalPoiConfig
This commit is contained in:
parent
52dad763a0
commit
12aa680335
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2024. looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* https://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.poi;
|
||||
|
||||
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
||||
|
||||
/**
|
||||
* POI的全局设置
|
||||
*
|
||||
* @author Looly
|
||||
* @see ZipSecureFile
|
||||
* @since 5.8.30
|
||||
*/
|
||||
public class GlobalPoiConfig {
|
||||
|
||||
/**
|
||||
* 设置解压时的最小压缩比例<br>
|
||||
* 为了避免`Zip Bomb`,POI中设置了最小压缩比例,这个比例为:
|
||||
* <pre>
|
||||
* 压缩后的大小/解压后的大小
|
||||
* </pre>
|
||||
* <p>
|
||||
* POI的默认值是0.01(即最小压缩到1%),如果文档中的文件压缩比例小于这个值,就会报错。<br>
|
||||
* 如果文件中确实存在高压缩比的文件,可以通过这个全局方法自定义比例,从而避免错误。
|
||||
*
|
||||
* @param ratio 解压后的文件大小与原始文件大小的最小比率,小于等于0表示不检查
|
||||
*/
|
||||
public static void setMinInflateRatio(final double ratio) {
|
||||
ZipSecureFile.setMinInflateRatio(ratio);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单个Zip文件中最大文件大小,默认为4GB,即32位zip格式的最大值。
|
||||
*
|
||||
* @param maxEntrySize 单个Zip文件中最大文件大小,必须大于0
|
||||
*/
|
||||
public static void setMaxEntrySize(final long maxEntrySize) {
|
||||
ZipSecureFile.setMaxEntrySize(maxEntrySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置解压前文本的最大字符数,超过抛出异常。
|
||||
*
|
||||
* @param maxTextSize 文本的最大字符数
|
||||
* @throws IllegalArgumentException for negative maxTextSize
|
||||
*/
|
||||
public static void setMaxTextSize(final long maxTextSize) {
|
||||
ZipSecureFile.setMaxTextSize(maxTextSize);
|
||||
}
|
||||
}
|
@ -22,8 +22,6 @@ import java.io.File;
|
||||
*/
|
||||
public class WordUtil {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建Word 07格式的生成器
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user