KSBM_SQKSXS_QK.aspx (导出excel、导出时数字自动转化成科学计算的处理)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KSBM_SQKSXS_QK.aspx.cs" Inherits="GSAO.KSBM.KSBM_SQKSXS_QK" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>考试报名统计</title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
      <asp:Label ID="lb_function_desc" runat="server" Visible="false" >
    功能说明:统计每个考试的报名情况,显示每个考试报名情况,交费情况!<br/>
    操作表为:KSBM_SQKSXS,KSBM_KSXM.
    </asp:Label>
    <table width="99%" class="tbDefault mb5 mt5">
        <tr>
             <td class="tdRight bgEFEFEF" width="120">考试项目名称:</td>
             <td class="tdLeft">
               <asp:TextBox ID="tb_KSXMMC" runat="server" CssClass="txt mr10"  Width="200"></asp:TextBox>
                &nbsp;&nbsp;
                <asp:Button ID="btn_search" runat="server" Text="查 询" CssClass="btnStyle mr10" 
                     onclick="btn_search_Click" />
               <asp:Button ID="btn_export" runat="server" Text="导 出" CssClass="btnStyle mr10" onclick="btn_export_Click" 
                    />    
               <asp:Label ID="lb_total" runat="server"></asp:Label>
            </td>
        </tr>
      </table>
       <asp:GridView ID="GridView1" runat="server" CssClass="tbGvw" Width="99%"   AllowPaging="true"  
          AutoGenerateColumns="false"     BorderStyle="Solid"  BorderWidth="1" 
           BorderColor="Silver"       PageSize="20" onpageindexchanged="GridView1_PageIndexChanged" 
           onrowdatabound="GridView1_RowDataBound" 
           onpageindexchanging="GridView1_PageIndexChanging">
            <PagerSettings PageButtonCount="20" FirstPageText="[ 首页 ]" LastPageText="[ 末页 ]" 
               Mode="NextPreviousFirstLast" NextPageText="[ 下一页 ]" Position="TopAndBottom" 
               PreviousPageText="[ 上一页 ]"   />
         <PagerTemplate>
            <table width="100%"> <tr> <td style="text-align:left; color:#996600;"><asp:Label id="lblPageIndex" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页 共<asp:Label id="lblPageCount" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageCount %>' />页 <asp:linkbutton id="btnFirst" runat="server" causesvalidation="False" commandargument="First" ForeColor="#996600" Font-Bold="true" commandname="Page" text="首页" /> <asp:linkbutton id="btnPrev" runat="server" causesvalidation="False" ForeColor="#996600" Font-Bold="true"  commandargument="Prev" commandname="Page" text="上一页" /> <asp:linkbutton id="btnNext" runat="server" ForeColor="#996600" Font-Bold="true"  causesvalidation="False" commandargument="Next" commandname="Page" text="下一页" /> <asp:linkbutton id="btnLast" runat="server" ForeColor="#996600" Font-Bold="true"  causesvalidation="False" commandargument="Last" commandname="Page" text="尾页" /></td> </tr> </table>
         </PagerTemplate>
        <HeaderStyle CssClass="tbHeader" />
        <RowStyle HorizontalAlign="Center" Wrap="False" Height="25px" ></RowStyle>
        <Columns>
            <asp:BoundField HeaderText="姓名"  ItemStyle-Width="80px" DataField="XM"/>
            <asp:BoundField HeaderText="性别"  ItemStyle-Width="50px" DataField="XB"/>  
            <asp:BoundField HeaderText="学号"  ItemStyle-Width="60px" DataField="XH"/> 
            <asp:TemplateField HeaderText="证件类型" ItemStyle-Width="100">
                <ItemTemplate>
                    <asp:Label ID="lb_SFZJLX" runat="server" Text="身份证"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField HeaderText="证件号码"  ItemStyle-Width="100px" DataField="SFZJH" /> 
            <asp:BoundField HeaderText="院系"  ItemStyle-Width="120px" DataField="YXSMC"/> 
            <asp:BoundField HeaderText="专业名称"  ItemStyle-Width="120px" DataField="ZY_MC"/>
            <asp:BoundField HeaderText="培养层次"  ItemStyle-Width="120px" DataField="PYCCMC"/> 
            <asp:BoundField HeaderText="年级"  ItemStyle-Width="50px" DataField="NJ"/>
            <asp:BoundField HeaderText="考试项目名称"   ItemStyle-CssClass="tdLeft wordBreak" DataField="KSXMMC"/>
            <asp:BoundField HeaderText="考试日期" DataFormatString="{0:yyyy-MM-dd}"  ItemStyle-Width="100px" DataField="KSRQ"/>
            <asp:BoundField HeaderText="所需费用"  ItemStyle-Width="80px" DataField="SXFY"/>
            <asp:BoundField HeaderText="申请日期" DataFormatString="{0:yyyy-MM-dd}"  ItemStyle-Width="80px" DataField="SQRQ"/>
        </Columns>
        <PagerStyle  Font-Size="10pt"  BorderColor="White" Font-Bold="False" ForeColor="#996600"></PagerStyle> 
      </asp:GridView>
    </form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace GSAO.KSBM
{
    public partial class KSBM_SQKSXS_QK : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind_gv();
            }
        }

        private void Bind_gv()
        {
            string where = "1=1";
            if (tb_KSXMMC.Text != "")
                where += " and KSBM_KSXM.KSXMMC like '%" + tb_KSXMMC.Text + "%'";
            where += " order by KSBM_KSXM.KSRQ desc";
            DAL_GSAO_KSBM.Controller.KSBM_SQKSXS C_KSBM_SQKSXS = new DAL_GSAO_KSBM.Controller.KSBM_SQKSXS();
            DataSet ds = C_KSBM_SQKSXS.GetList_Join_All(where);
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();

            GridView1.Columns[10].Visible = false;
            GridView1.Columns[11].Visible = false;
            GridView1.Columns[12].Visible = false;

            lb_total.Text = "总计-" + ds.Tables[0].Rows.Count.ToString() + "-项";
        }
        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            Bind_gv();
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "if(style.backgroundColor!='#ffffd0'){oldcolor=style.backgroundColor;style.backgroundColor='#c4e4ff';}");
                e.Row.Attributes.Add("onmouseout", "if(style.backgroundColor!='#ffffd0')style.backgroundColor=oldcolor;");
                e.Row.Attributes.Add("onmousedown", "if(style.backgroundColor=='#ffffd0')style.backgroundColor='white';else style.backgroundColor='#ffffd0';");
                //导出时数字自动转化成科学计算的处理
                e.Row.Cells[4].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
            }
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                GridView1.PageIndex = e.NewPageIndex;
            }
            catch
            {
                GridView1.PageIndex = 0;
            }
        }
        protected void btn_search_Click(object sender, EventArgs e)
        {
            Bind_gv();
        }
        public override void VerifyRenderingInServerForm(Control control)
        {
            //base.VerifyRenderingInServerForm(control);
        }


        //导出
        protected void btn_export_Click(object sender, EventArgs e)
        {
            if (GridView1.Rows.Count == 0)
            {
                Common_GSAO.Tools.ShowAlert("数据不能为空!");
                return;
            }
            GridView1.Columns[10].Visible = true;
            GridView1.Columns[11].Visible = true;
            GridView1.Columns[12].Visible = true;
            
            string ExcelFile = "KSBMQK_" + System.DateTime.Now.ToString("yyyyMMddHHmmss");
            string header = @"<table><tr><td colspan=13><center><b><u><font size='3'>汕头大学考试报名情况汇总表</font></u></b></center></td></tr>"
                + "<tr><td colspan=10></td><td>导出时间:</td><td>" + DateTime.Now.ToShortDateString() + "</td></tr></table>";
            string bottomer = "";
            Common_GSAO.Tools.OutputExcel(GridView1, ExcelFile, header, bottomer, lb_total);

            GridView1.Columns[10].Visible = false;
            GridView1.Columns[11].Visible = false;
            GridView1.Columns[12].Visible = false;
        }
    }
}

 

转载于:https://www.cnblogs.com/linyongqin/articles/3778186.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在研招网进行成绩查询可以使用Python编写一个简单的程序来实现。 首先,我们需要使用`requests`库来发送网络请求并获取网页内容。然后,使用`beautifulsoup`库来解析网页内容,以便提取所需的成绩信息。接下来,我们可以使用正则表达式或CSS选择器来定位和提取特定的成绩数据。最后,将成绩信息以适当的格式输出给用户。 以下是一个简单的代码示例: ``` import requests from bs4 import BeautifulSoup def get_scores(username, password): # 构造请求URL和表单数据 login_url = 'http://www.yanzhaowang.com.cn/LoginWeb.jsp' scores_url = 'http://www.yanzhaowang.com.cn/ksbm/cjcx.jsp' data = {'username': username, 'password': password} # 发送登录请求 session = requests.session() session.post(login_url, data=data) # 发送成绩查询请求 scores_response = session.get(scores_url) # 解析网页内容 soup = BeautifulSoup(scores_response.text, 'html.parser') # 使用CSS选择器定位成绩信息 scores = soup.select('#mainTable tr td') # 提取成绩信息并输出给用户 for score in scores: print(score.text) # 调用函数进行成绩查询 username = input('请输入用户名:') password = input('请输入密码:') get_scores(username, password) ``` 以上代码是一个简单的示例,实际应用中可能需要根据具体情况进行相应的修改和优化。例如,可以增加错误处理、结果存储和界面优化等功能,以提高程序的稳定性和用户友好性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值