Skip to content

Commit 27db055

Browse files
authored
Merge pull request #253 from ozlerhakan/3.1.9
dump version 3.1.9
2 parents 2e9827c + a173057 commit 27db055

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

README.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
:toclevels: 2
33

44
= Poiji
5-
:version: v3.1.8
6-
:branch: 3.1.8
5+
:version: v3.1.9
6+
:branch: 3.1.9
77

88
image:https://github.com/ozlerhakan/poiji/actions/workflows/maven.yml/badge.svg["Build Status"] image:https://app.codacy.com/project/badge/Grade/64f7e2cb9e604807b62334a4cfc3952d["Codacy code quality",link="https://www.codacy.com/gh/ozlerhakan/poiji/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"]
99
image:https://codecov.io/gh/ozlerhakan/poiji/branch/{branch}/graph/badge.svg?token=MN6V6xOWBq["Codecov",link="https://codecov.io/gh/ozlerhakan/poiji"] image:https://img.shields.io/badge/apache.poi-5.2.1-brightgreen.svg[] image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji.svg?type=shield["FOSSA Status",link="https://app.fossa.com/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji?ref=badge_shield"]
@@ -25,15 +25,15 @@ In your Maven/Gradle project, first add the corresponding dependency:
2525
<dependency>
2626
<groupId>com.github.ozlerhakan</groupId>
2727
<artifactId>poiji</artifactId>
28-
<version>3.1.8</version>
28+
<version>3.1.9</version>
2929
</dependency>
3030
----
3131

3232
.gradle
3333
[source,groovy]
3434
----
3535
dependencies {
36-
compile 'com.github.ozlerhakan:poiji:3.1.8'
36+
compile 'com.github.ozlerhakan:poiji:3.1.9'
3737
}
3838
----
3939

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.ozlerhakan</groupId>
88
<artifactId>poiji</artifactId>
9-
<version>3.1.8</version>
9+
<version>3.1.9</version>
1010
<packaging>jar</packaging>
1111

1212
<name>poiji</name>

src/main/java/com/poiji/bind/mapping/PoijiHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ public void endRow(int rowNum) {
199199

200200
@Override
201201
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
202+
if (cellReference == null) {
203+
// TODO hidden log required; a cell reference could return null
204+
return;
205+
}
202206
final CellAddress cellAddress = new CellAddress(cellReference);
203207
int row = cellAddress.getRow();
204208
int headerStart = options.getHeaderStart();

src/main/java/com/poiji/bind/mapping/XSSFSheetXMLPoijiHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public void startElement(String uri, String localName, String qName, Attributes
5252
!"e".equals(cellType) &&
5353
!"inlineStr".equals(cellType) &&
5454
!"s".equals(cellType) &&
55-
!"str".equals(cellType)) {
56-
if (cellStyleStr != null) {
57-
int styleIndex = Integer.parseInt(cellStyleStr);
55+
!"str".equals(cellType) &&
56+
cellStyleStr != null) {
57+
int styleIndex = Integer.parseInt(cellStyleStr);
5858

59-
if (poijiOptions.isDisableXLSXNumberCellFormat()) {
60-
attributes2.removeAttribute(styleIndex);
61-
}
59+
if (poijiOptions.isDisableXLSXNumberCellFormat() &&
60+
attributes2.getLength() > styleIndex) {
61+
attributes2.removeAttribute(styleIndex);
6262
}
6363
}
6464
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.poiji.deserialize;
2+
3+
import com.poiji.bind.Poiji;
4+
import com.poiji.deserialize.model.AutoImport;
5+
import com.poiji.option.PoijiOptions;
6+
import org.junit.Test;
7+
8+
import java.io.File;
9+
import java.util.List;
10+
11+
import static org.hamcrest.CoreMatchers.is;
12+
import static org.hamcrest.MatcherAssert.assertThat;
13+
import static org.junit.Assert.assertNotNull;
14+
import static org.junit.Assert.assertNull;
15+
16+
public class NullReferenceTest {
17+
18+
@Test
19+
public void shouldReturnEmptyWhenCellReferenceNull() {
20+
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings().disableXLSXNumberCellFormat().build();
21+
22+
List<AutoImport> result = Poiji.fromExcel(new File("src/test/resources/autos2.xlsx"), AutoImport.class, options);
23+
24+
assertNotNull(result);
25+
assertThat(result.size(), is(20));
26+
assertNull(result.get(0).getPmercado());
27+
28+
}
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.poiji.deserialize.model;
2+
3+
import com.poiji.annotation.ExcelCell;
4+
5+
public class AutoImport {
6+
7+
@ExcelCell(7)
8+
private Double pmercado;
9+
10+
public Double getPmercado() {
11+
return pmercado;
12+
}
13+
}

src/test/resources/autos2.xlsx

7.08 KB
Binary file not shown.

0 commit comments

Comments
 (0)