The Artima Developer Community
Sponsored Link

C# Answers Forum
Excel Automation

4 replies on 1 page. Most recent reply: May 26, 2005 12:57 PM by Nolan Johnson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Luis Gustavo

Posts: 2
Nickname: lgcibim
Registered: Apr, 2004

Excel Automation Posted: Apr 22, 2004 1:26 PM
Reply to this message Reply
Advertisement
How to add a page break in a excel file using C#?


Ned Flanders

Posts: 3
Nickname: nedman
Registered: Apr, 2004

Re: Excel Automation Posted: Apr 23, 2004 1:38 PM
Reply to this message Reply
I'm only doing this from one of my last remaining VB6 apps, but in that I have:

.Rows(SomeRow).PageBreak = xlPageBreakManual

Hope this helps somewhat.

Luis Gustavo

Posts: 2
Nickname: lgcibim
Registered: Apr, 2004

Re: Excel Automation Posted: Apr 26, 2004 11:17 AM
Reply to this message Reply
Hi,
I'm using this to add a Page Break using C#:

worksheet.get_Range("A35", "R35").PageBreak = (int)Excel.Constants.xlManual;

OR

worksheet.HPageBreaks.Add(worksheet.get_Ran ge("A35", "R35"));

The programs runs without errors, but when I open the Excel file and go to the "Print Preview" and "Page Break Preview", the Page Breaks not appear. Do you know why?
There are any Page Setup to the Excel accept the Page Break?

Aaron Picht

Posts: 1
Nickname: aaronp
Registered: May, 2005

Re: Excel Automation Posted: May 16, 2005 2:33 AM
Reply to this message Reply
So far I have had good luck with

((Excel.Range)objSheet.Cells[intRow,1]).PageBreak = (int)Excel.XlPageBreak.xlPageBreakManual;

Hope this helps anyone searching around for an answer, because I couldn't find one. Just had to play with it for a while.

Nolan Johnson

Posts: 1
Nickname: nojo
Registered: May, 2005

Re: Excel Automation Posted: May 26, 2005 12:57 PM
Reply to this message Reply
On a somewhat different note: I'm looking into revamping a VBA-based Excel app that we have, and considering several routes. I've seen lots of "simple" examples of Excel automation in C#, but nowhere have I seen anybody answer this question: Can I do everything from C# that I can do from VBA? If not, what can't I do? I need to try to get my head around the limitations of using C# to do complex manipulations of Excel workbooks.

Thanks.

Flat View: This topic has 4 replies on 1 page
Topic: survey Previous Topic   Next Topic Topic: voip

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use