Excel Interop: formatting footers

I am creating an Excel Worksheet from C # using Microsoft.Office.Interop.Excel and I was not able to get the footers the way their user wants.

1) How to add footer text to BOLD? 2) How can I put the page number in the footer? (Enter @ "Page @ [Page]" because the text does not work.)

Possible? Impossible?

+3
source share
4 answers

1) worksheet.PageSetup.LeftFooter = "&B Bold text &B"

2) worksheet.PageSetup.CenterFooter = "Page &P"

- Excel , , , , . VBA. VBA , API. Excel.

+6

SpreadsheetGear .NET Excel:

  • & P - .
  • & N - .
  • & B - *.
  • & - *.
  • & U - *.
  • && - '&' .
  • & D - .
  • & T - .
  • & F - .
  • & A - .
  • & "FontName" - *.
  • & N - *.

* , , SpreadsheetGear.

+8

- ​​, , . , , :

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 30/06/2009 by bloggsj
'

'
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = "&""Arial,Bold""Page &P of &N"          '<== Et. Voila! 
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.75)
        .RightMargin = Application.InchesToPoints(0.75)
        .TopMargin = Application.InchesToPoints(1)
        .BottomMargin = Application.InchesToPoints(1)
        .HeaderMargin = Application.InchesToPoints(0.5)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
    End With
End Sub

, (Et. Voila), Excel. , .

0

; & B & , html-. :

PageSetup.LeftHeader = "&B&IBOLDITALIC&I BOLD&B NORMAL";

:

BOLDITALIC BOLD

0

Source: https://habr.com/ru/post/1711594/


All Articles