-
-
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 branch 'jmorgan-iad-master' into 4.1.2
- Loading branch information
Showing
5 changed files
with
84 additions
and
1 deletion.
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
46 changes: 46 additions & 0 deletions
46
src/test/java/com/poiji/deserialize/RawValueFormulaTest.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,46 @@ | ||
package com.poiji.deserialize; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.poiji.bind.Poiji; | ||
import com.poiji.deserialize.model.RowModelFormula; | ||
import com.poiji.option.PoijiOptions; | ||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
/** | ||
* Created by jmorgan on 12.09.2023 | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class RawValueFormulaTest { | ||
|
||
private String path; | ||
|
||
public RawValueFormulaTest(String path) { | ||
this.path = path; | ||
} | ||
|
||
@Parameterized.Parameters(name = "{index}: ({0})={1}") | ||
public static Iterable<Object[]> queries() { | ||
return Arrays.asList(new Object[][]{ | ||
{"src/test/resources/raw_value_formula.xls"}, | ||
{"src/test/resources/raw_value_formula.xlsx"}, | ||
}); | ||
} | ||
|
||
@Test | ||
public void shouldMapCalculations() { | ||
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings().headerCount(0).rawData(true).build(); | ||
List<RowModelFormula> models = Poiji.fromExcel(new File(path), RowModelFormula.class, options); | ||
|
||
for (RowModelFormula model : models) { | ||
assertThat(model.getCurrencyValue(), is(123.45D)); | ||
assertThat(model.getFormulaValue(), is(246.90D)); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/test/java/com/poiji/deserialize/model/RowModelFormula.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,31 @@ | ||
package com.poiji.deserialize.model; | ||
|
||
import com.poiji.annotation.ExcelCell; | ||
|
||
/** | ||
* Created by jmorgan on 12.09.2023 | ||
*/ | ||
public class RowModelFormula { | ||
|
||
@ExcelCell(0) | ||
private double currencyValue; | ||
|
||
@ExcelCell(1) | ||
private double formulaValue; | ||
|
||
public double getCurrencyValue() { | ||
return currencyValue; | ||
} | ||
|
||
public void setCurrencyValue(double currencyValue) { | ||
this.currencyValue = currencyValue; | ||
} | ||
|
||
public double getFormulaValue() { | ||
return formulaValue; | ||
} | ||
|
||
public void setFormulaValue(double formulaValue) { | ||
this.formulaValue = formulaValue; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.