Link to home
Start Free TrialLog in
Avatar of quiTech
quiTechFlag for Canada

asked on

Specify paper orientation and page size in Excel from ASP

I am creating an Excel page from ASP, using this line:

<% Response.ContentType = "application/vnd.ms-excel" %>

The rest of the page is HTML (created via ASP).

Is there any way I can tell the client that the Excel page-setup should be Landscape and using Legal Paper?  How about the "fit to page" option?  

Thanks!
Avatar of CCongdon
CCongdon
Flag of United States of America image

You might try this CSS for the page. I'm not 100% sure what the commands for fit to page or page size are. However, you might just simply try adding width: 14in height: 8.5in to the @page for paper size. You might also poke around and look for the Microsoft Office XML reference. That might list out the mso's that are available.

@page
{
mso-page-orientation:landscape;
}
ASKER CERTIFIED SOLUTION
Avatar of CCongdon
CCongdon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of quiTech

ASKER

thanks!
Avatar of paragp
paragp

does this solution work for IE?
Yes and no. It is for Excel. Now, since IE can load Excel's DLLs and view Excel files, yes this works for IE insamuch that IE is just a shell for Excel when viewing the .xls stream from the web server.
well I am actually doing an export to excel. So I have a datagrid on an aspx page which I export to excel.
I tried the above mentioned way but it does not seem to work. The excel spreadsheet just open up in portrait format.
Are you using Excel 2007 by any chance? I'm going to guess this won't work for the newest Excel since MS changed a lot in the new Office.
no i am using excel 2002