none
Creating Docx and adding Header/Footer as needed with Openxml RRS feed

  • Question

  • Hey Guys! I trying to create word document with Header and Footer as needed. I have looked answers around and I dont see exactly one that matches what I need. Can you guys help? Here is what I am tring to do.

    1) Read text file

    2) Create docx file

    3) Read the lines from the text file and append the text to the docx. Looping through the text file, according to the contents of the line currently in, I want to Add a Header/Footer to that particular page I am on. Dont need the Header/Footers to show up on the other pages.

    It seems simple but I keep getting errors with docx file I created.

    Thanks,

    Issa

     
    Saturday, June 2, 2012 12:27 AM

Answers

  • Hi Issa,

    I think what you mentioned is hard to do. Footer and Header will not alow what you want due to them will never be set on every page. It only set on document. It means that all of the pages in the doucment will use only one Header/Footer setting.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, June 6, 2012 7:40 AM
    Moderator

All replies

  • Hi Issa,

    Thank for posting in the MSDN Forum.

    It's based on my experience that footer/header will never only show on specific page. There are three type of footers/headers. I would recommend you take a look at this http://msdn.microsoft.com/en-Us/library/documentformat.openxml.wordprocessing.headerreference then tell me which kind of header/footer you want?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, June 4, 2012 4:49 AM
    Moderator
  • Hey Tom,

    Thanks for the reply. Okay I see your point of not being possible to add footers on specifi pages rather than all pages. How about the following scenario:

    1) Read text file

    2) Write the stream to the docx

    3) Get one footer but update the info in the footer as you go t though the pages.

    For example, first footer could be date on the first page, second footer will be historic date from second page, and so on. Basically showing different footer text for different pages. Is this possible?

    Thanks,

    Issa

    Monday, June 4, 2012 4:55 PM
  • Hi Issa,

    I think what you mentioned is hard to do. Footer and Header will not alow what you want due to them will never be set on every page. It only set on document. It means that all of the pages in the doucment will use only one Header/Footer setting.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, June 6, 2012 7:40 AM
    Moderator