我想打印CrystalReportViewer中显示的报告。我使用此代码在CrystalReportViewer中预览报表:
private void previewButton_Click(object sender, EventArgs e)
{
string sql1 = "SELECT * FROM SousCategorie WHERE Stock > 0";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataAdapter dscmd1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
dscmd1.Fill(ds1, "SousCategorie");
CrystalReport5 objRpt2 = new CrystalReport5();
objRpt2.SetDataSource(ds1);
crystalReportViewer5.ReportSource = objRpt2;
crystalReportViewer5.Refresh();
}
我使用此代码打印CrystalReportViewer中预览的报告:
private void printButton_Click(object sender, EventArgs e)
{
CrystalReport5 objRpt4 = new CrystalReport5();
objRpt4.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
objRpt4.PrintOptions.PaperSize = PaperSize.PaperA4;
objRpt4.PrintToPrinter(1, false, 0, 0);
}
但是我打印了一份空白报告。如何打印报告,如CrystalReportViewer工具栏中存在的打印按钮?