惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Achilles.NET

路过 通过javascript获得当前窗口页面的宽高度 SQL SERVER设置重新构造字段值大小写敏感 - Achilles.NET - 博客园 修改SQL默认不区分大小写字段值规则 [转帖]Transact-SQL编程规范 Version 1.1 - Achilles.NET C#调用存储过程返回值 - Achilles.NET - 博客园 Ghost备份后找不到gho镜像文件的解决办法 - Achilles.NET GridView数据突出颜色显示解决办法 GridView中空记录不显示表头的解决方案[作者不祥] Temple js控制标题闪动 山西DOT NET俱乐部 打印脚本 DataGrid分页 妻子让老公死心塌地的绝招 下班无聊,随便YY const(C# 参考) - Achilles.NET ERP──Enterprise Resource Planning 企业资源计划系统 extern(C# 参考)
WEB弹出窗口打印
Achilles.NET · 2007-04-17 · via 博客园 - Achilles.NET

  1using System;
  2using System.IO;
  3using System.Collections;
  4using System.ComponentModel;
  5using System.Data;
  6using System.Drawing;
  7using System.Web;
  8using System.Web.SessionState;
  9using System.Web.UI;
 10using System.Web.UI.WebControls;
 11using System.Web.UI.HtmlControls;
 12using System.Text;
 13
 14
 15namespace xxxx
 16{
 17    /// <summary>
 18    /// clsPrint 的摘要说明。
 19    /// </summary>

 20    public class CSPrint
 21    {
 22        public CSPrint()
 23        {
 24            //
 25            // TODO: 在此处添加构造函数逻辑
 26            //
 27        }

 28
 29        //打印DATAGRID数据
 30        public void dataGridPrint()
 31        {
 32
 33        }

 34
 35        public string pagePrint(DataTable dt,string tableName)
 36        {
 37            //pagePrint:根据DataTable转换成对应的HTML对应的字符串并打印
 38            DataTable myDataTable=new DataTable();
 39            myDataTable=dt;
 40 
 41            int myRow=myDataTable.Rows.Count; 
 42            int myCol=myDataTable.Columns.Count;
 43
 44//修改列标题
 45            myDataTable.Columns[0].ColumnName = "x1";
 46            myDataTable.Columns[1].ColumnName = "x2";
 47            myDataTable.Columns[2].ColumnName = "x3";
 48            myDataTable.Columns[3].ColumnName = "x4";
 49            myDataTable.Columns[4].ColumnName = "x5";
 50            myDataTable.Columns[5].ColumnName = "x6";
 51            myDataTable.Columns[6].ColumnName = "x7";
 52            
 53            
 54            
 55
 56            StringBuilder sb=new StringBuilder(); 
 57 
 58            string colHeaders="<html>" + "<head><title>" + tableName + "</title>"
 59                + "</head>"
 60                + "<body>"
 61                + "<script language='javascript'>"
 62                + "    try"
 63                + "      {"
 64                + "         var Wsh=new ActiveXObject('WScript.Shell');"
 65                + "         HKEY_Key='header';"
 66                + "            Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,'');"
 67                + "            HKEY_Key='footer';"
 68                + "            Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,'');"
 69                + "         }"
 70                + "       catch(e){}</script>"
 71                + "<object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'VIEWASTEXT></object>"
 72                + "<table border=1 cellspacing=0 cellpadding=0><caption align=center><font size=5><B>" + tableName + "</B></font></caption><tr>"
 73 
 74            for(int i=0;i<myCol;i++)
 75            {     
 76                colHeaders +="<th align=center>"+ myDataTable.Columns[i].ColumnName.ToString()+"</th>";
 77            }

 78            colHeaders += "</tr>";
 79            sb.Append(colHeaders);
 80 
 81            for(int i=0;i<myRow;i++)
 82            {       
 83                sb.Append("<tr>");
 84                for(int j=0;j<myCol;j++)
 85                {
 86                    sb.Append("<td align=center>");
 87                    if (myDataTable.Rows[i][j].ToString().Trim() != "")
 88                    {
 89                        sb.Append(myDataTable.Rows[i][j].ToString().Trim());
 90                    }

 91                    else
 92                    {
 93                        sb.Append("&nbsp;");
 94                    }

 95                    sb.Append("</td>");
 96                }

 97                sb.Append("</tr>");   
 98            }

 99 
100            sb.Append("</table></body></html>"); 
101            colHeaders=sb.ToString();               
102            colHeaders+="<script languge='javascript'>window.opener=null;WebBrowser.ExecWB(6,1); window.close();</script>";
103            return(colHeaders);
104
105        }

106    }

107}