Spread WPF Documentation
PrintToDocument(String) Method
Example 


GrapeCity.Windows.SpreadSheet.UI Namespace > GcSpreadSheet Class > PrintToDocument Method : PrintToDocument(String) Method
Syntax
'Declaration
 
Public Overloads Function PrintToDocument( _
   ByVal pageRange As System.String _
) As System.Windows.Documents.IDocumentPaginatorSource
'Usage
 
Dim instance As GcSpreadSheet
Dim pageRange As System.String
Dim value As System.Windows.Documents.IDocumentPaginatorSource
 
value = instance.PrintToDocument(pageRange)
public System.Windows.Documents.IDocumentPaginatorSource PrintToDocument( 
   System.string pageRange
)

Parameters

pageRange
Remarks
Page strings should use a dash between groups of pages and a comma when skipping pages. For example, GcSpreadSheet1.PrintPreview(“2-4, 6-8, 10”), means to preview the page from 2 to 4, 6 to 8, and page 10.
Example
This example uses the PrintToDocument method.
internal class PrintDocumentViewer : DocumentViewer
        {
            public PrintDocumentViewer(GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet spread, int sheetIndex)
            {
                this.Spread = spread;
                this.SheetIndex = sheetIndex;
                this.Document = spread.PrintToDocument("2");
            }

            protected override void OnPrintCommand()
            {
                if (this.Spread != null)
                {
                    if (this.SheetIndex != -1)
                    {
                        this.Spread.Print(this.SheetIndex);
                    }
                    else
                    {
                        this.Spread.Print();
                    }
                }

            }
            private GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet Spread { get; set; }
            private int SheetIndex { get; set; }
        }           

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            Window window = new Window();
            PrintDocumentViewer viewer = new PrintDocumentViewer(GcSpreadSheet1, -1);
            window.Content = viewer;
            window.ShowDialog();
        }
Friend Class PrintDocumentViewer
        Inherits DocumentViewer
        Public Sub New(spread As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet, sheetIndex As Integer)
            Me.Spread = spread
            Me.SheetIndex = sheetIndex
            Me.Document = spread.PrintToDocument("2")
        End Sub

        Protected Overrides Sub OnPrintCommand()
            If Me.Spread IsNot Nothing Then
                If Me.SheetIndex <> -1 Then
                    Me.Spread.Print(Me.SheetIndex)
                Else
                    Me.Spread.Print()
                End If
            End If
        End Sub

        Private Property Spread() As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
            Get
                Return m_Spread
            End Get
            Set(value As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet)
                m_Spread = value
            End Set
        End Property
        Private m_Spread As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
        Private Property SheetIndex() As Integer
            Get
                Return m_SheetIndex
            End Get
            Set(value As Integer)
                m_SheetIndex = Value
            End Set
        End Property
        Private m_SheetIndex As Integer
    End Class

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Dim window As New Window()
        Dim viewer As New PrintDocumentViewer(GcSpreadSheet1, -1)
        window.Content = viewer
        window.ShowDialog()
    End Sub
See Also

Reference

GcSpreadSheet Class
GcSpreadSheet Members
Overload List