水晶报表的导出和打印 Push

简介:

ExpandedBlockStart.gif ContractedBlock.gif <% dot.gif @ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=10.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %>
ExpandedBlockStart.gif ContractedBlock.gif <% dot.gif @ Page language="c#" Codebehind="Main.aspx.cs" AutoEventWireup="false" Inherits="CrystalPush.WebForm1" %>
None.gif <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
None.gif < HTML >
None.gif < HEAD >
None.gif < title >WebForm1 </ title >
None.gif < meta content ="Microsoft Visual Studio 7.0" name ="GENERATOR" >
None.gif < meta content ="C#" name ="CODE_LANGUAGE" >
None.gif < meta content ="JavaScript" name ="vs_defaultClientScript" >
None.gif < meta content ="http://schemas.microsoft.com/intellisense/ie5" name ="vs_targetSchema" >
None.gif </ HEAD >
None.gif < body MS_POSITIONING ="GridLayout" >
None.gif < form id ="Form1" method ="post" runat ="server" >
None.gif < FONT face ="宋体" >
None.gif < CR:CRYSTALREPORTVIEWER id ="Crv" style ="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 54px" runat ="server" Height ="50px" Width ="350px" HasZoomFactorList ="False" HasDrillUpButton ="False" HasGotoPageButton ="False" HasPageNavigationButtons ="False" HasSearchButton ="False" ></ CR:CRYSTALREPORTVIEWER >
None.gif < asp:Button id ="btnPrint" style ="Z-INDEX: 103; LEFT: 548px; POSITION: absolute; TOP: 15px" runat ="server" Width ="78px" Text ="打印" ></ asp:Button >
None.gif < asp:Button id ="btnExport" style ="Z-INDEX: 102; LEFT: 434px; POSITION: absolute; TOP: 14px" runat ="server" Width ="78px" Text ="导出" ></ asp:Button >
None.gif < asp:Label id ="Label1" style ="Z-INDEX: 104; LEFT: 26px; POSITION: absolute; TOP: 19px" runat ="server" >请选择导出格式: </ asp:Label >
None.gif < asp:DropDownList id ="ddlFormat" style ="Z-INDEX: 105; LEFT: 188px; POSITION: absolute; TOP: 16px" runat ="server" >
None.gif < asp:ListItem Value ="Rich Text (RTF)" >Rich Text (RTF) </ asp:ListItem >
None.gif < asp:ListItem Value ="Portable Document (PDF)" >Portable Document (PDF) </ asp:ListItem >
None.gif < asp:ListItem Value ="MS Word (DOC)" >MS Word (DOC) </ asp:ListItem >
None.gif < asp:ListItem Value ="MS Excel (XLS)" >MS Excel (XLS) </ asp:ListItem >
None.gif </ asp:DropDownList ></ FONT ></ form >
None.gif </ body >
None.gif </ HTML >

None.gif using System;
None.gif using System.Collections;
None.gif using System.ComponentModel;
None.gif using System.Data;
None.gif using System.Drawing;
None.gif using System.Web;
None.gif using System.Web.SessionState;
None.gif using System.Web.UI;
None.gif using System.Web.UI.WebControls;
None.gif using System.Web.UI.HtmlControls;
None.gif using System.IO;
None.gif using System.Data.SqlClient;
None.gif using UseCrystal.CrystalPush;
None.gif using CrystalDecisions.CrystalReports.Engine;
None.gif using CrystalDecisions.Shared;
None.gif namespace CrystalPush
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif/**//// <summary>
InBlock.gif
/// WebForm1 的摘要说明。
ExpandedSubBlockEnd.gif
/// </summary>

InBlock.gifpublic class WebForm1 : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifprotected System.Web.UI.WebControls.Button btnExport;
InBlock.gifprotected System.Web.UI.WebControls.Button btnPrint;
InBlock.gifprotected CrystalDecisions.Web.CrystalReportViewer Crv;
InBlock.gifprotected System.Web.UI.WebControls.Label Label1;
InBlock.gifprotected System.Web.UI.WebControls.DropDownList ddlFormat;
InBlock.gif myReport ReportDoc = new myReport();
InBlock.gifprivate void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif// 在此处放置用户代码以初始化页面
InBlock.gif
string strProvider = "Server=(local);DataBase=myDatabase;UID=sa;PWD=111";
InBlock.gif SqlConnection MyConn = new SqlConnection(strProvider);
InBlock.gif MyConn.Open();
InBlock.gifstring strSel = "Select * from SaleOfCuntry";
InBlock.gif SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel,MyConn);
InBlock.gif DataSet1 ds = new DataSet1();
InBlock.gif MyAdapter.Fill(ds,"SaleOfCuntry");
InBlock.gif ReportDoc.SetDataSource(ds);
InBlock.gif Crv.ReportSource = ReportDoc;
InBlock.gif
ExpandedSubBlockEnd.gif }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gifWeb Form Designer generated code#region Web Form Designer generated code
InBlock.gifoverride protected void OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//
InBlock.gif
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
InBlock.gif
//
InBlock.gif
InitializeComponent();
InBlock.gifbase.OnInit(e);
ExpandedSubBlockEnd.gif }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif/**//// <summary>
InBlock.gif
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
InBlock.gif
/// 此方法的内容。
ExpandedSubBlockEnd.gif
/// </summary>

InBlock.gifprivate void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifthis.btnExport.Click += new System.EventHandler(this.btnExport_Click);
InBlock.gifthis.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
InBlock.gifthis.Load += new System.EventHandler(this.Page_Load);
InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif#endregion

InBlock.gif
InBlock.gifprivate void btnExport_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
InBlock.gif ReportDoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
InBlock.gifswitch (ddlFormat.SelectedItem.Text)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifcase "Rich Text (RTF)":
InBlock.gif  ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.RichText;//
InBlock.gif
  DiskOpts.DiskFileName = "c:\\Output.rtf";//
InBlock.gif
break;
InBlock.gifcase "Portable Document (PDF)":
InBlock.gif  ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//
InBlock.gif
  DiskOpts.DiskFileName = "c:\\Output.pdf";//
InBlock.gif
break;
InBlock.gifcase "MS Word (DOC)":
InBlock.gif  ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.WordForWindows;//
InBlock.gif
  DiskOpts.DiskFileName = "c:\\Output.doc";//
InBlock.gif
break;
InBlock.gifcase "MS Excel (XLS)":
InBlock.gif  ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;//
InBlock.gif
  DiskOpts.DiskFileName = "c:\\Output.xls";//
InBlock.gif
break;
InBlock.gifdefault:
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif ReportDoc.ExportOptions.DestinationOptions = DiskOpts;
InBlock.gif  ReportDoc.Export();
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifprivate void btnPrint_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif// 指定打印机名称,这里是网络工作站Gigi上的打印机Hp Jet 6
InBlock.gif
string strPrinterName;
InBlock.gif strPrinterName = @"Canon Bubble-Jet BJC-210SP";
InBlock.gif// 设置打印页边距
InBlock.gif
PageMargins margins;
InBlock.gif margins = ReportDoc.PrintOptions.PageMargins;
InBlock.gif margins.bottomMargin = 250;
InBlock.gif margins.leftMargin = 350;
InBlock.gif margins.rightMargin = 350;
InBlock.gif margins.topMargin = 450;
InBlock.gif ReportDoc.PrintOptions.ApplyPageMargins(margins);
InBlock.gif//应用打印机名称
InBlock.gif
ReportDoc.PrintOptions.PrinterName = strPrinterName;
InBlock.gif// 打印 // 打印报表。将 startPageN 和 endPageN
InBlock.gif
// 参数设置为 0 表示打印所有页。
InBlock.gif
ReportDoc.PrintToPrinter(1, false,0,0);
InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif



本文转自高海东博客园博客,原文链接:http://www.cnblogs.com/ghd258/archive/2005/10/25/261677.html,如需转载请自行联系原作者
相关文章
|
5月前
|
Python
python pyqt5 cmd 命令行 控制台 打印 print 输出 显示打印内容 实时显示 界面
python pyqt5 cmd 命令行 控制台 打印 print 输出 显示打印内容 实时显示 界面
169 0
|
2月前
MFC编程 -- 保存和读取列表框内容
MFC编程 -- 保存和读取列表框内容
15 0
|
4月前
EndNote文献输出引用格式自定义修改与编辑界面解读
EndNote文献输出引用格式自定义修改与编辑界面解读
|
8月前
|
安全 数据安全/隐私保护
文档的保存和打印
3.8 文档的保存与打印 3.8.1 防止文档内容丢失 1. 自动恢复 Word提供自动恢复功能,可在很大程度上避免因为停电、机器死机等问题引发的文档丢失现象。在“文件”选项卡中的“选项”命令,在其中的“保存”选项卡中设置,默认10分钟,可以修改(1-120分钟)。 2. 自动备份文档副本 在编辑Word文档时,如果不小心保存了不需要的信息,或者原文档损坏,可以使用文档备份的副本避免损失。当然,这需要你事先在Word系统设置了“始终创建备份副本”功能,具体操作如下: 1单击“文件”选项卡,选择“选项”命令,打开对话框设置。 2选择此选项可在每次保存文档时创建一个文档的备份副本扩展名为 .wbk
|
10月前
|
图形学 C++
Qt实现Qchart的打印和打印预览的几种方法
Qt实现Qchart的打印和打印预览的几种方法
WIN10文件名排序错误的案例截图
WIN10文件名排序错误的案例截图
67 0
WIN10文件名排序错误的案例截图
|
Python
Python 技术篇-在cmd命令提示行里模拟动态下载进度条实例演示,cmd清除日志、打印动态内容方法
Python 技术篇-在cmd命令提示行里模拟动态下载进度条实例演示,cmd清除日志、打印动态内容方法
473 0
Python 技术篇-在cmd命令提示行里模拟动态下载进度条实例演示,cmd清除日志、打印动态内容方法
|
存储 Python
Python 自动化-pywinauto库print_control_identifiers()方法打印内容显示不全解决办法,cmd展示更多内容设置方法
Python 自动化-pywinauto库print_control_identifiers()方法打印内容显示不全解决办法,cmd展示更多内容设置方法
791 0
Python 自动化-pywinauto库print_control_identifiers()方法打印内容显示不全解决办法,cmd展示更多内容设置方法