aspose file tools*
The moose likes JSP and the fly likes --How do I control behavior when data is exported to MS Excel??-- Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "--How do I control behavior when data is exported to MS Excel??--" Watch "--How do I control behavior when data is exported to MS Excel??--" New topic
Author

--How do I control behavior when data is exported to MS Excel??--

verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
I have a JSP that needs the capacity to be viewed from the browser and also exported to MS Excel. I have the display in the browser working fine. On the JSP I have an "Export to Excel" button. When clicked, I set a hidden field called format to "excel" and then the page is submitted. When the page is reloaded, I examine the request parameters for this value:

This code does cause MS Excel to open and display my page. My questions concern how could I control the formatting of the data when it has been exported to Excel:
-- How do I control the width and height of the cells? I need the data to be formatted so that it will all fit on one page when printed in portrait mode.
-- The file is not automatically maximized in the Excel window. How can I tell it to open fully maximized?
-- I specify that the name of the file is DailyCensus.xls. When it opens in Excel, it is DailyCensus[1].xls and the name of the worksheet is DailyCensus 1. Why does it use the "1"? Is there a way to prevent this?
-- Is there a way for me to set the default location for the file to be saved? Currently, it defaults to C:\Documents and Settings\[user id]\Local Settings\Temporary Internet Files\... I'd rather have it set to a specific folder of a network drive. How do I do this?
I really appreciate any suggestions you have. Thanks.
verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
The only way that I have found to control the layout and look of the data once it is exported to Excel is to use ActiveXObject. I want to know now if there are any security concerns when using code with the ActiveX object.
Also, does anyone know how to specify the margins? I'm using:

If anyone can tell me the security implications of using such an ActiveXControl, I'd appreciate it. I'm also confused on how to set the margins. The code above is commented out because it doesn't work.
Thanks for your help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: --How do I control behavior when data is exported to MS Excel??--