web打印问题,高分求助

ywcyj 2004-06-22 03:58:35
我要实现这样的功能:点击网页(。aspx)上的按钮,就加载某个。doc文件到打印机,实现打印功能
大家说说如何实现比较方便
...全文
177 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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();
}

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧