how to insert header to an excel sheet?

This is a discussion on how to insert header to an excel sheet? within the C# Programming forums, part of the General Programming Boards category; Hello, I am working on excel worksheets from a c# code and I need to get the header from the ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    177

    how to insert header to an excel sheet?

    Hello,


    I am working on excel worksheets from a c# code and I need to get the header from the user and insert it to the sheets .

    Does anyone know the c# instruction to insert a header to an excel sheet?


    Thank you
    Arian

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    Thank you

    Do you mean this c# function?
    Code:
    sheet.get_Range(object cell1,object cell2);
    I use it to read data from an excel file or write to the body of a sheet.
    How can I access to the header part by this function?

    thank you

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    No, he doesn't. He means the Range.Insert Method (Microsoft.Office.Interop.Excel) method. (Hint: red = link = click it.)

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    thank you

    I found out about "PageSetup.CenterHeader ". I think it is easier to use

    here is a sample.
    Code:
                    StringBuilder str = new StringBuilder();
                    str.Append(@"&""Arial,Regular"+"header text");
    
                    sheet = (Excel.Worksheet)wBook1.Sheets[1];
                    sheet.PageSetup.CenterHeader = str.ToString();
    
                    wBook1.Save();
    Do you know how I can change the header font size?
    Last edited by arian; 07-01-2011 at 03:25 AM.

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    thank you

    I found out about "PageSetup.CenterHeader ". I think it is easier to use

    here is a sample.
    Code:
                    sheet = (Excel.Worksheet)wBook1.Sheets[1];
                    sheet.PageSetup.CenterHeader = "header text";
    
                    wBook1.Save();
    Do you know how I can change the header font and size?

    I know one way is to use StringBuilder and Append but I couldnt change the font size.
    Code:
    StringBuilder str = new StringBuilder();
    str.Append(@"&""Arial,Regular""test");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Outputting Data to Excel Sheet - MFC Application
    By strokebow in forum C++ Programming
    Replies: 3
    Last Post: 06-27-2011, 09:25 AM
  2. Programatically setting excel column/header names
    By cStudy in forum C# Programming
    Replies: 10
    Last Post: 03-03-2011, 07:07 AM
  3. balance sheet help
    By pickler in forum C Programming
    Replies: 0
    Last Post: 11-15-2009, 10:21 AM
  4. How to access excel sheet with C program(open,read,write)
    By jaininaveen in forum C Programming
    Replies: 4
    Last Post: 01-29-2006, 10:17 AM
  5. Replies: 1
    Last Post: 09-17-2001, 05:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21