Commit e44443aba16f6b791ca2a896d6aa5d6d55fe1486
1 parent
334261a7
Exists in
master
optimized share table tag
Showing
3 changed files
with
12 additions
and
8 deletions
Show diff stats
build.gradle
src/main/java/com/taover/easyexcel/analysis/v07/handlers/sax/SharedStringsTableHandler.java
... | ... | @@ -12,11 +12,14 @@ import com.taover.easyexcel.cache.ReadCache; |
12 | 12 | */ |
13 | 13 | public class SharedStringsTableHandler extends DefaultHandler { |
14 | 14 | private static final String T_TAG = "t"; |
15 | + private static final String X_T_TAG = "x:t"; | |
15 | 16 | private static final String SI_TAG = "si"; |
17 | + private static final String X_SI_TAG = "x:si"; | |
16 | 18 | /** |
17 | 19 | * Mac 2016 2017 will have this extra field to ignore |
18 | 20 | */ |
19 | 21 | private static final String RPH_TAG = "rPh"; |
22 | + private static final String X_RPH_TAG = "x:rPh"; | |
20 | 23 | |
21 | 24 | /** |
22 | 25 | * The final piece of data |
... | ... | @@ -43,19 +46,19 @@ public class SharedStringsTableHandler extends DefaultHandler { |
43 | 46 | |
44 | 47 | @Override |
45 | 48 | public void startElement(String uri, String localName, String name, Attributes attributes) { |
46 | - if (T_TAG.equals(name)) { | |
49 | + if (T_TAG.equals(name) || X_T_TAG.equals(name)) { | |
47 | 50 | currentElementData = null; |
48 | 51 | isTagt = true; |
49 | - } else if (SI_TAG.equals(name)) { | |
52 | + } else if (SI_TAG.equals(name) || X_SI_TAG.equals(name)) { | |
50 | 53 | currentData = null; |
51 | - } else if (RPH_TAG.equals(name)) { | |
54 | + } else if (RPH_TAG.equals(name) || X_RPH_TAG.equals(name)) { | |
52 | 55 | ignoreTagt = true; |
53 | 56 | } |
54 | 57 | } |
55 | 58 | |
56 | 59 | @Override |
57 | 60 | public void endElement(String uri, String localName, String name) { |
58 | - if (T_TAG.equals(name)) { | |
61 | + if (T_TAG.equals(name) || X_T_TAG.equals(name)) { | |
59 | 62 | if (currentElementData != null) { |
60 | 63 | if (currentData == null) { |
61 | 64 | currentData = new StringBuilder(); |
... | ... | @@ -63,13 +66,13 @@ public class SharedStringsTableHandler extends DefaultHandler { |
63 | 66 | currentData.append(currentElementData); |
64 | 67 | } |
65 | 68 | isTagt = false; |
66 | - } else if (SI_TAG.equals(name)) { | |
69 | + } else if (SI_TAG.equals(name) || X_SI_TAG.equals(name)) { | |
67 | 70 | if (currentData == null) { |
68 | 71 | readCache.put(null); |
69 | 72 | } else { |
70 | 73 | readCache.put(currentData.toString()); |
71 | 74 | } |
72 | - } else if (RPH_TAG.equals(name)) { | |
75 | + } else if (RPH_TAG.equals(name) || X_RPH_TAG.equals(name)) { | |
73 | 76 | ignoreTagt = false; |
74 | 77 | } |
75 | 78 | } | ... | ... |
src/test/java/com/taover/easyexcel/test/WbTest.java
... | ... | @@ -11,7 +11,8 @@ import com.taover.easyexcel.EasyExcel; |
11 | 11 | public class WbTest { |
12 | 12 | public static void main(String[] args) { |
13 | 13 | //File dataFile = new File("C:\\Users\\Administrator\\Desktop\\数据为空\\好合意商城_20210127_16_47(1).xlsx"); |
14 | - File dataFile = new File("C:\\Users\\Administrator\\Desktop\\Excel隐藏行\\配送确认1.16(1).xlsx"); | |
14 | + //File dataFile = new File("C:\\Users\\Administrator\\Desktop\\Excel隐藏行\\配送确认1.16(1).xlsx"); | |
15 | + File dataFile = new File("C:\\Users\\Administrator\\Desktop\\Excel隐藏行\\吉祥三宝-20210128-29条(1).xlsx"); | |
15 | 16 | //File dataFile = new File("C:\\Users\\Administrator\\Desktop\\表头匹配-测试文件\\多sheet-多个可用-数据有无.xlsx"); |
16 | 17 | // List<List<Object>> data = transListMapTo2List(EasyExcel.read(dataFile).readHiddenRow(false).headRowNumber(0).doReadSelectedSync()); |
17 | 18 | // for(List<Object> row: data) { | ... | ... |