-
-
Notifications
You must be signed in to change notification settings - Fork 133
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 #71 from ozlerhakan/1.19.2
version 1.19.2
- Loading branch information
Showing
17 changed files
with
247 additions
and
86 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
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
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 |
---|---|---|
|
@@ -13,8 +13,4 @@ | |
@Target(ElementType.FIELD) | ||
@Documented | ||
public @interface ExcelCellRange { | ||
|
||
int begin() default 0; | ||
int end(); | ||
|
||
} |
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
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
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
54 changes: 54 additions & 0 deletions
54
src/test/java/com/poiji/deserialize/DeserializerCaseTest.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,54 @@ | ||
package com.poiji.deserialize; | ||
|
||
import com.poiji.bind.Poiji; | ||
import com.poiji.deserialize.model.ProductExcelDTO; | ||
import com.poiji.exception.PoijiExcelType; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* Created by hakan on 2019-01-10 | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class DeserializerCaseTest { | ||
|
||
private String path; | ||
private PoijiExcelType poijiExcelType; | ||
|
||
public DeserializerCaseTest(String path, PoijiExcelType type) { | ||
this.path = path; | ||
this.poijiExcelType = type; | ||
} | ||
|
||
@Parameterized.Parameters(name = "{index}: ({0})={1}") | ||
public static Iterable<Object[]> queries() { | ||
return Arrays.asList(new Object[][]{ | ||
{"src/test/resources/test.xlsx", PoijiExcelType.XLSX}, | ||
{"src/test/resources/test.xls", PoijiExcelType.XLS}, | ||
}); | ||
} | ||
|
||
@Test | ||
public void shouldMapExcelToJava() { | ||
try (InputStream stream = new FileInputStream(new File(path))) { | ||
List<ProductExcelDTO> products = Poiji.fromExcel(stream, poijiExcelType, ProductExcelDTO.class); | ||
assertThat(products, notNullValue()); | ||
assertThat(products.size(), not(0)); | ||
} catch (IOException e) { | ||
fail(e.getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
351e497
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to jump in, I tested the excel and java objects that fermartinez1 posted with the 1.19.1 and it worked for both xls and xlsx. The excelcellrange is for cases when the column names are not unique and so the range is meant to differentiate which name belongs to which object.
I'm going to look further into why it happened in the master branch.
351e497
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kpolli , I made some changes in @ExcelCellRange. From now on, we don't need to give a range on this annotation. and the part that I totally overlooked is the header names. The header names must be unique always. Please look at the updated readme file, example 4.