mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
remove deprecated methods
This commit is contained in:
@@ -75,19 +75,6 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
||||
this(WorkbookUtil.createBook(bookFile), sheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetIndex sheet序号,0表示第一个sheet
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public ExcelReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
@@ -98,19 +85,6 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetName sheet名,第一个默认是sheet1
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public ExcelReader(InputStream bookStream, String sheetName, boolean closeAfterRead) {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
|
@@ -8,8 +8,6 @@ import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.PoiChecker;
|
||||
import cn.hutool.poi.excel.cell.CellLocation;
|
||||
import cn.hutool.poi.excel.sax.Excel03SaxReader;
|
||||
import cn.hutool.poi.excel.sax.Excel07SaxReader;
|
||||
import cn.hutool.poi.excel.sax.ExcelSaxReader;
|
||||
import cn.hutool.poi.excel.sax.ExcelSaxUtil;
|
||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
@@ -113,120 +111,6 @@ public class ExcelUtil {
|
||||
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
||||
reader.read(in, idOrRid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(InputStream, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(InputStream in, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(in, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param file 文件
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(File, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(File file, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(file, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param path 路径
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(String, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(String path, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(path, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(InputStream, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(in, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param file 文件
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(File, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(File file, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(file, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param path 路径
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(String, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(String path, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(path, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------ Read by Sax end
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ getReader
|
||||
@@ -308,24 +192,7 @@ public class ExcelUtil {
|
||||
* @return {@link ExcelReader}
|
||||
*/
|
||||
public static ExcelReader getReader(InputStream bookStream) {
|
||||
return getReader(bookStream, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
||||
* 默认调用第一个sheet
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public static ExcelReader getReader(InputStream bookStream, boolean closeAfterRead) {
|
||||
try {
|
||||
return getReader(bookStream, 0, closeAfterRead);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
return getReader(bookStream, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,25 +211,6 @@ public class ExcelUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetIndex sheet序号,0表示第一个sheet
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @since 4.0.3
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExcelReader getReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) {
|
||||
try {
|
||||
return new ExcelReader(bookStream, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
||||
* 读取结束自动关闭流
|
||||
@@ -379,24 +227,6 @@ public class ExcelUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetName sheet名,第一个默认是sheet1
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExcelReader getReader(InputStream bookStream, String sheetName, boolean closeAfterRead) {
|
||||
try {
|
||||
return new ExcelReader(bookStream, sheetName);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ getWriter
|
||||
|
||||
/**
|
||||
|
@@ -1039,20 +1039,6 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定单元格创建样式
|
||||
*
|
||||
* @param x X坐标,从0计数,即列号
|
||||
* @param y Y坐标,从0计数,即行号
|
||||
* @return {@link CellStyle}
|
||||
* @since 4.0.9
|
||||
* @deprecated 请使用 {@link #createCellStyle(int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CellStyle createStyleForCell(int x, int y) {
|
||||
return createCellStyle(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置某个单元格的样式<br>
|
||||
* 此方法用于多个单元格共享样式的情况<br>
|
||||
|
@@ -19,7 +19,7 @@ import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Excel工作簿{@link Workbook}相关工具类
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.7
|
||||
*
|
||||
@@ -28,7 +28,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFilePath Excel文件路径,绝对路径或相对于ClassPath路径
|
||||
* @return {@link Workbook}
|
||||
* @since 3.1.1
|
||||
@@ -39,7 +39,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link Workbook}
|
||||
*/
|
||||
@@ -49,13 +49,13 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建工作簿,用于Excel写出
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* 1. excelFile为null时直接返回一个空的工作簿,默认xlsx格式
|
||||
* 2. 文件已存在则通过流的方式读取到这个工作簿
|
||||
* 3. 文件不存在则检查传入文件路径是否以xlsx为扩展名,是则创建xlsx工作簿,否则创建xls工作簿
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link Workbook}
|
||||
* @since 4.5.18
|
||||
@@ -68,13 +68,13 @@ public class WorkbookUtil {
|
||||
if (excelFile.exists()) {
|
||||
return createBook(FileUtil.getInputStream(excelFile));
|
||||
}
|
||||
|
||||
|
||||
return createBook(StrUtil.endWithIgnoreCase(excelFile.getName(), ".xlsx"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿,只读模式
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @param password Excel工作簿密码,如果无密码传{@code null}
|
||||
* @return {@link Workbook}
|
||||
@@ -87,19 +87,6 @@ public class WorkbookUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link Workbook}
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createBook(InputStream)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Workbook createBook(InputStream in, boolean closeAfterRead) {
|
||||
return createBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
@@ -110,21 +97,6 @@ public class WorkbookUtil {
|
||||
return createBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param password 密码
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link Workbook}
|
||||
* @since 4.0.3
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createBook(InputStream, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Workbook createBook(InputStream in, String password, boolean closeAfterRead) {
|
||||
return createBook(in, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
@@ -145,7 +117,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 根据文件类型创建新的工作簿,文件路径
|
||||
*
|
||||
*
|
||||
* @param isXlsx 是否为xlsx格式的Excel
|
||||
* @return {@link Workbook}
|
||||
* @since 4.1.0
|
||||
@@ -162,7 +134,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFilePath Excel文件路径,绝对路径或相对于ClassPath路径
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
@@ -173,7 +145,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
@@ -184,7 +156,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿,只读模式
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @param password Excel工作簿密码,如果无密码传{@code null}
|
||||
* @return {@link SXSSFWorkbook}
|
||||
@@ -196,29 +168,13 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
* @since 5.7.1
|
||||
*/
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in, boolean closeAfterRead) {
|
||||
return createSXSSFBook(in, null, closeAfterRead);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param password 密码
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createSXSSFBook(InputStream, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in, String password, boolean closeAfterRead) {
|
||||
return toSXSSFBook(createBook(in, password, closeAfterRead));
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in) {
|
||||
return createSXSSFBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +191,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建SXSSFWorkbook,用于大批量数据写出
|
||||
*
|
||||
*
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
*/
|
||||
@@ -245,7 +201,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建SXSSFWorkbook,用于大批量数据写出
|
||||
*
|
||||
*
|
||||
* @param rowAccessWindowSize 在内存中的行数
|
||||
* @return {@link Workbook}
|
||||
* @since 4.1.13
|
||||
@@ -256,7 +212,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 将Excel Workbook刷出到输出流,不关闭流
|
||||
*
|
||||
*
|
||||
* @param book {@link Workbook}
|
||||
* @param out 输出流
|
||||
* @throws IORuntimeException IO异常
|
||||
@@ -273,7 +229,7 @@ public class WorkbookUtil {
|
||||
/**
|
||||
* 获取或者创建sheet表<br>
|
||||
* 如果sheet表在Workbook中已经存在,则获取之,否则创建之
|
||||
*
|
||||
*
|
||||
* @param book 工作簿{@link Workbook}
|
||||
* @param sheetName 工作表名
|
||||
* @return 工作表{@link Sheet}
|
||||
@@ -315,9 +271,9 @@ public class WorkbookUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* sheet是否为空
|
||||
*
|
||||
*
|
||||
* @param sheet {@link Sheet}
|
||||
* @return sheet是否为空
|
||||
* @since 4.0.1
|
||||
@@ -329,7 +285,7 @@ public class WorkbookUtil {
|
||||
// -------------------------------------------------------------------------------------------------------- Private method start
|
||||
/**
|
||||
* 将普通工作簿转换为SXSSFWorkbook
|
||||
*
|
||||
*
|
||||
* @param book 工作簿
|
||||
* @return SXSSFWorkbook
|
||||
* @since 4.1.13
|
||||
|
Reference in New Issue
Block a user