← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18909: Check for max columns for excel tables, must respect legacy limit of 256 cols for JXL API

 

------------------------------------------------------------
revno: 18909
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-15 18:48:14 +0200
message:
  Check for max columns for excel tables, must respect legacy limit of 256 cols for JXL API
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java	2015-03-31 12:52:08 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java	2015-04-15 16:48:14 +0000
@@ -104,6 +104,7 @@
     
     private static final String EMPTY = "";    
     private static final String XLS_SHEET_PREFIX = "Sheet ";
+    private static final int JXL_MAX_COLS = 256;
     
     private static final NodeFilter HTML_ROW_FILTER = new OrFilter( new TagNameFilter( "td" ), new TagNameFilter( "th" ) );    
     
@@ -271,6 +272,13 @@
             return;
         }
         
+        int cols = grid.getVisibleHeaders().size();
+        
+        if ( cols > JXL_MAX_COLS )
+        {
+            log.warn( "Grid will be truncated, no of columns is greater than JXL max limit: " + cols + "/" + JXL_MAX_COLS );
+        }
+        
         WritableSheet sheet = workbook.createSheet( sheetName, sheetNo );
 
         int rowNumber = 1;
@@ -312,6 +320,11 @@
                     
                     sheet.addCell( new Label( columnIndex++, rowNumber, content, XLS_FORMAT_TEXT ) );
                 }
+                
+                if ( columnIndex >= JXL_MAX_COLS )
+                {
+                    break;
+                }
             }
 
             rowNumber++;


Follow ups