using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System; using System.Collections.Generic; using System.Drawing.Printing; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using TradeModel; namespace TradeManage.PrintTemplate { public partial class GoodBatchPrint : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { List gwplist = new List(); if (Session["GoodWarePrint2"] != null) gwplist = (List)Session["GoodWarePrint2"]; if (gwplist == null || gwplist.Count == 0) return; // GoodWarePrint gwp = new GoodWarePrint(); // gwp.Descript="黑色"; // gwp.GoodBatch = "423395-1234578-001"; // gwp.GoodNo = "C009-001"; // gwp.WareNo = "仓库"; // gwplist.Add(gwp); //; CrystalReportSource1.ReportDocument.SetDataSource(gwplist); CrystalReportSource1.DataBind(); //ReportDocument rptSales = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); //rptSales.FileName = Server.MapPath("GoodBatch.rpt"); //rptSales.SetDataSource(gwplist); //PrintDocument prtdoc = new PrintDocument(); //string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName; //// then print, this is the important thing here //rptSales.PrintOptions.PrinterName = strDefaultPrinter; //rptSales.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize; //rptSales.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto; ////parameters here depending on your situation. //rptSales.ExportToHttpResponse( // ExportFormatType.PortableDocFormat, Response, false, ""); } } }