Changes for page Development-Excel Generation
Last modified by Pascal Robert on 2010/09/13 00:35
From version 4.1
edited by Pascal Robert
on 2007/09/03 15:14
on 2007/09/03 15:14
Change comment:
There is no comment for this version
To version 3.1
edited by Quinton Dolan
on 2007/07/12 20:44
on 2007/07/12 20:44
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -Web Applications-Development-Excel Generation 1 +Programming__WebObjects-Web Applications-Development-Excel Generation - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. probert1 +XWiki.qdolan - Content
-
... ... @@ -1,4 +1,4 @@ 1 -For a "clean" copy of this file, head over to [[http://www.overhyped.com./downloads/OTCPOIArchive.java]]1 +For a "clean" copy of this file, head over to http:~/~/www.overhyped.com./downloads/OTCPOIArchive.java 2 2 3 3 {{code}} 4 4 ... ... @@ -48,7 +48,7 @@ 48 48 public void setLocalContext(D2WContext d2w) { 49 49 d2wContext = d2w; 50 50 } 51 - 51 + 52 52 /** Returns the current EOEnterpriseObject. */ 53 53 public EOEnterpriseObject object() { 54 54 return object; ... ... @@ -57,16 +57,16 @@ 57 57 public void setObject(EOEnterpriseObject newEO) { 58 58 object = newEO; 59 59 } 60 - 61 - /** Creates an Excel Spreadsheet using Apache's POI project. If the objectArray 62 - * is null or empty, this method will fetch all objects from the database for 60 + 61 + /** Creates an Excel Spreadsheet using Apache's POI project. If the objectArray 62 + * is null or empty, this method will fetch all objects from the database for 63 63 * the given entityNameForArchive. If the entityNameForArchive is null or 64 - * empty, this method will fetch all entities and iterate over them, while 65 - * fetching all objects for each entityName. This method will use aKey to set 66 - * an Integer into the target, allowing for feedback while the calculation is 67 - * occurring. The resulting file can be found in the /excel/ directory of the 64 + * empty, this method will fetch all entities and iterate over them, while 65 + * fetching all objects for each entityName. This method will use aKey to set 66 + * an Integer into the target, allowing for feedback while the calculation is 67 + * occurring. The resulting file can be found in the /excel/ directory of the 68 68 * WebServer. */ 69 - public String calculate(NSArray objectArray, String entityNameForArchive, String aKey, WOComponent target) { 69 + public String calculate(NSArray objectArray, String entityNameForArchive, String aKey, WOComponent target) { 70 70 71 71 try { 72 72 EOEditingContext ec; ... ... @@ -82,7 +82,7 @@ 82 82 String attribute, attribute2, value; 83 83 short r; 84 84 EOEnterpriseObject item; 85 - 85 + 86 86 // set up the d2wcontext 87 87 if (d2wContext() == null) setLocalContext( new D2WContext(target.session()) ); 88 88 // set the task for archive ... ... @@ -93,7 +93,7 @@ 93 93 wb = new HSSFWorkbook(); 94 94 // get the entities 95 95 if ((entityNameForArchive == null) || (entityNameForArchive.length() == 0)) { 96 - entities = D2WUtils.allEntities(); 96 + entities = D2WUtils.allEntities(); 97 97 objectArray = null; // if there's no entity name, we'd better clear out any objects. 98 98 } 99 99 else { ... ... @@ -106,7 +106,7 @@ 106 106 // enumerate 107 107 while (entityEnum.hasMoreElements()) { 108 108 // get the next entity 109 - eName = ((EOEntity)entityEnum.nextElement()).name(); 109 + eName = ((EOEntity)entityEnum.nextElement()).name(); 110 110 // set the entity into the D2WContext 111 111 d2wContext().setEntity(EOUtilities.entityNamed(ec, eName)); 112 112 // get all objects for this entity ... ... @@ -183,7 +183,7 @@ 183 183 sCount++; 184 184 // clear out the objectArray, since there's another entity 185 185 objectArray = null; 186 - 186 + 187 187 // System.out.println("POIArchive: calculate: Completed Archive: " + eName); 188 188 } 189 189 // All sheets and cells added. Now write out the workbook ... ... @@ -192,10 +192,10 @@ 192 192 FileOutputStream fileOut = new FileOutputStream(file); 193 193 wb.write(fileOut); 194 194 fileOut.close(); 195 - 195 + 196 196 objectArray = null; 197 197 entityNameForArchive = null; 198 - 198 + 199 199 System.out.println("POI @ " + fn); 200 200 return fn; 201 201 } ... ... @@ -204,12 +204,12 @@ 204 204 e.printStackTrace(new PrintStream(baos)); 205 205 System.out.println("POIArchive: archive(): error:" + baos.toString()); 206 206 return null; 207 + } 207 207 } 208 - } 209 - 210 - /** Returns the current value provided by the d2wContext. Found objects use 211 - * the d2wContext for timestamp formatting, relationships, etc. If a 212 - * relationship fo an EOEnterpriseObject is resolved, and no keyForRelationship 209 + 210 + /** Returns the current value provided by the d2wContext. Found objects use 211 + * the d2wContext for timestamp formatting, relationships, etc. If a 212 + * relationship fo an EOEnterpriseObject is resolved, and no keyForRelationship 213 213 * is found, this method will use the EO's userPresentableDescription. */ 214 214 public String currentValue() { 215 215 Object o = null; ... ... @@ -262,13 +262,13 @@ 262 262 return "(Binary Data)"; 263 263 } 264 264 } 265 - 265 + 266 266 /** Returns an EOEnterpriseObject's 'displayNameForEntity', using the d2wContext. 267 - * If it is not found, the method will check the userInfoDictionary for 267 + * If it is not found, the method will check the userInfoDictionary for 268 268 * displayName. If all else fails, it will return the entity's name. */ 269 269 public String displayName() { 270 270 String s; 271 - 271 + 272 272 s = (String) d2wContext().valueForKey("displayNameForEntity"); 273 273 if (s == null) { 274 274 s = (String) d2wContext().entity().userInfo().objectForKey("displayName"); ... ... @@ -292,7 +292,7 @@ 292 292 } 293 293 if (_fileUploadPath == null) { 294 294 NSLog.err.appendln("FileUpload: 'OTCUploadDirectory' does not exist." 295 - + " Please launch this application again with the 'OTCUploadDirectory'" 295 + + " Please launch this application again with the 'OTCUploadDirectory'" 296 296 + " System Property set to a directory to which you have write permission."); 297 297 } 298 298 } ... ... @@ -301,3 +301,5 @@ 301 301 } 302 302 303 303 {{/code}} 304 + 305 +Category:WebObjects