forked from alibaba/easyexcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alibaba#3132 from gongxuanzhang/fix_utfdecode
Fix utf decode
- Loading branch information
Showing
4 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/rare/ReadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.alibaba.easyexcel.test.demo.rare; | ||
|
||
import com.alibaba.easyexcel.test.util.TestFileUtil; | ||
import com.alibaba.excel.EasyExcel; | ||
import org.apache.poi.xssf.usermodel.XSSFRow; | ||
import org.apache.poi.xssf.usermodel.XSSFSheet; | ||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* 记录一些不太常见的案例 | ||
* | ||
* @author gxz gongxuanzhang@foxmail.com | ||
**/ | ||
public class ReadTest { | ||
|
||
|
||
/** | ||
* 当excel有需要转义的 如x005特殊符号时需要通过utf decode解码 | ||
**/ | ||
@Test | ||
public void readX005() throws Exception { | ||
String fileName = TestFileUtil.pathBuild().sub("temp").sub("utfdecode").sub("demo.xlsx").getPath(); | ||
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(fileName); | ||
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); | ||
XSSFRow row = xssfSheet.getRow(0); | ||
String poiValue = row.getCell(0).getStringCellValue(); | ||
List<Map<Integer, Object>> list = EasyExcel.read(fileName) | ||
.sheet(0) | ||
.headRowNumber(0).doReadSync(); | ||
Map<Integer, Object> easyExcelRow = list.get(0); | ||
Assert.assertEquals(easyExcelRow.get(0).toString(), poiValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.