婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > ASP.NET利用MD.DLL轉EXCEL具體實現

ASP.NET利用MD.DLL轉EXCEL具體實現

熱門標簽:電銷語音自動機器人 萊蕪外呼電銷機器人價格 五常地圖標注 地圖標注和認領 長春呼叫中心外呼系統哪家好 智能電話營銷外呼系統 鄭州400電話辦理 聯通 戶外地圖標注軟件手機哪個好用 凱立德導航官網地圖標注
前提
引入MD.dll 文件;
下載地址:https://www.jb51.net/dll/MD.dll.html
1、建立無CS文件的DownExcel.aspx 文件
復制代碼 代碼如下:

%@ Page Language="C#" %>
%@ import Namespace="System.Data" %>
%@ import Namespace="System.Data.SqlClient" %>
%@ import Namespace="MD" %>
script runat="server">
string tableName = "";
string procName ="";
private string selectSql( string selstr )
{
string sp =selstr + " WHERE";
int iwhere;
iwhere=sp.IndexOf("WHERE");
iwhere=iwhere+7;
string sall = Server.UrlDecode(Request.QueryString.ToString());
string[] sparams;
sparams=sall.Split('');
int i=0;
if (sparams.Length>1){
while (isparams.Length){
if (!(sparams[i].StartsWith("table"))){
if ((sparams[i].StartsWith("str") )){
sp=sp+" and " + sparams[i].Replace("=","='").Substring(3) + "'";
}
if ((sparams[i].StartsWith("num") ))
{
sp=sp+" and " + sparams[i].Substring(3) + "";
}
}
i++;
}
}
if (sp.IndexOf("and") >0 ){
sp = (sp.Substring(0,sp.IndexOf("and")) + sp.Substring(sp.IndexOf("and")+3));
}
//sp=sp.Replace("=","='");
if (sp.Lengthiwhere) {
sp=sp.Substring(0,(iwhere-8));
}
return sp;
}
private string selectProc( string selstr )
{
string sp =selstr + " ";
string sall = Server.UrlDecode(Request.QueryString.ToString());
//Server.UrlDecode(Request.QueryString.ToString());
string[] sparams;
sparams=sall.Split('');
int i=0;
if (sparams.Length>1)
{
while (isparams.Length)
{
if (!(sparams[i].StartsWith("procedure")))
{
if ((sparams[i].StartsWith("str") ))
{
sp=sp + "'" + sparams[i].Substring( sparams[i].IndexOf("=")+1) + "',";
}
if ((sparams[i].StartsWith("num") ))
{
sp=sp + sparams[i].Substring( sparams[i].IndexOf("=")+1) + ",";
}
}
i++;
}
}
if (sp.EndsWith(",")){
sp=sp.Substring(0, (sp.Length -1));
}
return sp;
}
private void Page_Load(object sender, System.EventArgs e)
{
// setup connection
//Response.Write(selectSql("start test!"));
string conn = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; /// System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
if (Request.QueryString["table"]== null Request.QueryString["procedure"]==null)
{
this.Response.Write("not supply correct parameters!");
this.Response.End();
return;
}
DataSet ds = new DataSet();
ds.Locale = new System.Globalization.CultureInfo("zh-CN");
//OleDbDataAdapter adapter=new OleDbDataAdapter();
if (!(Request.QueryString["table"]== null ) )
{
/*string test1=selectSql(("SELECT * from " + Request.QueryString["table"]));
this.Response.Write(test1);
this.Response.End();
return;*/
tableName=Request.QueryString["table"];
MD.SqlHelper.FillDataset(conn,System.Data.CommandType.Text ,selectSql(("SELECT * from " + tableName)),ds,new string[] {"down"});
}
if (!(Request.QueryString["procedure"]== null ) )
{
/*string test2=selectProc(("exec " + Request.QueryString["procedure"]));
this.Response.Write(test2);
this.Response.End();
return;*/
procName=Request.QueryString["procedure"];
MD.SqlHelper.FillDataset(conn,System.Data.CommandType.Text ,selectProc(("exec " + procName)),ds,new string[] {"down"});
}
if (ds.Tables[0].Rows.Count==0){
this.Response.Write("條件不符,查詢沒有任何資料!");
return;
}
string downRes="";
if (procName=="")
{
downRes=tableName;
}
else
{
downRes=procName;
}
//OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * from " + tableName, conn);
//Response.Write(selectSql("SELECT * from " + tableName));
//return;
// open the Database and get the results
this.DataGridDown.DataSource=ds;
this.DataGridDown.DataBind();
this.Response.Clear();
this.Response.Buffer =true;
this.Response.Charset="utf-8";
this.Response.ContentType="application/ms-excel";
this.Response.AppendHeader("content-Disposition","attachment;filename="+downRes+".xls");
this.Response.ContentEncoding =System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentEncoding = System.Text.Encoding.utf-8;
this.EnableViewState =false;
System.IO.StringWriter OStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter OHtmlTextWriter = new System.Web.UI.HtmlTextWriter(OStringWriter);
this.DataGridDown.RenderControl(OHtmlTextWriter);
this.Response.Write(OStringWriter.ToString());
this.Response.End();
// if the action is update, well, we update our DB
}
/script>
html>
head>
meta http-equiv="content-type" content="application/x-excel; charset=UTF-8"/>
!-- meta http-equiv="Content-Type" content="application/x-msexcel; charset=iso-8859-1" /> -->
/head>
body>
form runat="server">
asp:DataGrid id="DataGridDown" style="Z-INDEX: 100; POSITION: absolute" runat="server" Height="373px" Width="674px" >
/asp:DataGrid>
!-- Insert content here -->
/form>
/body>
/html>

2、調用方法
http://localhost:13042/report/downexcel.aspx?procedure=P_PP_SPC_FindCountstrWorkCenterNum=0strStatus=全部strPartno=
注解
P_PP_SPC_FindCoun:存儲過程
WorkcenterNum:參數
在每個參數前都要加上‘Str'表示該參數是字符串型
所以參數要寫成StrWorkcenterNum
您可能感興趣的文章:
  • ASP.NET實現讀取Excel內容并在Web上顯示
  • ASP.NET中上傳并讀取Excel文件數據示例
  • asp.net導出excel的簡單方法實例
  • asp.net讀取excel文件的三種方法示例
  • asp.net導出Excel亂碼的原因及解決方法
  • asp.net讀取excel中的數據并綁定在gridview
  • asp.net使用npoi讀取excel模板并導出下載詳解
  • asp.net導出Excel類庫代碼分享
  • Asp.Net用OWC操作Excel的實例代碼
  • Asp.net中DataTable導出到Excel的方法介紹
  • ASP.NET(C#)讀取Excel的文件內容
  • Asp.Net使用Npoi導入導出Excel的方法

標簽:衢州 福州 岳陽 宣城 湖州 西藏 紅河 西寧

巨人網絡通訊聲明:本文標題《ASP.NET利用MD.DLL轉EXCEL具體實現》,本文關鍵詞  ASP.NET,利用,MD.DLL,轉,EXCEL,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ASP.NET利用MD.DLL轉EXCEL具體實現》相關的同類信息!
  • 本頁收集關于ASP.NET利用MD.DLL轉EXCEL具體實現的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 宣武区| 青田县| 宁陵县| 焦作市| 两当县| 壶关县| 刚察县| 湘潭市| 湘阴县| 沂水县| 额尔古纳市| 永城市| 嵩明县| 达日县| 庐江县| 玉田县| 萝北县| 班戈县| 贺兰县| 夏津县| 宁波市| 东莞市| 白玉县| 蓬莱市| 友谊县| 河西区| 曲麻莱县| 繁峙县| 杨浦区| 开原市| 天柱县| 北海市| 临夏市| 西充县| 宜兰市| 大同市| 松滋市| 阳春市| 合山市| 丰原市| 嘉禾县|