• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic