MS Excel Downloads using ExcelGenerator from Project Wonder
Thanks to Anjo Krank and the Project Wonder team,
we can create a WOComponent that automatically generates and downloads a
Microsoft Excel workbook using the er.excel.EGWrapper component from the
ExcelGenerator framework. This is very easy to use....
First simply get the "ExcelGenerator.framework"
from the Project Wonder download and copy it to your /Library/Frameworks folder
on OS X.
Add the
ExcelGenerator.framework to your
project
Create a simple WOComponent
page in your project.
Delete all HTML
content.
Next Insert a EGWrapper
component into your page
Inside the
wrapper create a table for each sheet that you want in the resulting
workbook.
Copy the Styles.plist
document from the EGSampleApp in the Wonder source (This EGSampleApp is a good
example of how to set it up)
Add method
to return the fonts/styles dictionary bindings in your Application class (see
EGSampleApp again for details)
use a
name="Sheet 1" attribute in the table tag to set the sheet
names.
see the comments in the
Styles.plist from EGSampleApp for cell formatting attributes that can be used in
the table and td tags.
Remove HTML
specific attributes such as cellpadding,
etc.
_______________________________________________________________________
IMPORTANT
PITFALL AVOIDANCE
Ensure you clean up the
WOComponent so that there are no spaces, line feed, tabs, etc. outside of any
tags since these will corrupt your Excel generated
output.
Ensure your attributes are
properly typed .... unlike HTML 4, these are case sensitive for excel generator.
For example use cellType, not celltype! Watch out for Command-R automatic
reformatting in WO Builder .... it may change the case of attributes and the
Excel Generator will ignore
them.
________________________________________________________________________
Set
the fonts and styles bindings as per the EGSampleApp. Set the Excel filename
binding if you wish. Set the enabled to false first to test your page
content.
If you are satisfied with the
content, then throw the enabled switch in EGWrapper to true, put an action URL
on a different page to initialize and return the Excel component page and
clicking this action URL should just make the Excel file auto-generate and
download.
Thanks a bunch Project
Wonder!
http://wonder.sourceforge.net/javadoc/er/excel/EGWrapper.html
Tag
attributes that you can set are:
Cell Width:
width="15"
Posted: Thursday - May 05, 2005 at 11:52 AM