把类 ReportClass 引入项目
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using Microsoft.Reporting.WinForms;
using System.Text.RegularExpressions;
using System.Text;
using System.Windows.Forms;
namespace SellManage
{
class ReportClass
{
private static int m_currentPageIndex; //用来记录当前打印到第几页了
private static IList<Stream> m_streams; //LocalReport对象的Render方法会将报表按页输出为多个Stream对象。
public static void Print(LocalReport report)
{
Export(report);
m_currentPageIndex = 0;
if (m_streams == null || m_streams.Count == 0)
return;
//声明PrintDocument对象用于数据的打印
PrintDocument printDoc = new PrintDocument();
//指定需要使用的打印机的名称,使用空字符串""来指定默认打印机