zoukankan      html  css  js  c++  java
  • 直接打印水晶报表Crystal Report到打印机 Web模式

    Sometimes a little tip could save you much time when browsing website:

    //dataset create
    DataSet thisDataSet = new DataSet();
    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
    adapter.Fill(thisDataSet, "Main");

    ReportDocument rptSales = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

    rptSales.FileName = Server.MapPath("CrystalReport.rpt");
    rptSales.SetDatabaseLogon("user", "password");
    rptSales.SetDataSource(thisDataSet.Tables["Main"]);

    //default printer name
    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.PrintToPrinter(1, true, 1, 9999);
    thisConnection.Close();
  • 相关阅读:
    第二章 java内存区域与内存溢出异常
    TCP实现可靠传输
    Tomcat的类加载架构
    浅析Synchronized
    设计数据库
    http和https
    IOC容器的依赖注入
    IOC容器初始化
    深入理解Java内存模型
    单例应该这么写
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1367349.html
Copyright © 2011-2022 走看看