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();
  • 相关阅读:
    linux用户管理初级(上)
    定时任务实战
    linux定时任务
    Linux 命令行基础(一)
    Linux 操作系统发展历程及系统版本选择
    Linux文件的权限
    Linux硬连接和软连接
    Linux 文件的属性
    linux 正则表达式
    centos7 设置时间同步
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1367349.html
Copyright © 2011-2022 走看看