我有一个TALBE表,打算这个table打印出来
但不能用JS代码去写,这样要降低安全性,我用的是.NET2003能在CS下写一个打印按钮吗?
高手指点下吧。
但不能用JS代码去写,这样要降低安全性,我用的是.NET2003能在CS下写一个打印按钮吗?
高手指点下吧。
解决方案 »
- MSSQL2000临时表分页通用sql语句偶尔会出错
- ASP.NET中FormView的问题.帮忙看看!
- System.Data.SqlClient.SqlException: 列名 'studyNumber' 无效 菜鸟请求赐教
- 求一无排序算法
- 如何隐藏由DataSet对象查询出来的DataGrid表
- 打包问题急急!
- 在ASP.net 2.0中如何通过服务器端控件激活客户端脚本?
- 怎么读出dataset中的任意一个数据呢?
- 如何在Dreamweaver中的htm文件中调用ASP.NET的aspx文件?有没有办法
- 怎么样释放ado.net中声明的对象!
- !!100分!超级郁闷的Cookie问题!!
- ~~菜鸟问题~~??????急
如果用JS的话
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath( "StudentsToHTML.xsl") );
XPathDocument XDoc = new XPathDocument(Server.MapPath( "Students.Xml" ));
XmlWriter writer = new XmlTextWriter( server.MapPath("Students.html"), System.Text.Encoding.UTF8 );
xslt.Transform( XDoc, null, writer );
writer.Close();
Response.Redirect("Students.html");
利用ActiveX控件打印利用第三方控件◆自己开发控件。这种方式很多商用软件采用这种方式,写成控件后已经无所谓是在web中使用还是应用程序中使用了。优点:打印方式非常灵活,基本上程序能做到的web也能做得到。缺点:客户端需要安装组件,部署不是很方便。使用水晶报表◆用户仅需要Web 浏览器就可以查看报表。◆报表查看器控件可以是应用程序中众多控件之一。◆与报表轻松交互◆用户可将报表导出为Microsoft word 和Excel 格式,以及PDF、HTML 和Crystal Reports for visual Studio .Net格式。◆可以使用报表控件直接打印【实例代码】 //水晶报表的填充,省略连接代码
myReport ReportDoc = new myReport();
ReportDoc.SetDataSource(ds);
Crv.ReportSource = ReportDoc;
//输出为指定类型文件
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new
CrystalDecisions.Shared.DiskFileDestinationOptions();
ReportDoc.ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile;
string strFileName = server.MapPath("Output");
switch (ddlFormat.SelectedItem.Text)
{
case "Rich Text (RTF)":
ReportDoc.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.RichText;
DiskOpts.DiskFileName =strFileName + ".rtf";
break;
case "Portable Document (PDF)":
ReportDoc.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
DiskOpts.DiskFileName = strFileName + ".pdf";
break;
case "MS word (DOC)":
ReportDoc.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.WordForWindows;
DiskOpts.DiskFileName = strFileName + ".doc";
break;
case "MS excel (XLS)":
ReportDoc.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.Excel;//
DiskOpts.DiskFileName = strFileName + ".xls";
break;
default:
break;
}
ReportDoc.ExportOptions.DestinationOptions = DiskOpts;
ReportDoc.Export();
//打印
// 指定打印机名称
string strPrinterName;
strPrinterName = @"Canon Bubble-Jet BJC-210SP";
// 设置打印页边距
PageMargins margins;
margins = ReportDoc.PrintOptions.PageMargins;
margins.bottomMargin = 250;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 450;
ReportDoc.PrintOptions.ApplyPageMargins(margins);
//应用打印机名称
ReportDoc.PrintOptions.PrinterName = strPrinterName;
// 打印
// 打印报表。将startPageN 和endPageN
// 参数设置为0 表示打印所有页。
ReportDoc.PrintToPrinter(1, false,0,0);
网上找的,不知道你有没有用