This project has moved. For the latest updates, please go here.

Adding text to footer

May 4, 2010 at 7:14 PM
I am using a template that has a right aligned Image in the footer and I want to add text to the left aligned footer. When trying to add the left side text it rewrites the entire footer,is there a way to retain the image within the template? The code i'm using is: ExcelHeaderFooterText footer= worksheet.HeaderFooter.oddFooter; footer.LeftAlignedText = "Test Value"; Thanks
Coordinator
May 5, 2010 at 6:37 AM

No support for that in the current version. You can use the WorksheetXml if you want to be advanced. Extract the package (rename the template .zip and extract it) and have a look at the sheet-xml file to see the xpath and format.

May 7, 2010 at 6:38 PM
I will have a look at that. I appreciate all your work on this library, it's been real helpful for my project. Thanks!
May 10, 2010 at 1:02 PM
Edited May 10, 2010 at 1:05 PM
Just for reference to others who may need this, I accomplished what I needed by doing the following:

XmlNodeList nodeList = worksheet.WorksheetXml.GetElementsByTagName("oddFooter");
nodeList[0].InnerText += "&L" + footerText; //add footerText to the left (&L)

footerText is a string variable and worksheet is an ExcelWorksheet object
This looked to be the easiest way to add text without overwriting the image that was already in the footer.
Mar 28, 2011 at 8:47 AM

Thanks cdc5205

we'll seriously consider adding functionality to this.

extract note to add here:

nodeList[0].InnerText += "&L" + footerText; //add footerText to the left (&L)

&L = left

&C = center

&R = Right

 

&P = current page number

&N = "of" page number eg. Page &P of &N = Page 1 of 1

whereas &[Page] and &[Pages] would require a "compile" by excel