473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Default page oriantation to Landscape

Hi All,

In a .NET windows application using C#, I'm opening an existing excel worksheet using office interop, where in I get Excel.Application object, Workbook object etc. I want to set the default orienation to Landscape while this worksheet will be printed by user. I searched around a lot!! But din't find any object with which orientation property can be set to landscape through code.
Here is the piece of code used for opening the xls file:

Microsoft.Office.Interop.Excel.Application xlAppn = null;
xlAppn = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook curWorkBook = xlAppn.Workbooks.Open(fileName,
0, false, 5,
"", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindow s, "\t", true, false,
0, true, true, false);

Microsoft.Office.Interop.Excel.Sheets curSheets = curWorkBook.Worksheets;
_Worksheet curWorkSheet = (_Worksheet)curSheets.get_Item(1);



I do some modifications to the cells data after this, close it. And then MS excel is launched using,
System.Diagnostics.Process.Start(fileName);

Any help is highly appreciated!! Thanks in advance.

--Himani
Aug 14 '06 #1
1 12105
Short answer - use the PageSetup for a sheet:

using Excel = Microsoft.Office.Interop.Excel;
Excel._Worksheet oSheet;
oSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;


In the future, just load the Excel Interop dll into the VS object browser and do a search for whatever you're looking for.

ciao,

Hans

Hi All,

In a .NET windows application using C#, I'm opening an existing excel worksheet using office interop, where in I get Excel.Application object, Workbook object etc. I want to set the default orienation to Landscape while this worksheet will be printed by user. I searched around a lot!! But din't find any object with which orientation property can be set to landscape through code.
Here is the piece of code used for opening the xls file:

Microsoft.Office.Interop.Excel.Application xlAppn = null;
xlAppn = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook curWorkBook = xlAppn.Workbooks.Open(fileName,
0, false, 5,
"", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindow s, "\t", true, false,
0, true, true, false);

Microsoft.Office.Interop.Excel.Sheets curSheets = curWorkBook.Worksheets;
_Worksheet curWorkSheet = (_Worksheet)curSheets.get_Item(1);



I do some modifications to the cells data after this, close it. And then MS excel is launched using,
System.Diagnostics.Process.Start(fileName);

Any help is highly appreciated!! Thanks in advance.

--Himani
Jan 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Yaron Cohen | last post by:
Hi, I would like to ask for your help. I am using IE5.5. I have a wide page with horizontal scroll bar. The problem is that I get only 1 page when printing it using "file->print" or...
3
by: NWx | last post by:
Hi, I have a web browser control integrated into a form, which display a HTM page I generate in my program And I want to be able to print that web page (it is a actually a report) But I want it...
0
by: Steph. | last post by:
Hi, Is there a BUG in the printdialog ? When I create a PrintDialog ans set the "DefaultPageSettings.Landscape" property to "false" and then display the dialog, select "Landscape" and click OK,...
2
by: Sean McKaharay | last post by:
I want to find out how I can change the page orientation of a printer.
2
by: Yelena Kaplun | last post by:
Hi, I'm trying to customize print settings while streaming HTML content into Excel. I'm using ASP.NET 1.1 and Excel 2003. While some printer settings like Margins are working correctly, I cannot...
12
by: Connor T | last post by:
Hi, I have a crystal report embedded in a viewer. How / Where can I set a property to make it default to landscape orientation? Rgds, Dan
2
by: satnamsarai | last post by:
it is possible to change page orientation to landscape from asp.net page? I am using window.print() dialog to print a page and I would like that page to print automatically in landscape view.
2
by: Andrew Poulos | last post by:
To set an item's style properties I can do something like this: var foo = document.getElementById("bar"); bar.style.width = "100px"; But how do I set the style of paged media i.e. the @page...
4
by: nano2k | last post by:
Hello I need to display and then automatically print a PDF file. I'm using AxAcroPDF to display the PDF. AxAcroPDF class has a very good method: printAll(). The only thing is that I need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.