11package org .dhatim .fastexcel .reader ;
22
33import org .junit .jupiter .api .Test ;
4+ import org .junit .jupiter .params .ParameterizedTest ;
5+ import org .junit .jupiter .params .provider .CsvSource ;
46
57import java .io .IOException ;
68import java .io .InputStream ;
9+ import java .math .BigDecimal ;
710
11+ import static org .assertj .core .api .Assertions .assertThat ;
812import static org .dhatim .fastexcel .reader .Resources .open ;
913import static org .junit .jupiter .api .Assertions .assertEquals ;
1014import static org .junit .jupiter .api .Assertions .assertNotNull ;
@@ -25,4 +29,49 @@ public void testGetCellByAddress() throws IOException {
2529 assertEquals (cellIndex0 , cellA1 );
2630 }
2731 }
32+
33+ @ ParameterizedTest
34+ @ CsvSource ({
35+ "0, false, 1, Lorem, 43101, 1+A1, true" ,
36+ "1, true, 2, ipsum, 43102, 1+A2, false" ,
37+ "2, true, 3, dolor, 43103, 1+A3, true" ,
38+ "3, false, 4, sit, 43104, 1+A4, false" ,
39+ "4, false, 5, amet, 43105, 1+A5, true" ,
40+ "5, false, 6, consectetur, 43106, 1+A6, false" ,
41+ "6, true, 7, adipiscing, 43107, 1+A7, true" ,
42+ "7, true, 8, elit, 43108, 1+A8, false" ,
43+ "8, true, 9, Ut, 43109, 1+A9, true" ,
44+ "9, false, 10, nec, 43110, 1+A10, false"
45+ })
46+ public void shouldGetVisibleAndHiddenRows (int index , boolean isHidden , String cellIndex0 , String cellIndex1 , int cellIndex2 , String cellIndex3 ,
47+ boolean cellIndex4 ) throws IOException {
48+ try (InputStream inputStream = open ("/xlsx/simple-with-hidden-rows.xlsx" );
49+ ReadableWorkbook excel = new ReadableWorkbook (inputStream )) {
50+ Sheet firstSheet = excel .getFirstSheet ();
51+
52+ Row row = firstSheet .read ().get (index );
53+
54+ assertThat (row .isHidden ()).isEqualTo (isHidden );
55+ assertThat (row .getCell (0 )).satisfies (cell -> {
56+ assertThat (cell .getType ()).isEqualTo (CellType .NUMBER );
57+ assertThat (cell .asNumber ()).isEqualTo (new BigDecimal (cellIndex0 ));
58+ });
59+ assertThat (row .getCell (1 )).satisfies (cell -> {
60+ assertThat (cell .getType ()).isEqualTo (CellType .STRING );
61+ assertThat (cell .asString ()).isEqualTo (cellIndex1 );
62+ });
63+ assertThat (row .getCell (2 )).satisfies (cell -> {
64+ assertThat (cell .getType ()).isEqualTo (CellType .NUMBER );
65+ assertThat (cell .asNumber ()).isEqualTo (new BigDecimal (cellIndex2 ));
66+ });
67+ assertThat (row .getCell (3 )).satisfies (cell -> {
68+ assertThat (cell .getType ()).isEqualTo (CellType .FORMULA );
69+ assertThat (cell .getFormula ()).isEqualTo (cellIndex3 );
70+ });
71+ assertThat (row .getCell (4 )).satisfies (cell -> {
72+ assertThat (cell .getType ()).isEqualTo (CellType .BOOLEAN );
73+ assertThat (cell .asBoolean ()).isEqualTo (cellIndex4 );
74+ });
75+ }
76+ }
2877}
0 commit comments