Skip to content

Commit

Permalink
* xlsx存在隐藏字符时需要忽略,确保和展示看到的一样
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangjiaju committed Apr 28, 2023
1 parent 770be56 commit 73b65d2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */

package com.alibaba.excel.analysis.v07.handlers.sax;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.alibaba.excel.cache.ReadCache;
import com.alibaba.excel.constant.ExcelXmlConstants;

import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Sax read sharedStringsTable.xml
*
Expand Down Expand Up @@ -146,7 +164,7 @@ static String utfDecode(String value) {

String code = m.group(1);
int icode = Integer.decode("0x" + code);
buf.append((char) icode);
buf.append((char)icode);

idx = m.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ public void t08() {
Assert.assertEquals(10L, list.size());
}

@Test
public void t09() {
// `SH_x005f_x000D_Z002` exists in `ShardingString.xml` and needs to be replaced by: `SH_x000D_Z002`
File file = TestFileUtil.readFile("compatibility/t09.xlsx");
List<Map<Integer, Object>> list = EasyExcel.read(file)
.headRowNumber(0)
.sheet()
.doReadSync();
log.info("data:{}", JSON.toJSONString(list));
Assert.assertEquals(1, list.size());

Assert.assertEquals("SH_x000D_Z002", list.get(0).get(0));
}

private List<SimpleData> data() {
List<SimpleData> list = new ArrayList<SimpleData>();
for (int i = 0; i < 10; i++) {
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions update.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* 读csv会忽略BOM数据 [Issue #3137](https://github.com/alibaba/easyexcel/issues/3137)
* 解决csv用office打开乱码的问题,写csv默认带上BOM数据
* xlsx存在隐藏字符时需要忽略,确保和展示看到的一样

# 3.2.1

Expand Down

0 comments on commit 73b65d2

Please sign in to comment.