@@ -155,29 +155,8 @@ private static void exportTable(Sheet sheet, ODLTableReadOnly table,int firstOut
155
155
Row row = sheet .createRow (firstOutputRow + 1 + srcRow );
156
156
for (int col = 0 ; col < nc ; col ++) {
157
157
Cell cell = row .createCell (col );
158
- switch (table .getColumnType (col )){
159
- case LONG :
160
- case DOUBLE :
161
- Number dVal = (Number )table .getValueAt (srcRow , col );
162
- if (dVal !=null ){
163
- cell .setCellValue (dVal .doubleValue ());
164
- }else {
165
- cell .setCellValue ((String )null );
166
- }
167
- cell .setCellType (Cell .CELL_TYPE_NUMERIC );
168
- break ;
169
- default :
170
- String sval = TableUtils .getValueAsString (table , srcRow , col );
171
- if (sval != null ) {
172
- if (sval .length () >= MAX_CHAR_COUNT_IN_EXCEL_CELL ) {
173
- nbOversized ++;
174
- }
175
- cell .setCellValue (sval .toString ());
176
- } else {
177
- cell .setCellValue ((String ) null );
178
- }
179
- cell .setCellType (Cell .CELL_TYPE_STRING );
180
- break ;
158
+ if (saveElementToCell (table , srcRow , col , cell )==SaveElementResult .OVERSIZED ){
159
+ nbOversized ++;
181
160
}
182
161
183
162
}
@@ -187,6 +166,48 @@ private static void exportTable(Sheet sheet, ODLTableReadOnly table,int firstOut
187
166
report .log (getOversizedWarningMessage (nbOversized , table .getName ()));
188
167
}
189
168
}
169
+
170
+ public enum SaveElementResult {
171
+ OK ,
172
+ OVERSIZED
173
+ }
174
+
175
+ /**
176
+ * @param table
177
+ * @param row
178
+ * @param col
179
+ * @param cell
180
+ * @param nbOversized
181
+ * @return
182
+ */
183
+ public static SaveElementResult saveElementToCell (ODLTableReadOnly table , int row , int col , Cell cell ) {
184
+ boolean oversized =false ;
185
+ switch (table .getColumnType (col )){
186
+ case LONG :
187
+ case DOUBLE :
188
+ Number dVal = (Number )table .getValueAt (row , col );
189
+ if (dVal !=null ){
190
+ cell .setCellValue (dVal .doubleValue ());
191
+ }else {
192
+ cell .setCellValue ((String )null );
193
+ }
194
+ cell .setCellType (Cell .CELL_TYPE_NUMERIC );
195
+ break ;
196
+ default :
197
+ String sval = TableUtils .getValueAsString (table , row , col );
198
+ if (sval != null ) {
199
+ if (sval .length () >= MAX_CHAR_COUNT_IN_EXCEL_CELL ) {
200
+ oversized =true ;
201
+ }
202
+ cell .setCellValue (sval .toString ());
203
+ } else {
204
+ cell .setCellValue ((String ) null );
205
+ }
206
+ cell .setCellType (Cell .CELL_TYPE_STRING );
207
+ break ;
208
+ }
209
+ return oversized ? SaveElementResult .OVERSIZED : SaveElementResult .OK ;
210
+ }
190
211
191
212
public static String getOversizedWarningMessage (int nbOversized , String tableName ) {
192
213
String s = "Found " + nbOversized + " cell(s) in table \" " + tableName + "\" longer than maximum Excel cell length ("
0 commit comments