facebooktwittermenuarrow-up

GemBox Support Forum

Chart not printing

When printing an xlsx, the chart on the sheet is not printed. Everything else prints fine. This is my code to print the xlsx:

Public Sub Print_Spreadsheet_GemBox(xlName As String, xlSheet As String, LandScape As Boolean, DoubleSided As Boolean, gemboxRowHeights As Boolean)
    SpreadsheetInfo.SetLicense("myKey")

    Dim oBook As ExcelFile = ExcelFile.Load(xlName)
    Dim oSheet As ExcelWorksheet = oBook.Worksheets(xlSheet)

    oBook.AutomaticFormulaUpdate = True
    oBook.Calculate()

    Dim pTicket As New PrintTicket()
    If DoubleSided Then
        pTicket.Duplexing = Duplexing.TwoSidedLongEdge
    Else
        pTicket.Duplexing = Duplexing.OneSided
    End If
    pTicket.PagesPerSheet = 1
    If LandScape Then
        pTicket.PageOrientation = PageOrientation.Landscape
    Else
        pTicket.PageOrientation = PageOrientation.Portrait
    End If
    pTicket.PageMediaType = PageMediaType.Plain
    pTicket.PageOrder = PageOrder.Standard

    ' i do not do this the row heights are really high when printed
    If gemboxRowHeights Then
        Dim i As Integer
        For i = 0 To 203
            oSheet.Rows(i).Height = oSheet.Rows(i).Height
        Next
    End If

    oSheet.PrintOptions.SetPrinterSettings(Nothing, pTicket.GetXmlStream())

    oSheet.PrintOptions.Portrait = IIf(LandScape, False, True)

    oSheet.PrintOptions.FitWorksheetHeightToPages = 2
    oSheet.PrintOptions.FitWorksheetWidthToPages = 1
    oSheet.PrintOptions.PaperType = PaperType.A4

    Dim prnOptions As New PrintOptions(pTicket.GetXmlStream)
    prnOptions.SelectionType = SelectionType.ActiveSheet

    Dim printerName As String = Nothing
    oBook.Print(printerName, prnOptions)
End Sub

Hi Trevor,

Note that not all charts are supported.

You can find the list of supported charts on the following help page:
https://www.gemboxsoftware.com/spreadsheet/docs/charts.html

Regards,
Mario