web打印问题,高分求助

ywcyj 2004-06-22 03:58:35
我要实现这样的功能:点击网页(。aspx)上的按钮,就加载某个。doc文件到打印机,实现打印功能
大家说说如何实现比较方便
...全文
145 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
angelsea 2004-06-23
Study!
回复
vicyang 2004-06-23
UP !!! UP!!!......
回复
ywcyj 2004-06-22
to 楼上的兄弟
我现在的要求比你说的更简单
只要实现将现成的doc文件添加都打印机就成
回复
bxf2008 2004-06-22
1。你首先必须把报表载入,也就是你说的加载,
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
try
{
lblMessage.Visible=false;
DataSet myDs=new DataSet();
myDs=(DataSet) this.Session["g_sbcx_jg"];
//string jdyqcx_reporttitle=(string) this.Session["g_jdyqcx_title"];
rDsbcxAll.Load(Server.MapPath("CrSbcx_jg.rpt"));
//((TextObject)rDjdyqcx.ReportDefinition.Sections["Section2"].ReportObjects["toTitle"]).Text=jdyqcx_reporttitle;
rDsbcxAll.SetDataSource(myDs.Tables[0]);
CRVsbcxAll.ReportSource=rDsbcxAll;
}
catch(Exception ExLoad)
{
lblMessage.Visible=true;
lblMessage.Text=ExLoad.Message.ToString();

}

}
2。先保存到word文件里面,然后添加下面代码就可以实现你的要求
private void btnPrintWord_Click(object sender, System.EventArgs e)
{
try
{
CrystalDecisions.Shared.ExportOptions myExportsOptions;
CrystalDecisions.Shared.DiskFileDestinationOptions myDiskFileOptions;
string myExportFileName;
//Crsbcx_jg1 myReport=new Crsbcx_jg1();
//Read the temp directory from Web.Config,this temp Directory at the server
string strTempDirectory=System.Configuration.ConfigurationSettings.AppSettings["TempDirectory"];
//-----------------------------End--------------b0b0 2004-4.15
myExportFileName=strTempDirectory.Trim()+ this.Session.SessionID.ToString() +".doc" ;
myDiskFileOptions=new CrystalDecisions.Shared.DiskFileDestinationOptions();
myDiskFileOptions.DiskFileName=myExportFileName;
myExportsOptions=rDsbcxAll.ExportOptions;

myExportsOptions.DestinationOptions=myDiskFileOptions;
myExportsOptions.ExportDestinationType=CrystalDecisions.Shared.ExportDestinationType.DiskFile;
myExportsOptions.ExportFormatType=CrystalDecisions.Shared.ExportFormatType.WordForWindows;
rDsbcxAll.Export();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/msword";
Response.WriteFile(myExportFileName);
Response.Flush();
Response.Close();
System.IO.File.Delete(myExportFileName);
}
catch(Exception ExWord)
{
lblMessage.Visible=true;
lblMessage.Text=ExWord.Message.ToString();
}
回复
发动态
发帖子
C#
创建于2007-09-28

10.4w+

社区成员

.NET技术 C#
申请成为版主
社区公告

全世界最好的语言,没有之一.