Solved

Specify paper orientation and page size in Excel from ASP

Posted on 2007-11-20
8
1,475 Views
Last Modified: 2012-05-05
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!
0
Comment
Question by:quiTech
  • 4
  • 3
8 Comments
 
LVL 9

Expert Comment

by:CCongdon
ID: 20322050
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;
}
0
 
LVL 9

Accepted Solution

by:
CCongdon earned 500 total points
ID: 20322084
OK, looking a little further, this *should* be how you set page size of legal with a landscape orientaiton.


@page
{
size:14.0in 8.5in;
mso-page-orientation:landscape;
}
0
 

Author Comment

by:quiTech
ID: 20576537
thanks!
0
 

Expert Comment

by:paragp
ID: 20743621
does this solution work for IE?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:CCongdon
ID: 20743688
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.
0
 

Expert Comment

by:paragp
ID: 20743746
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.
0
 
LVL 9

Expert Comment

by:CCongdon
ID: 20743784
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.
0
 

Expert Comment

by:paragp
ID: 20743799
no i am using excel 2002
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now