Imports FarPoint.Win.Spread
Imports System.Drawing.Printing
Public Class Form1
Private _spread As FpSpread
Private _printDocument As PrintDocument
Private _printPreviewDialog As New PrintPreviewDialog
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
_spread = New FpSpread
_spread.Sheets.Add(New SheetView)
'数据量的大小会影响打印速度
_spread.Sheets(0).Cells(0, 0).Text = "测试"
_spread.Sheets(0).Cells(30, 0).Text = "测试2"
_spread.Sheets(0).Cells(0, 10).Text = "测试3"
_printDocument = New PrintDocument
AddHandler _printDocument.PrintPage, AddressOf PrintPage
_printPreviewDialog.Document = _printDocument
_printPreviewDialog.ShowDialog()
End Sub
Private Sub PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs)
Dim rect As Rectangle
rect = New Rectangle(0, 0, 1000, 800)
'旋转导致速度慢,不旋转对速度没影响
e.Graphics.TranslateTransform(0, e.PageSettings.PaperSize.Height)
e.Graphics.RotateTransform(-90)
_spread.OwnerPrintDraw(e.Graphics, rect, 0, 1)
End Sub
End Class
以上是我的所有测试代码,麻烦帮忙看下。现在使用OwnerPrintDraw方法主要是为了实现在一个打印任务中完成多个SheetView打印,有什么其他的方法能实现这个需求吗? |