濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > ASP.NET利用MD.DLL轉(zhuǎn)EXCEL具體實(shí)現(xiàn)

ASP.NET利用MD.DLL轉(zhuǎn)EXCEL具體實(shí)現(xiàn)

熱門標(biāo)簽:電銷語(yǔ)音自動(dòng)機(jī)器人 萊蕪?fù)夂綦婁N機(jī)器人價(jià)格 五常地圖標(biāo)注 地圖標(biāo)注和認(rèn)領(lǐng) 長(zhǎng)春呼叫中心外呼系統(tǒng)哪家好 智能電話營(yíng)銷外呼系統(tǒng) 鄭州400電話辦理 聯(lián)通 戶外地圖標(biāo)注軟件手機(jī)哪個(gè)好用 凱立德導(dǎo)航官網(wǎng)地圖標(biāo)注
前提
引入MD.dll 文件;
下載地址:https://www.jb51.net/dll/MD.dll.html
1、建立無(wú)CS文件的DownExcel.aspx 文件
復(fù)制代碼 代碼如下:

%@ 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("條件不符,查詢沒(méi)有任何資料!");
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、調(diào)用方法
http://localhost:13042/report/downexcel.aspx?procedure=P_PP_SPC_FindCountstrWorkCenterNum=0strStatus=全部strPartno=
注解
P_PP_SPC_FindCoun:存儲(chǔ)過(guò)程
WorkcenterNum:參數(shù)
在每個(gè)參數(shù)前都要加上‘Str'表示該參數(shù)是字符串型
所以參數(shù)要寫成StrWorkcenterNum
您可能感興趣的文章:
  • ASP.NET實(shí)現(xiàn)讀取Excel內(nèi)容并在Web上顯示
  • ASP.NET中上傳并讀取Excel文件數(shù)據(jù)示例
  • asp.net導(dǎo)出excel的簡(jiǎn)單方法實(shí)例
  • asp.net讀取excel文件的三種方法示例
  • asp.net導(dǎo)出Excel亂碼的原因及解決方法
  • asp.net讀取excel中的數(shù)據(jù)并綁定在gridview
  • asp.net使用npoi讀取excel模板并導(dǎo)出下載詳解
  • asp.net導(dǎo)出Excel類庫(kù)代碼分享
  • Asp.Net用OWC操作Excel的實(shí)例代碼
  • Asp.net中DataTable導(dǎo)出到Excel的方法介紹
  • ASP.NET(C#)讀取Excel的文件內(nèi)容
  • Asp.Net使用Npoi導(dǎo)入導(dǎo)出Excel的方法

標(biāo)簽:衢州 福州 岳陽(yáng) 宣城 湖州 西藏 紅河 西寧

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET利用MD.DLL轉(zhuǎn)EXCEL具體實(shí)現(xiàn)》,本文關(guān)鍵詞  ASP.NET,利用,MD.DLL,轉(zhuǎn),EXCEL,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET利用MD.DLL轉(zhuǎn)EXCEL具體實(shí)現(xiàn)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于ASP.NET利用MD.DLL轉(zhuǎn)EXCEL具體實(shí)現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    钟山县| 永泰县| 明溪县| 剑阁县| 奉节县| 嘉黎县| 阳东县| 鹤峰县| 泰和县| 望江县| 乌拉特后旗| 黑龙江省| 浮山县| 丹棱县| 南京市| 大姚县| 合肥市| 兴业县| 格尔木市| 沅江市| 元阳县| 安国市| 英山县| 云龙县| 神木县| 黄龙县| 天峻县| 贵南县| 山西省| 扬中市| 兴隆县| 大同市| 阜新| 冕宁县| 马鞍山市| 奉化市| 辽阳县| 景洪市| 温宿县| 阿巴嘎旗| 柳州市|