Line 3
Link Here
|
|
|
3 |
import java.lang.reflect.Field; |
4 |
import java.util.ArrayList; |
5 |
import java.util.List; |
6 |
|
Line 5
Link Here
|
|
|
9 |
import org.apache.poi.hssf.record.ColumnInfoRecord; |
10 |
|
Line 74
Link Here
|
|
|
80 |
} |
81 |
|
82 |
public void testGetCellWidth() |
83 |
{ |
84 |
try{ |
85 |
Sheet sheet = Sheet.createSheet(); |
86 |
ColumnInfoRecord nci = ( ColumnInfoRecord ) sheet.createColInfo(); |
87 |
|
88 |
//prepare test model |
89 |
nci.setFirstColumn((short)5); |
90 |
nci.setLastColumn((short)10); |
91 |
nci.setColumnWidth((short)100); |
92 |
Field f = Sheet.class.getDeclaredField("columnSizes"); |
93 |
f.setAccessible(true); |
94 |
List columnSizes = new ArrayList(); |
95 |
f.set(sheet,columnSizes); |
96 |
columnSizes.add(nci); |
97 |
sheet.records.add(1 + sheet.dimsloc, nci); |
98 |
sheet.dimsloc++; |
99 |
|
100 |
assertEquals((short)100,sheet.getColumnWidth((short)5)); |
101 |
assertEquals((short)100,sheet.getColumnWidth((short)6)); |
102 |
assertEquals((short)100,sheet.getColumnWidth((short)7)); |
103 |
assertEquals((short)100,sheet.getColumnWidth((short)8)); |
104 |
assertEquals((short)100,sheet.getColumnWidth((short)9)); |
105 |
assertEquals((short)100,sheet.getColumnWidth((short)10)); |
106 |
|
107 |
sheet.setColumnWidth((short)6,(short)200); |
108 |
|
109 |
assertEquals((short)100,sheet.getColumnWidth((short)5)); |
110 |
assertEquals((short)200,sheet.getColumnWidth((short)6)); |
111 |
assertEquals((short)100,sheet.getColumnWidth((short)7)); |
112 |
assertEquals((short)100,sheet.getColumnWidth((short)8)); |
113 |
assertEquals((short)100,sheet.getColumnWidth((short)9)); |
114 |
assertEquals((short)100,sheet.getColumnWidth((short)10)); |
115 |
|
116 |
|
117 |
} |
118 |
catch(Exception e){e.printStackTrace();fail(e.getMessage());} |
119 |
|