ASPX can't change PageSetup property of Chart

L

Lowell

I have a .NET component (DLL, written in C# with VS 2002)
which loads data from a database into an Excel sheet then
uses that data to create a chart.

When I run it from a Windows program (EXE, also written in
C# with VS 2002), everything is fine.

When I run it as a server-side component from an ASPX
page, I get an error "Unable to set the XXX property of
the PageSetup class" where "XXX"
is "ChartSize", "Orientation", (and presumably, I gave up
after trying the previous ones), "PaperSize" and "Zoom".
(I'm trapping the error and printing out the message that
comes from the exception.) (The idea is to have a web
server component generate the spreadsheet and GIFs of the
charts and then display a page that lets the user download
the GIFs. That way, the client doesn't have to have
Framework, Excel, etc. installed.)

I can make it work through the ASPX page if I completely
remove anything that has to do with the "PageSetup"
property, but then my resulting spreadsheet charts won't
print on a single page (among other issues).

I suspect that there is something with the fact that Excel
does not have access to a display (since it is running
under the IIS server) which makes the "PageSetup" property
invalid. Please say it isn't so and tell me of some magic
trick I can use to make this work!

The code looks like this:

private bool SetPageSetup ( Excel.Chart CurrentChart, ... )

{
....

CurrentChart.PageSetup.ChartSize =
Excel.XlObjectSize.xlFullPage;
....
}

Remember, the DLL works fine as a component in a Windows
EXE or as a downloaded client-side component. It does not
work as a server-side component when run from an ASP.NET
web page.

Any suggestions?
 
L

Lori Turner [MSFT]

The problem is most likely due to the fact that there is no printer
installed for the account you're running under when you automate Excel from
ASP.NET.
You should make note of the information in the following article which
describes that we do not recommend or support Excel Automation on the
server:

INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/?id=257757

Regards,
Lori Turner
Microsoft Beta Staff

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
L

Lowell

Bingo! That was what I needed! And a whole bunch of
other good stuff besides! Thanks!

Lowell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top