Skip to content

Commit

Permalink
Merge pull request #2464 from fufeii/developing
Browse files Browse the repository at this point in the history
fix #2227 读取csv文件时autoTrim配置失效
  • Loading branch information
zhuangjiaju authored May 11, 2022
2 parents 589aacb + 6db9e14 commit 4446d63
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private void dealRecord(CSVRecord record, int rowIndex) {
Map<Integer, Cell> cellMap = new LinkedHashMap<>();
Iterator<String> cellIterator = record.iterator();
int columnIndex = 0;
Boolean autoTrim = csvReadContext.currentReadHolder().globalConfiguration().getAutoTrim();
while (cellIterator.hasNext()) {
String cellString = cellIterator.next();
ReadCellData<String> readCellData = new ReadCellData<>();
Expand All @@ -105,7 +106,7 @@ private void dealRecord(CSVRecord record, int rowIndex) {
// csv is an empty string of whether <code>,,</code> is read or <code>,"",</code>
if (StringUtils.isNotBlank(cellString)) {
readCellData.setType(CellDataTypeEnum.STRING);
readCellData.setStringValue(cellString);
readCellData.setStringValue(autoTrim ? cellString.trim() : cellString);
} else {
readCellData.setType(CellDataTypeEnum.EMPTY);
}
Expand Down

0 comments on commit 4446d63

Please sign in to comment.