Message-ID: <885239878.9553.1711694630971.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9552_1598622785.1711694630971" ------=_Part_9552_1598622785.1711694630971 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
To format a header or footer in script, include formatting codes within = the SetContent() call, for example:
using SoftArtisans.OfficeWriter.ExcelWriter; public class HeaderFooterDemo : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); Worksheet sheet1 =3D wb.Worksheets[0]; PageSetup pgsetup =3D sheet1.PageSetup; HeaderFooterSection leftHeader =3D pgsetup.GetHeader(HeaderFooterSection.Section.Left); leftHeader.SetContent("Document name: &F"); HeaderFooterSection centerHeader =3D pgsetup.GetHeader(HeaderFooterSection.Section.Center); centerHeader.SetContent("Basic Report"); HeaderFooterSection rightHeader =3D pgsetup.GetHeader(HeaderFooterSection.Section.Right); rightHeader.SetContent("Generated by OfficeWriter"); HeaderFooterSection leftFooter =3D pgsetup.GetFooter(HeaderFooterSection.Section.Left); leftFooter.SetContent("Created on date &D"); HeaderFooterSection centerFooter =3D pgsetup.GetFooter(HeaderFooterSection.Section.Center); centerFooter.SetContent("Page &P of &N"); HeaderFooterSection rightFooter =3D pgsetup.GetFooter(HeaderFooterSection.Section.Right); rightFooter.SetContent("Create at time &T"); } }=20
Formatting Codes for Headers and Footers <= /th> | |
---|---|
&E |
Turns double-underline on or off. |
&X |
Turns superscript on or off. |
&Y |
Turns subscript on or off. |
&B |
Turns bold on or off. |
&I |
Turns italic on or off. |
&U |
Turns underline on or off. |
&S |
Turns strikethrough on or off. |
&D |
Prints the current date. |
&T |
Prints the current time. |
&F |
Prints the name of the document. |
&A |
Prints the name of the worksheet. |
&P |
Prints the page number. |
&P+number |
Prints the page number plus the specified num= ber. |
&P-number |
Prints the page number minus the specified nu= mber. |
&& |
Prints a single ampersand. |
&"font name" |
Prints the characters that follow in the spec= ified font. |
&nn |
Prints the characters that follow in the spec= ified font size. Use a two digit number to specify a size in points. |
&N |
Prints the total number of pages in the docum= ent. |
When opening an existing Excel spreadsheet, ExcelWriter will preserve th= e header and footer formatting created in Excel. However, if you change the= header/footer text in your ExcelWriter script and do not include Formatting Codes, the for= matting created in Excel will be overwritten and default formatting will be= applied. To preserve header/footer formatting created in Excel, do not cha= nge header/footer text in script.
To format spreadsheet headers and footers in Excel and preserve the form= atting in ExcelWriter: