mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 20:58:00 +08:00
add method
This commit is contained in:
parent
95854cddb1
commit
06cc38734c
@ -27,6 +27,7 @@
|
|||||||
* 【core 】 ReflectUtil.getMethod排除桥接方法(pr#1965@Github)
|
* 【core 】 ReflectUtil.getMethod排除桥接方法(pr#1965@Github)
|
||||||
* 【http 】 completeFileNameFromHeader在使用path为路径时,自动解码(issue#I4K0FS@Gitee)
|
* 【http 】 completeFileNameFromHeader在使用path为路径时,自动解码(issue#I4K0FS@Gitee)
|
||||||
* 【core 】 CopyOptions增加override配置(issue#I4JQ1N@Gitee)
|
* 【core 】 CopyOptions增加override配置(issue#I4JQ1N@Gitee)
|
||||||
|
* 【poi 】 SheetRidReader可以获取所有sheet名(issue#I4JA3M@Gitee)
|
||||||
*
|
*
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复FileResource构造fileName参数无效问题(issue#1942@Github)
|
* 【core 】 修复FileResource构造fileName参数无效问题(issue#1942@Github)
|
||||||
|
@ -202,7 +202,7 @@ public class Excel07SaxReader implements ExcelSaxReader<Excel07SaxReader> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sheetIndex需转换为rid
|
// sheetIndex需转换为rid
|
||||||
final SheetRidReader ridReader = new SheetRidReader().read(xssfReader);
|
final SheetRidReader ridReader = SheetRidReader.parse(xssfReader);
|
||||||
|
|
||||||
if (StrUtil.startWithIgnoreCase(idOrRidOrSheetName, SHEET_NAME_PREFIX)) {
|
if (StrUtil.startWithIgnoreCase(idOrRidOrSheetName, SHEET_NAME_PREFIX)) {
|
||||||
// name:开头的被认为是sheet名称直接处理
|
// name:开头的被认为是sheet名称直接处理
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.poi.excel.sax;
|
package cn.hutool.poi.excel.sax;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -13,6 +14,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +34,17 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class SheetRidReader extends DefaultHandler {
|
public class SheetRidReader extends DefaultHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从{@link XSSFReader}中解析sheet名、sheet id等相关信息
|
||||||
|
*
|
||||||
|
* @param reader {@link XSSFReader}
|
||||||
|
* @return SheetRidReader
|
||||||
|
* @since 5.7.17
|
||||||
|
*/
|
||||||
|
public static SheetRidReader parse(XSSFReader reader) {
|
||||||
|
return new SheetRidReader().read(reader);
|
||||||
|
}
|
||||||
|
|
||||||
private final static String TAG_NAME = "sheet";
|
private final static String TAG_NAME = "sheet";
|
||||||
private final static String RID_ATTR = "r:id";
|
private final static String RID_ATTR = "r:id";
|
||||||
private final static String SHEET_ID_ATTR = "sheetId";
|
private final static String SHEET_ID_ATTR = "sheetId";
|
||||||
@ -137,6 +150,16 @@ public class SheetRidReader extends DefaultHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有sheet名称
|
||||||
|
*
|
||||||
|
* @return sheet名称
|
||||||
|
* @since 5.7.17
|
||||||
|
*/
|
||||||
|
public List<String> getSheetNames() {
|
||||||
|
return ListUtil.toList(this.NAME_RID_MAP.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||||
if (TAG_NAME.equalsIgnoreCase(localName)) {
|
if (TAG_NAME.equalsIgnoreCase(localName)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user