如何将html转aspx文件转化为ASPX文件

> 怎么将HTML网页转换为aspx
怎么将HTML网页转换为aspx
liwanling & &
发布时间: & &
浏览:3 & &
回复:9 & &
悬赏:0.0希赛币
如何将HTML网页转换为aspx是这样的, & 先让美工用dreamweaver做好了界面, & 然后拿过来写程序, & 在VS.NET & 2003中可以直接将html转成aspx的, & 但在VS2005中不行了
并不只是改改扩展名, & 还要同时生成对应的.resx和.cs文件
你可以让美工用dreamweaver直接作成aspx页啊
我刚才试了,没搞出来
liwei043 & &
01:01:50 & &
& & (0)(0)引用05中建立aspx页面,把html页面代码拷过来
liwei110110 & &
01:01:50 & &
& & (0)(0)引用建立aspx页面,把html页面代码拷过来
------------------------------------
liwcch & &
01:01:50 & &
& & (0)(0)引用就是,拷代码不就得了,
liwei_snake & &
01:01:50 & &
& & (0)(0)引用先建个aspx的页面,在把html代码烤进去。
Sunny_Jane & &
01:01:50 & &
& & (0)(0)引用先添加一个小的代码文件,然后再改了扩展名的文件里加page指令,最后在aspx文件上右键选择“转换为Web应用程序”。不管是改文件名还是拷贝代码,本质是一样的。我觉得自动生成的代码还是要研究一番才好,有助于提高技巧。
sunny_335 & &
01:01:50 & &
& & (1)(0)引用同上 把代码拷进来
sunny_happy & &
01:01:50 & &
& & (0)(0)引用Me toosunny_305 & &
01:01:50 & &
& & (0)(0)引用会了么?求告知吃西瓜的小科科 & &
12:02:55 & &
& & (0)(0)引用
本问题标题:
本问题地址:
温馨提示:本问答中心的任何言论仅代表发言者个人的观点,与希赛网立场无关。请对您的言论负责,遵守中华人民共和国有关法律、法规。如果您的言论违反希赛网问答中心的规则,将会被删除。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&HTML源代码转换JavaScript代码工具
JavaScript源代码转换HTML代码工具
可以把html内容转换成js输出,反之也可以转换回来
配色/在线汉字.net如何把html页面表格转换成excel文件?
此答案由tang666提供
??一步:在页面前台加上如下代码&a class=&button_2& onclick=&javaScript:window.printReport()& style=&cursor:hand&&打 &印&/a&&Script language=网页特效& & &var winIndex = 0; & &//打印 & &function printReport() & &{ & & & & & & & &var width = &600&; & & & &var height = &400&; & & & &var urlVar = &../Report/PmsAccidentStatisticsReportExcel.asp教程x?formyear=&%=_flag %&&; & & & &var top = (screen.availHeight - height) / 2; & & & &var left = (screen.availWidth - width) / 2; & & & &var feather = &toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=& + width + &px,height=& + height & & & & & & & & & & + &px,top=& + top + &,left=& + left + &,titlebar=no&; & & & &var t = window.open(urlVar, &pmsReport_Allpms19&+winIndex, feather); & & & & & & & &t.focus(); & & & & & & & &winIndex++; & &}&/script&第二步: & 新建PmsAccidentStatisticsReportExcel.aspx文件.这个页面用来输出Excel文件.所以这个页面根据传过来的参数得出全部所需要下载的数据PmsAccidentStatisticsReportExcel.aspx前台代码 (主要是建一个Table其中的每个TD用&%=_formyear%&绑定后如的string字段,用Label控件不行)&%@ Page Language=&C#& AutoEventWireup=&true& CodeFile=&PmsAccidentStatisticsReportExcel.aspx.cs&& & Inherits=&Web_PmsReport_Report_PmsAccidentStatisticsReportExcel& %&&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&&script language=&javascript&&& & window.resizeTo(10,10);& & window.close();&/script&&html&&head&& & &title&青岛市交通报表信息&/title&& & &meta content=&Microsoft Visual Studio .NET 7.1& name=&GENERATOR&&& & &meta content=&C#& name=&CODE_LANGUAGE&&& & &meta content=&JavaScript& name=&vs_defaultClientScript&&& & &meta content=&/intellisense/ie5& name=&vs_targetSchema&&&/head&&body&& & &form id=&Form1& method=&post& runat=&server&&& & & & &table cellspacing=&0& cellpadding=&0& border=&1& width=&98%& align=&center&&& & & & & & &tr&& & & & & & & & &td&& & & & & & & & & & &table class=&table& cellspacing=&1& cellpadding=&5& width=&100%& border=&1& style=&font-size: 11&&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&tr_biaoti2& colspan=&7& style=& font-size: 14 text-align: center&&& & & & & & & & & & & & & & & & &h3&道路运输行业行车事故统计表 &/h3&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5' width='72%'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' width='28%'&& & & & & & & & & & & & & & & & 表 & &号:&%=_FormNo%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 制表机关:&%=_MadeDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准机关:&%=_CheckDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准文号:&%=_CheckNo%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' align=&center&&& & & & & & & & & & & & & & & & 填报单位& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: left& colspan='2'&& & & & & & & & & & & & & & & & & &%=_SendUnit%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='1' align='center' style=&text-align: height: 25px&&& & & & & & & & & & & & & & & & &b&& & & & & & & & & & & & & & & & & & &%=_FormYear1%&& & & & & & & & & & & & & & & & &/b&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 有效期至:&%=_FormY%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center& rowspan='2'&& & & & & & & & & & & & & & & & & 指标& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='4' style=&text-align: center&&& & & & & & & & & & & & & & & & & 事故次数(次)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' style=&text-align: center&&& & & & & & & & & & & & & & & & & 死伤人数(人)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25& width='13%'&& & & & & & & & & & & & & & & & & 合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡10人以上& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡3至9人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡1至2人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 死亡& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 受伤& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & & 本月合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label1%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label2%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label3%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label4%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label5%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label6%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & & 客车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label7%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label8%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label9%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label10%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label11%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label12%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 货车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label13%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label14%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label15%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label16%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label17%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label18%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &危险化学品&br /&& & & & & & & & & & & & & & & & &运输车辆& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label19%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label20%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label21%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label22%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label23%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label24%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='7' width='100%' align=&center& style=&font-size: 11&&& & & & & & & & & & & & & & & & &单位负责人:& & & & & & & & & & & & & & & & &%=_UnitManager%&& & & & & & & & & & & & & & & & &统计负责人:& & & & & & & & & & & & & & & & &%=_StarUser%&& & & & & & & & & & & & & & & & &填表人:&%=_FillUser%&& & & & & & & & & & & & & & & & &联系电话:&%=_FormPhone%&& & & & & & & & & & & & & & & & &报出日期:&%=_FormDate%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & &/table&& & & & & & & & &/td&& & & & & & &/tr&& & & & &/table&& & & & &br&& & &/form&&/body&&/html&&第三步 在PmsAccidentStatisticsReportExcel.aspx后台cs文件里对以上各绑定的string字段定义和赋值再加上如下代码& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&); & & & &Response.Charset = &gb2312&; & & & &Response.ContentType = &application/msexcel&;完整的代码如下using Susing System.Dusing System.Cusing System.Cusing System.Wusing System.Web.Susing System.Web.UI;using System.Web.UI.WebCusing System.Web.UI.WebControls.WebPusing System.Web.UI.HtmlC//工具mon.U//业务声明using Pms.PmsReport.BLL;using Pms.PmsReport.M//使用泛型using System.Collections.Gpublic partial class Web_PmsReport_Report_PmsAccidentStatisticsReportExcel : System.Web.UI.Page{& & private PmsReportBll1 _bll = new PmsReportBll1();& & private string _& & private DataTable dt1 = new DataTable();& & private DataTable dt2 = new DataTable();& & private DataTable dt3 = new DataTable();& & private DataTable dt4 = new DataTable();& & private DataTable dt5 = new DataTable();& & protected string _label1=&0&;& & protected string _label2=&0&;& & protected string _label3 = &0&;& & protected string _label4 = &0&;& & protected string _label5 = &0&;& & protected string _label6 = &0&;& & protected string _label7 = &0&;& & protected string _label8 = &0&;& & protected string _label9 = &0&;& & protected string _label10 = &0&;& & protected string _label11 = &0&;& & protected string _label12 = &0&;& & protected string _label13 = &0&;& & protected string _label14 = &0&;& & protected string _label15 = &0&;& & protected string _label16 = &0&;& & protected string _label17 = &0&;& & protected string _label18 = &0&;& & protected string _label19 = &0&;& & protected string _label20 = &0&;& & protected string _label21 = &0&;& & protected string _label22 = &0&;& & protected string _label23 = &0&;& & protected string _label24 = &0&;& & protected string _FormNo;& & protected string _MadeD& & protected string _CheckD& & protected string _CheckNo;& & protected string _SendU& & protected string _FormYear1;& & protected string _FormY;& & protected string _UnitM& & protected string _StarU& & protected string _FillU& & protected string _FormP& & protected string _FormD& & int m = 0;& & int n = 0;& & int k = 0;& & List&string& arryLabel = new List&string&();& & protected void Page_Load(object sender, EventArgs e)& & {& & & & _FormYear1 = Request.Params[&formyear&].ToString().Substring(0, 4) + &年& + Request.Params[&formyear&].ToString().Substring(5, 2)+&月&;& & & & dt1 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &大型客车&);& & & & dt2 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &中型客车&);& & & & dt3 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &乘用车&);& & & & dt4 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &货车&);& & & & dt5 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &危险品运输车&);& & & & //Id.Text = _bll.IsExist(&Allpms19&, Request.Params[&formyear&].ToString());&& & & & DataTable dt = _bll.SelectCountModel(Request.Params[&formyear&].ToString());& & & & _FormNo = dt.Rows[0][&FormNo&].ToString();& & & & _MadeDep = dt.Rows[0][&MadeDep&].ToString();& & & & _CheckDep = dt.Rows[0][&CheckDep&].ToString();& & & & _CheckNo = dt.Rows[0][&CheckNo&].ToString();& & & & _SendUnit = dt.Rows[0][&SendUnit&].ToString(); & && & & & _FormY = dt.Rows[0][&FormY&].ToString();& & & & _UnitManager = dt.Rows[0][&UnitManager&].ToString();& & & & _StarUser = dt.Rows[0][&StarUser&].ToString();& & & & _FillUser = dt.Rows[0][&FillUser&].ToString();& & & & _FormPhone = dt.Rows[0][&FormPhone&].ToString();& & & & _FormDate = dt.Rows[0][&FormDate&].ToString();& & &&& & & & //计算事故死亡人数大于10人的事故次数& & & & arryLabel.Add(_label8);& & & & arryLabel.Add(_label14);& & & & arryLabel.Add(_label20);& & & & Count(arryLabel, &max&);& & & & _label8 = arryLabel[0];& & & & _label14 = arryLabel[1];& & & & _label20 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label2 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label14) + Convert.ToInt32(_label20));& & & & //计算事故死亡人数在3人到9人之间的事故次数& & & & arryLabel.Add(_label9);& & & & arryLabel.Add(_label15);& & & & arryLabel.Add(_label21);& & & & Count(arryLabel, &middle&);& & & & _label9 = arryLabel[0];& & & & _label15 = arryLabel[1];& & & & _label21 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label3 = Convert.ToString(Convert.ToInt32(_label9) + Convert.ToInt32(_label15) + Convert.ToInt32(_label21));& & & & //计算事故死亡人数小于3人的事故次数& & & & arryLabel.Add(_label10);& & & & arryLabel.Add(_label16);& & & & arryLabel.Add(_label22);& & & & Count(arryLabel, &min&);& & & & _label10 = arryLabel[0];& & & & _label16 = arryLabel[1];& & & & _label22 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label4 = Convert.ToString(Convert.ToInt32(_label10) + Convert.ToInt32(_label16) + Convert.ToInt32(_label22));& & & & //计算事故死亡人数& & & & arryLabel.Add(_label11);& & & & arryLabel.Add(_label17);& & & & arryLabel.Add(_label23);& & & & Count(arryLabel, &deadtotal&);& & & & _label11 = arryLabel[0];& & & & _label17 = arryLabel[1];& & & & _label23 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label5 = Convert.ToString(Convert.ToInt32(_label11) + Convert.ToInt32(_label17) + Convert.ToInt32(_label23));& & & & //计算事故受伤人数& & & & arryLabel.Add(_label12);& & & & arryLabel.Add(_label18);& & & & arryLabel.Add(_label24);& & & & Count(arryLabel, &hurttotal&);& & & & _label12 = arryLabel[0];& & & & _label18 = arryLabel[1];& & & & _label24 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label6 = Convert.ToString(Convert.ToInt32(_label12) + Convert.ToInt32(_label18) + Convert.ToInt32(_label24));& & & & //各行的统计& & & & _label1 = Convert.ToString(Convert.ToInt32(_label2) + Convert.ToInt32(_label3) + Convert.ToInt32(_label4));& & & & _label7 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label9) + Convert.ToInt32(_label10));& & & & _label13 = Convert.ToString(Convert.ToInt32(_label14) + Convert.ToInt32(_label15) + Convert.ToInt32(_label16));& & & & _label19 = Convert.ToString(Convert.ToInt32(_label20) + Convert.ToInt32(_label21) + Convert.ToInt32(_label22));& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&);& & & & Response.Charset = &gb2312&;& & & & Response.ContentType = &application/msexcel&;& & }& & private void Count(List&string& arryLabel, string val)& & {& & & & if (dt1.Rows.Count & 0 && dt1.Rows[0][val].ToString() != &&)& & & & {& & & & & & m = Convert.ToInt32(dt1.Rows[0][val].ToString());& & & & }& & & & if (dt2.Rows.Count & 0 && dt2.Rows[0][val].ToString() != &&)& & & & {& & & & & & n = Convert.ToInt32(dt2.Rows[0][val].ToString());& & & & }& & & & if (dt3.Rows.Count & 0 && dt3.Rows[0][val].ToString() != &&)& & & & {& & & & & & k = Convert.ToInt32(dt3.Rows[0][val].ToString());& & & & }& & & & arryLabel[0] = Convert.ToString(m + n + k);& & & & if (dt4.Rows.Count & 0 && dt4.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[1] = dt4.Rows[0][val].ToString();& & & & }& & & & if (dt5.Rows.Count & 0 && dt5.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[2] = dt5.Rows[0][val].ToString();& & & & }& & }}??
此答案由tang666提供
??一步:在页面前台加上如下代码&a class=&button_2& onclick=&javaScript:window.printReport()& style=&cursor:hand&&打 &印&/a&&Script language=网页特效& & &var winIndex = 0; & &//打印 & &function printReport() & &{ & & & & & & & &var width = &600&; & & & &var height = &400&; & & & &var urlVar = &../Report/PmsAccidentStatisticsReportExcel.asp教程x?formyear=&%=_flag %&&; & & & &var top = (screen.availHeight - height) / 2; & & & &var left = (screen.availWidth - width) / 2; & & & &var feather = &toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=& + width + &px,height=& + height & & & & & & & & & & + &px,top=& + top + &,left=& + left + &,titlebar=no&; & & & &var t = window.open(urlVar, &pmsReport_Allpms19&+winIndex, feather); & & & & & & & &t.focus(); & & & & & & & &winIndex++; & &}&/script&第二步: & 新建PmsAccidentStatisticsReportExcel.aspx文件.这个页面用来输出Excel文件.所以这个页面根据传过来的参数得出全部所需要下载的数据PmsAccidentStatisticsReportExcel.aspx前台代码 (主要是建一个Table其中的每个TD用&%=_formyear%&绑定后如的string字段,用Label控件不行)&%@ Page Language=&C#& AutoEventWireup=&true& CodeFile=&PmsAccidentStatisticsReportExcel.aspx.cs&& & Inherits=&Web_PmsReport_Report_PmsAccidentStatisticsReportExcel& %&&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&&script language=&javascript&&& & window.resizeTo(10,10);& & window.close();&/script&&html&&head&& & &title&青岛市交通报表信息&/title&& & &meta content=&Microsoft Visual Studio .NET 7.1& name=&GENERATOR&&& & &meta content=&C#& name=&CODE_LANGUAGE&&& & &meta content=&JavaScript& name=&vs_defaultClientScript&&& & &meta content=&/intellisense/ie5& name=&vs_targetSchema&&&/head&&body&& & &form id=&Form1& method=&post& runat=&server&&& & & & &table cellspacing=&0& cellpadding=&0& border=&1& width=&98%& align=&center&&& & & & & & &tr&& & & & & & & & &td&& & & & & & & & & & &table class=&table& cellspacing=&1& cellpadding=&5& width=&100%& border=&1& style=&font-size: 11&&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&tr_biaoti2& colspan=&7& style=& font-size: 14 text-align: center&&& & & & & & & & & & & & & & & & &h3&道路运输行业行车事故统计表 &/h3&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5' width='72%'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' width='28%'&& & & & & & & & & & & & & & & & 表 & &号:&%=_FormNo%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 制表机关:&%=_MadeDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准机关:&%=_CheckDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准文号:&%=_CheckNo%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' align=&center&&& & & & & & & & & & & & & & & & 填报单位& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: left& colspan='2'&& & & & & & & & & & & & & & & & & &%=_SendUnit%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='1' align='center' style=&text-align: height: 25px&&& & & & & & & & & & & & & & & & &b&& & & & & & & & & & & & & & & & & & &%=_FormYear1%&& & & & & & & & & & & & & & & & &/b&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 有效期至:&%=_FormY%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center& rowspan='2'&& & & & & & & & & & & & & & & & & 指标& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='4' style=&text-align: center&&& & & & & & & & & & & & & & & & & 事故次数(次)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' style=&text-align: center&&& & & & & & & & & & & & & & & & & 死伤人数(人)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25& width='13%'&& & & & & & & & & & & & & & & & & 合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡10人以上& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡3至9人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡1至2人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 死亡& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 受伤& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & & 本月合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label1%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label2%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label3%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label4%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label5%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label6%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & & 客车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label7%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label8%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label9%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label10%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label11%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label12%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 货车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label13%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label14%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label15%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label16%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label17%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label18%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &危险化学品&br /&& & & & & & & & & & & & & & & & &运输车辆& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label19%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label20%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label21%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label22%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label23%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label24%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='7' width='100%' align=&center& style=&font-size: 11&&& & & & & & & & & & & & & & & & &单位负责人:& & & & & & & & & & & & & & & & &%=_UnitManager%&& & & & & & & & & & & & & & & & &统计负责人:& & & & & & & & & & & & & & & & &%=_StarUser%&& & & & & & & & & & & & & & & & &填表人:&%=_FillUser%&& & & & & & & & & & & & & & & & &联系电话:&%=_FormPhone%&& & & & & & & & & & & & & & & & &报出日期:&%=_FormDate%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & &/table&& & & & & & & & &/td&& & & & & & &/tr&& & & & &/table&& & & & &br&& & &/form&&/body&&/html&&第三步 在PmsAccidentStatisticsReportExcel.aspx后台cs文件里对以上各绑定的string字段定义和赋值再加上如下代码& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&); & & & &Response.Charset = &gb2312&; & & & &Response.ContentType = &application/msexcel&;完整的代码如下using Susing System.Dusing System.Cusing System.Cusing System.Wusing System.Web.Susing System.Web.UI;using System.Web.UI.WebCusing System.Web.UI.WebControls.WebPusing System.Web.UI.HtmlC//工具mon.U//业务声明using Pms.PmsReport.BLL;using Pms.PmsReport.M//使用泛型using System.Collections.Gpublic partial class Web_PmsReport_Report_PmsAccidentStatisticsReportExcel : System.Web.UI.Page{& & private PmsReportBll1 _bll = new PmsReportBll1();& & private string _& & private DataTable dt1 = new DataTable();& & private DataTable dt2 = new DataTable();& & private DataTable dt3 = new DataTable();& & private DataTable dt4 = new DataTable();& & private DataTable dt5 = new DataTable();& & protected string _label1=&0&;& & protected string _label2=&0&;& & protected string _label3 = &0&;& & protected string _label4 = &0&;& & protected string _label5 = &0&;& & protected string _label6 = &0&;& & protected string _label7 = &0&;& & protected string _label8 = &0&;& & protected string _label9 = &0&;& & protected string _label10 = &0&;& & protected string _label11 = &0&;& & protected string _label12 = &0&;& & protected string _label13 = &0&;& & protected string _label14 = &0&;& & protected string _label15 = &0&;& & protected string _label16 = &0&;& & protected string _label17 = &0&;& & protected string _label18 = &0&;& & protected string _label19 = &0&;& & protected string _label20 = &0&;& & protected string _label21 = &0&;& & protected string _label22 = &0&;& & protected string _label23 = &0&;& & protected string _label24 = &0&;& & protected string _FormNo;& & protected string _MadeD& & protected string _CheckD& & protected string _CheckNo;& & protected string _SendU& & protected string _FormYear1;& & protected string _FormY;& & protected string _UnitM& & protected string _StarU& & protected string _FillU& & protected string _FormP& & protected string _FormD& & int m = 0;& & int n = 0;& & int k = 0;& & List&string& arryLabel = new List&string&();& & protected void Page_Load(object sender, EventArgs e)& & {& & & & _FormYear1 = Request.Params[&formyear&].ToString().Substring(0, 4) + &年& + Request.Params[&formyear&].ToString().Substring(5, 2)+&月&;& & & & dt1 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &大型客车&);& & & & dt2 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &中型客车&);& & & & dt3 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &乘用车&);& & & & dt4 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &货车&);& & & & dt5 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &危险品运输车&);& & & & //Id.Text = _bll.IsExist(&Allpms19&, Request.Params[&formyear&].ToString());&& & & & DataTable dt = _bll.SelectCountModel(Request.Params[&formyear&].ToString());& & & & _FormNo = dt.Rows[0][&FormNo&].ToString();& & & & _MadeDep = dt.Rows[0][&MadeDep&].ToString();& & & & _CheckDep = dt.Rows[0][&CheckDep&].ToString();& & & & _CheckNo = dt.Rows[0][&CheckNo&].ToString();& & & & _SendUnit = dt.Rows[0][&SendUnit&].ToString(); & && & & & _FormY = dt.Rows[0][&FormY&].ToString();& & & & _UnitManager = dt.Rows[0][&UnitManager&].ToString();& & & & _StarUser = dt.Rows[0][&StarUser&].ToString();& & & & _FillUser = dt.Rows[0][&FillUser&].ToString();& & & & _FormPhone = dt.Rows[0][&FormPhone&].ToString();& & & & _FormDate = dt.Rows[0][&FormDate&].ToString();& & &&& & & & //计算事故死亡人数大于10人的事故次数& & & & arryLabel.Add(_label8);& & & & arryLabel.Add(_label14);& & & & arryLabel.Add(_label20);& & & & Count(arryLabel, &max&);& & & & _label8 = arryLabel[0];& & & & _label14 = arryLabel[1];& & & & _label20 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label2 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label14) + Convert.ToInt32(_label20));& & & & //计算事故死亡人数在3人到9人之间的事故次数& & & & arryLabel.Add(_label9);& & & & arryLabel.Add(_label15);& & & & arryLabel.Add(_label21);& & & & Count(arryLabel, &middle&);& & & & _label9 = arryLabel[0];& & & & _label15 = arryLabel[1];& & & & _label21 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label3 = Convert.ToString(Convert.ToInt32(_label9) + Convert.ToInt32(_label15) + Convert.ToInt32(_label21));& & & & //计算事故死亡人数小于3人的事故次数& & & & arryLabel.Add(_label10);& & & & arryLabel.Add(_label16);& & & & arryLabel.Add(_label22);& & & & Count(arryLabel, &min&);& & & & _label10 = arryLabel[0];& & & & _label16 = arryLabel[1];& & & & _label22 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label4 = Convert.ToString(Convert.ToInt32(_label10) + Convert.ToInt32(_label16) + Convert.ToInt32(_label22));& & & & //计算事故死亡人数& & & & arryLabel.Add(_label11);& & & & arryLabel.Add(_label17);& & & & arryLabel.Add(_label23);& & & & Count(arryLabel, &deadtotal&);& & & & _label11 = arryLabel[0];& & & & _label17 = arryLabel[1];& & & & _label23 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label5 = Convert.ToString(Convert.ToInt32(_label11) + Convert.ToInt32(_label17) + Convert.ToInt32(_label23));& & & & //计算事故受伤人数& & & & arryLabel.Add(_label12);& & & & arryLabel.Add(_label18);& & & & arryLabel.Add(_label24);& & & & Count(arryLabel, &hurttotal&);& & & & _label12 = arryLabel[0];& & & & _label18 = arryLabel[1];& & & & _label24 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label6 = Convert.ToString(Convert.ToInt32(_label12) + Convert.ToInt32(_label18) + Convert.ToInt32(_label24));& & & & //各行的统计& & & & _label1 = Convert.ToString(Convert.ToInt32(_label2) + Convert.ToInt32(_label3) + Convert.ToInt32(_label4));& & & & _label7 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label9) + Convert.ToInt32(_label10));& & & & _label13 = Convert.ToString(Convert.ToInt32(_label14) + Convert.ToInt32(_label15) + Convert.ToInt32(_label16));& & & & _label19 = Convert.ToString(Convert.ToInt32(_label20) + Convert.ToInt32(_label21) + Convert.ToInt32(_label22));& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&);& & & & Response.Charset = &gb2312&;& & & & Response.ContentType = &application/msexcel&;& & }& & private void Count(List&string& arryLabel, string val)& & {& & & & if (dt1.Rows.Count & 0 && dt1.Rows[0][val].ToString() != &&)& & & & {& & & & & & m = Convert.ToInt32(dt1.Rows[0][val].ToString());& & & & }& & & & if (dt2.Rows.Count & 0 && dt2.Rows[0][val].ToString() != &&)& & & & {& & & & & & n = Convert.ToInt32(dt2.Rows[0][val].ToString());& & & & }& & & & if (dt3.Rows.Count & 0 && dt3.Rows[0][val].ToString() != &&)& & & & {& & & & & & k = Convert.ToInt32(dt3.Rows[0][val].ToString());& & & & }& & & & arryLabel[0] = Convert.ToString(m + n + k);& & & & if (dt4.Rows.Count & 0 && dt4.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[1] = dt4.Rows[0][val].ToString();& & & & }& & & & if (dt5.Rows.Count & 0 && dt5.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[2] = dt5.Rows[0][val].ToString();& & & & }& & }}??
此答案由tang666提供
??一步:在页面前台加上如下代码&a class=&button_2& onclick=&javaScript:window.printReport()& style=&cursor:hand&&打 &印&/a&&Script language=网页特效& & &var winIndex = 0; & &//打印 & &function printReport() & &{ & & & & & & & &var width = &600&; & & & &var height = &400&; & & & &var urlVar = &../Report/PmsAccidentStatisticsReportExcel.asp教程x?formyear=&%=_flag %&&; & & & &var top = (screen.availHeight - height) / 2; & & & &var left = (screen.availWidth - width) / 2; & & & &var feather = &toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=& + width + &px,height=& + height & & & & & & & & & & + &px,top=& + top + &,left=& + left + &,titlebar=no&; & & & &var t = window.open(urlVar, &pmsReport_Allpms19&+winIndex, feather); & & & & & & & &t.focus(); & & & & & & & &winIndex++; & &}&/script&第二步: & 新建PmsAccidentStatisticsReportExcel.aspx文件.这个页面用来输出Excel文件.所以这个页面根据传过来的参数得出全部所需要下载的数据PmsAccidentStatisticsReportExcel.aspx前台代码 (主要是建一个Table其中的每个TD用&%=_formyear%&绑定后如的string字段,用Label控件不行)&%@ Page Language=&C#& AutoEventWireup=&true& CodeFile=&PmsAccidentStatisticsReportExcel.aspx.cs&& & Inherits=&Web_PmsReport_Report_PmsAccidentStatisticsReportExcel& %&&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&&script language=&javascript&&& & window.resizeTo(10,10);& & window.close();&/script&&html&&head&& & &title&青岛市交通报表信息&/title&& & &meta content=&Microsoft Visual Studio .NET 7.1& name=&GENERATOR&&& & &meta content=&C#& name=&CODE_LANGUAGE&&& & &meta content=&JavaScript& name=&vs_defaultClientScript&&& & &meta content=&/intellisense/ie5& name=&vs_targetSchema&&&/head&&body&& & &form id=&Form1& method=&post& runat=&server&&& & & & &table cellspacing=&0& cellpadding=&0& border=&1& width=&98%& align=&center&&& & & & & & &tr&& & & & & & & & &td&& & & & & & & & & & &table class=&table& cellspacing=&1& cellpadding=&5& width=&100%& border=&1& style=&font-size: 11&&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&tr_biaoti2& colspan=&7& style=& font-size: 14 text-align: center&&& & & & & & & & & & & & & & & & &h3&道路运输行业行车事故统计表 &/h3&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5' width='72%'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' width='28%'&& & & & & & & & & & & & & & & & 表 & &号:&%=_FormNo%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 制表机关:&%=_MadeDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准机关:&%=_CheckDep%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='5'&& & & & & & & & & & & & & & & & && & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 批准文号:&%=_CheckNo%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' align=&center&&& & & & & & & & & & & & & & & & 填报单位& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: left& colspan='2'&& & & & & & & & & & & & & & & & & &%=_SendUnit%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='1' align='center' style=&text-align: height: 25px&&& & & & & & & & & & & & & & & & &b&& & & & & & & & & & & & & & & & & & &%=_FormYear1%&& & & & & & & & & & & & & & & & &/b&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2'&& & & & & & & & & & & & & & & & 有效期至:&%=_FormY%&&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center& rowspan='2'&& & & & & & & & & & & & & & & & & 指标& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='4' style=&text-align: center&&& & & & & & & & & & & & & & & & & 事故次数(次)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& colspan='2' style=&text-align: center&&& & & & & & & & & & & & & & & & & 死伤人数(人)& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25& width='13%'&& & & & & & & & & & & & & & & & & 合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡10人以上& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡3至9人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 一次造成死亡1至2人& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 死亡& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 受伤& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & & 本月合计& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label1%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label2%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label3%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label4%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label5%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 27&&& & & & & & & & & & & & & & & & &%=_label6%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & & 客车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label7%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label8%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label9%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label10%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label11%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label12%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & & 货车& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label13%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label14%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label15%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label16%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label17%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: height: 25&&& & & & & & & & & & & & & & & & &%=_label18%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &危险化学品&br /&& & & & & & & & & & & & & & & & &运输车辆& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label19%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label20%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label21%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label22%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label23%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & & & &td class=&td_left& style=&text-align: center&&& & & & & & & & & & & & & & & & &%=_label24%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & & & &tr&& & & & & & & & & & & & & & &td class=&td_right& colspan='7' width='100%' align=&center& style=&font-size: 11&&& & & & & & & & & & & & & & & & &单位负责人:& & & & & & & & & & & & & & & & &%=_UnitManager%&& & & & & & & & & & & & & & & & &统计负责人:& & & & & & & & & & & & & & & & &%=_StarUser%&& & & & & & & & & & & & & & & & &填表人:&%=_FillUser%&& & & & & & & & & & & & & & & & &联系电话:&%=_FormPhone%&& & & & & & & & & & & & & & & & &报出日期:&%=_FormDate%&& & & & & & & & & & & & & & &/td&& & & & & & & & & & & & &/tr&& & & & & & & & & & &/table&& & & & & & & & &/td&& & & & & & &/tr&& & & & &/table&& & & & &br&& & &/form&&/body&&/html&&第三步 在PmsAccidentStatisticsReportExcel.aspx后台cs文件里对以上各绑定的string字段定义和赋值再加上如下代码& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&); & & & &Response.Charset = &gb2312&; & & & &Response.ContentType = &application/msexcel&;完整的代码如下using Susing System.Dusing System.Cusing System.Cusing System.Wusing System.Web.Susing System.Web.UI;using System.Web.UI.WebCusing System.Web.UI.WebControls.WebPusing System.Web.UI.HtmlC//工具mon.U//业务声明using Pms.PmsReport.BLL;using Pms.PmsReport.M//使用泛型using System.Collections.Gpublic partial class Web_PmsReport_Report_PmsAccidentStatisticsReportExcel : System.Web.UI.Page{& & private PmsReportBll1 _bll = new PmsReportBll1();& & private string _& & private DataTable dt1 = new DataTable();& & private DataTable dt2 = new DataTable();& & private DataTable dt3 = new DataTable();& & private DataTable dt4 = new DataTable();& & private DataTable dt5 = new DataTable();& & protected string _label1=&0&;& & protected string _label2=&0&;& & protected string _label3 = &0&;& & protected string _label4 = &0&;& & protected string _label5 = &0&;& & protected string _label6 = &0&;& & protected string _label7 = &0&;& & protected string _label8 = &0&;& & protected string _label9 = &0&;& & protected string _label10 = &0&;& & protected string _label11 = &0&;& & protected string _label12 = &0&;& & protected string _label13 = &0&;& & protected string _label14 = &0&;& & protected string _label15 = &0&;& & protected string _label16 = &0&;& & protected string _label17 = &0&;& & protected string _label18 = &0&;& & protected string _label19 = &0&;& & protected string _label20 = &0&;& & protected string _label21 = &0&;& & protected string _label22 = &0&;& & protected string _label23 = &0&;& & protected string _label24 = &0&;& & protected string _FormNo;& & protected string _MadeD& & protected string _CheckD& & protected string _CheckNo;& & protected string _SendU& & protected string _FormYear1;& & protected string _FormY;& & protected string _UnitM& & protected string _StarU& & protected string _FillU& & protected string _FormP& & protected string _FormD& & int m = 0;& & int n = 0;& & int k = 0;& & List&string& arryLabel = new List&string&();& & protected void Page_Load(object sender, EventArgs e)& & {& & & & _FormYear1 = Request.Params[&formyear&].ToString().Substring(0, 4) + &年& + Request.Params[&formyear&].ToString().Substring(5, 2)+&月&;& & & & dt1 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &大型客车&);& & & & dt2 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &中型客车&);& & & & dt3 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &乘用车&);& & & & dt4 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &货车&);& & & & dt5 = _bll.SelectMonth(Request.Params[&formyear&].ToString(), &危险品运输车&);& & & & //Id.Text = _bll.IsExist(&Allpms19&, Request.Params[&formyear&].ToString());&& & & & DataTable dt = _bll.SelectCountModel(Request.Params[&formyear&].ToString());& & & & _FormNo = dt.Rows[0][&FormNo&].ToString();& & & & _MadeDep = dt.Rows[0][&MadeDep&].ToString();& & & & _CheckDep = dt.Rows[0][&CheckDep&].ToString();& & & & _CheckNo = dt.Rows[0][&CheckNo&].ToString();& & & & _SendUnit = dt.Rows[0][&SendUnit&].ToString(); & && & & & _FormY = dt.Rows[0][&FormY&].ToString();& & & & _UnitManager = dt.Rows[0][&UnitManager&].ToString();& & & & _StarUser = dt.Rows[0][&StarUser&].ToString();& & & & _FillUser = dt.Rows[0][&FillUser&].ToString();& & & & _FormPhone = dt.Rows[0][&FormPhone&].ToString();& & & & _FormDate = dt.Rows[0][&FormDate&].ToString();& & &&& & & & //计算事故死亡人数大于10人的事故次数& & & & arryLabel.Add(_label8);& & & & arryLabel.Add(_label14);& & & & arryLabel.Add(_label20);& & & & Count(arryLabel, &max&);& & & & _label8 = arryLabel[0];& & & & _label14 = arryLabel[1];& & & & _label20 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label2 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label14) + Convert.ToInt32(_label20));& & & & //计算事故死亡人数在3人到9人之间的事故次数& & & & arryLabel.Add(_label9);& & & & arryLabel.Add(_label15);& & & & arryLabel.Add(_label21);& & & & Count(arryLabel, &middle&);& & & & _label9 = arryLabel[0];& & & & _label15 = arryLabel[1];& & & & _label21 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label3 = Convert.ToString(Convert.ToInt32(_label9) + Convert.ToInt32(_label15) + Convert.ToInt32(_label21));& & & & //计算事故死亡人数小于3人的事故次数& & & & arryLabel.Add(_label10);& & & & arryLabel.Add(_label16);& & & & arryLabel.Add(_label22);& & & & Count(arryLabel, &min&);& & & & _label10 = arryLabel[0];& & & & _label16 = arryLabel[1];& & & & _label22 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label4 = Convert.ToString(Convert.ToInt32(_label10) + Convert.ToInt32(_label16) + Convert.ToInt32(_label22));& & & & //计算事故死亡人数& & & & arryLabel.Add(_label11);& & & & arryLabel.Add(_label17);& & & & arryLabel.Add(_label23);& & & & Count(arryLabel, &deadtotal&);& & & & _label11 = arryLabel[0];& & & & _label17 = arryLabel[1];& & & & _label23 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label5 = Convert.ToString(Convert.ToInt32(_label11) + Convert.ToInt32(_label17) + Convert.ToInt32(_label23));& & & & //计算事故受伤人数& & & & arryLabel.Add(_label12);& & & & arryLabel.Add(_label18);& & & & arryLabel.Add(_label24);& & & & Count(arryLabel, &hurttotal&);& & & & _label12 = arryLabel[0];& & & & _label18 = arryLabel[1];& & & & _label24 = arryLabel[2];& & & & arryLabel.Clear();& & & & _label6 = Convert.ToString(Convert.ToInt32(_label12) + Convert.ToInt32(_label18) + Convert.ToInt32(_label24));& & & & //各行的统计& & & & _label1 = Convert.ToString(Convert.ToInt32(_label2) + Convert.ToInt32(_label3) + Convert.ToInt32(_label4));& & & & _label7 = Convert.ToString(Convert.ToInt32(_label8) + Convert.ToInt32(_label9) + Convert.ToInt32(_label10));& & & & _label13 = Convert.ToString(Convert.ToInt32(_label14) + Convert.ToInt32(_label15) + Convert.ToInt32(_label16));& & & & _label19 = Convert.ToString(Convert.ToInt32(_label20) + Convert.ToInt32(_label21) + Convert.ToInt32(_label22));& & & & Response.AddHeader(&Content-Disposition&, & filename=ConsistencyAppraiseReportExcel.xls&);& & & & Response.Charset = &gb2312&;& & & & Response.ContentType = &application/msexcel&;& & }& & private void Count(List&string& arryLabel, string val)& & {& & & & if (dt1.Rows.Count & 0 && dt1.Rows[0][val].ToString() != &&)& & & & {& & & & & & m = Convert.ToInt32(dt1.Rows[0][val].ToString());& & & & }& & & & if (dt2.Rows.Count & 0 && dt2.Rows[0][val].ToString() != &&)& & & & {& & & & & & n = Convert.ToInt32(dt2.Rows[0][val].ToString());& & & & }& & & & if (dt3.Rows.Count & 0 && dt3.Rows[0][val].ToString() != &&)& & & & {& & & & & & k = Convert.ToInt32(dt3.Rows[0][val].ToString());& & & & }& & & & arryLabel[0] = Convert.ToString(m + n + k);& & & & if (dt4.Rows.Count & 0 && dt4.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[1] = dt4.Rows[0][val].ToString();& & & & }& & & & if (dt5.Rows.Count & 0 && dt5.Rows[0][val].ToString() != &&)& & & & {& & & & & & arryLabel[2] = dt5.Rows[0][val].ToString();& & & & }& & }}??
对“关于SQL外连接的解释”纠错
关注希赛微信
接听时间:工作日00:00-24:00(仅收市话费)
&&|&&关于希赛&&|&&工作机会&&|&&服务协议&&|&&免责声明&&|&&联系希赛&&|&&网站地图&&&&&&&&希赛网&&版权所有&&(C)&&&&&&

我要回帖

更多关于 html文件转化为pdf 的文章

 

随机推荐