Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:52:28+00:00 2026-06-03T16:52:28+00:00

EDIT: There’s a further detail I left out with my original post. The program

  • 0

EDIT: There’s a further detail I left out with my original post. The program is using a template stream rather than a concrete template for the “.Open” command. The template stream gets initialized with this code block:

public void Initialize(Stream templateStream)
{
    spreadsheet = SpreadsheetDocument.Open(templateStream, true);
}

I’m still researching this, but does anyone know the implications of using a stream for the HeaderFooter object in OpenXML?

I’m new to OpenXML and still in the process of reading and learning what I can of this massive SDK. I’ve inherited a C# MVC.NET program that uses OpenXML to display information on an Excel spreadsheet and all of that is working, but I now need to add a footer to the same spreadsheet and I’m hitting some brick walls in my OpenXML knowledge.

I put the footer information I wanted into the spreadsheet, opened it up with the Open XML SDK Productivity Tool and found this code under <.x:oddFooter(OddFooter):

 // Creates an OddFooter instance and adds its children.
        public OddFooter GenerateOddFooter()
        {
            OddFooter oddFooter1 = new OddFooter();
            oddFooter1.Text = "&L&\"Times New Roman,Regular\"Page &P of &N&C&\"Times New Roman,Regular\"Generated On: <Date/Time> Central&R&\"Times New Roman,Regular\"Report";
            return oddFooter1;
        }

And this code one level up under <>x:headerFooter(OddFooter):

// Creates an HeaderFooter instance and adds its children.
        public HeaderFooter GenerateHeaderFooter()
        {
            HeaderFooter headerFooter1 = new HeaderFooter();
            OddFooter oddFooter1 = new OddFooter();
            oddFooter1.Text = "&L&\"Times New Roman,Regular\"Page &P of &N&C&\"Times New Roman,Regular\"Generated On: <Date/Time> Central&R&\"Times New Roman,Regular\"Report";

            headerFooter1.Append(oddFooter1);
            return headerFooter1;
        }

Now I of course need to append the footer info somewhere, and this is where I’m stuck. In <>x:worksheet(Worksheet) I see this line of code:

worksheet1.Append(headerFooter1);

This looked easy enough, but when I looked back at the application code I found no worksheet object to append to. I thought I was close with the following line of code:

spreadsheet.WorkbookPart.Workbook.Append(headerFooter1);

but this yielded nothing. In the application I see a SpreadsheetDocument object and references to OpenXMLParts… do I need to get a spreadsheet part to append to? Or do I need to take a different approach with a Spreadsheet versus a worksheet object? Do I need to materialize the current worksheet and then append?

I have a feeling this has an easy solution, but as I said I’m still learning the SDK.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:52:30+00:00Added an answer on June 3, 2026 at 4:52 pm

    For those who don’t know about the productivity tool, it is included with the SDK and can be downloaded from https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=5124

    On my 64 bit machine, the install path to the tool was:
    “C:\Program Files (x86)\Open XML SDK\V2.0\tool\OpenXmlSdkTool.exe”

    You should be able to manually add a footer to a spreadsheet, and open it up with the tool and see the exact C# required to create the entire spreadsheet, including the footer. You can then remove the parts of the code that are unnecessary, like some of the styles that are automatically added.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit I think there is some confusion, I am not using both of the
EDIT: There is another wrinkle in here that I missed that turns out to
I'm using the code found in this jsbin: http://jsbin.com/asahe5/10/edit There is a function within
EDIT: There's now a doc page on this so this question is irrelevant, also
**EDIT: There are several options below that would work. Please vote/comment according to your
EDIT: There is the almost same question at Removing whitespace between HTML elements when
EDIT - there are no blank lines. EDIT 2 - my bad, it seems
EDIT: Is there any other phone systems that allow connecting into the native messaging
EDIT: Is there a better way of doing this ? TPendingBets = class(TDataModule) private
Edit Since there were many downvotes and people who didn't understand what I'm asking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.