當前位置:首頁 » 操作系統 » aspexcel導入源碼

aspexcel導入源碼

發布時間: 2023-02-01 02:08:42

㈠ 求通過asp把excel表格上傳至伺服器,然後導入到access資料庫中的源碼程序

上傳?應該就是個復制的過程吧。。
這種源碼網上肯定有的,就是難找。。

㈡ ASP.NET 自定義數據導入excel,求源碼方法

USE [Report]
GO

/****** Object: Table [dbo].[BookInfo] Script Date: 11/29/2011 20:52:04 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BookInfo]') AND type in (N'U'))
DROP TABLE [dbo].[BookInfo]
GO

USE [Report]
GO

/****** Object: Table [dbo].[BookInfo] Script Date: 11/29/2011 20:52:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BookInfo](
[名字] [varchar](50) NULL,
[編號] [varchar](50) NULL,
[手機號碼] [varchar](50) NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

2個步驟

--開啟導入exec程序
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

--改你所要execl的地址 Sheet2$ 看你的數據在哪裡
insert into BookInfo
SELECT * FROM OPENROWSET(
'Microsoft.Jet.OLEDB.4.0', 'EXCEL 5.0;HDR=YES;IMEX=2;DATABASE=E:\BookInfo
.xls'
,'SELECT * FROM [Sheet2$]')

--關閉導入exec程序
--使用完成後,關閉Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

㈢ asp網頁中如何導入excel

兩種方法
1.拿execl當做資料庫來讀取
2.可以把excel另存為網頁文件,就可以當做文本文件處理了,裡面代碼可以找到處理規律。

附上處理excel文檔的asp代碼(就是第一條的方法)
set conn2=CreateObject("ADODB.Connection")
conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended properties=Excel 5.0;Data Source="&file_path&""
sql="select*FROM [student$]"
set rs=conn2.execute(sql)
do while not rs.eof
sql="insert into student([student_name],[student_nick],[student_password])values('"&fixsql(rs(0))&"','"&fixsql(rs(3))&"','"&fixsql(rs(8))&"')"
conn.execute(sql)
rs.movenext
loop
conn2.close

㈣ 如何將excel數據通過asp導入資料庫

將excel數據通過asp導入資料庫:
參考代碼:
wenjian=request.Form("floor")
fileext=mid(wenjian,InStrRev(wenjian,".")+1)
if lcase(fileext)<>"xls" then
response.write "<script>alert ('文件格式不對,請上傳Excel文件');window.location.href='updateFloor.asp';</script>"
response.end
end if
set conne=server.CreateObject("ADODB.Connection")
connStre="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath( ""&wenjian&"" )&";Extended Properties='Excel 8.0;HDR=YES;IMEX=1';"
conne.open connStre
Sqle="select * from [sheet1$] "
Set rse = Server.CreateObject("ADODB.Recordset")
rse.open sqle,conne,1,1
'驗證
hang=2
do while not rse.eof
'名稱不能為空
if trim(rse(0))<>"" then
else
mess="第"& hang &"行名稱為空,請檢查!"
response.Write"<script>alert('"& mess &"').window.location.href='updateFloor.asp'</script>"
response.End()
end if
rse.movenext
hang=hang+1
loop
rse.movefirst
do while not rse.eof
set rst=server.CreateObject("adodb.recordset")
sqlt="select * from Sellman"
rst.open sqlt,conn,1,3
rst.addnew()
rst("CompanyName")=c2(rse(0))
rst("CompanyInfo")=c2(rse(1))
rst("address")=c2(rse(2))
rst("tel")=c2(rse(3))&" "&c2(rse(7))
rst("Fax")=c2(rse(4))
rst("linkman")=c2(rse(5))
rst("Homepage")=c2(rse(8))
rst("Email")=c2(rse(6))
rst.update()
rst.close
set rst=nothing
rse.movenext
loop
rse.close
set rse=nothing
response.Write "<script>alert('導入成功!');location.href='updateFloor.asp';</script>"

㈤ asp如何導入excel內容

DataSet _Table = GetTableName(Server.MapPath(@"upload/" + Request.Cookies["sa"].Value + "/" + this.ListBox1.SelectedValue), this.DropDownList1.SelectedValue); //首先獲取EXCEL文件路徑
string[] list = Request["checkbox"].Split(",".ToCharArray()); 要導入的列,代碼不貼了
string CompanyName = string.Empty, Person_in_charge = string.Empty, Mobile = string.Empty, Phone = string.Empty, Fax = string.Empty, E_mail = string.Empty, Address = string.Empty, IMQQ = string.Empty, AliWW = string.Empty, Website = string.Empty;
if (_Table.Tables[0].Rows.Count > 0)
{
for (int i = 0; i != _Table.Tables[0].Rows.Count; i++)/
{
for (int j = 0; j < list.Length; j++)/判斷每個列的數據,然後處理
{
string[] arr = list[j].ToString().Split("|".ToCharArray());
if (Request[list[j].ToString()] == "CompanyName")
{
CompanyName = CompanyName + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Person_in_charge")
{
Person_in_charge = Person_in_charge + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Mobile")
{
Mobile = Mobile + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Phone")
{
Phone = Phone + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Fax")
{
Fax = Fax + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "E-mail")
{
E_mail = E_mail + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Address")
{
Address = Address + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "IMQQ")
{
IMQQ = IMQQ + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "AliWW")
{
AliWW = AliWW + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
if (Request[list[j].ToString()] == "Website")
{
Website = Website + _Table.Tables[0].Rows[i][arr[1].ToString()].ToString();
}
}
db.Update_Sql("INSERT INTO Customers([sid],[s_dep],[CompanyName],[Person_in_charge],[Mobile],[Phone],[Fax],[E-mail],[Address],[IMQQ],[AliWW],[Website],[Instry])VALUES('" + Request.Cookies["sa"].Value + "'," + Request.Cookies["dep"].Value + ",'" + CompanyName + "','" + Person_in_charge + "','" + Mobile + "','" + Phone + "','" + Fax + "','" + E_mail + "','" + Address + "','" + IMQQ + "','" + AliWW + "','" + Website + "'," + this.DropDownList2.SelectedValue + ")");
CompanyName = ""; Person_in_charge = ""; Mobile = ""; Phone = ""; Fax = ""; E_mail = ""; Address = ""; IMQQ = ""; AliWW = "";
this.Label3.Text = "導入成功!";

㈥ 支持EXCEL導入的ASP源碼

假設你的EXCEL都已經是標准格式的文件了,那麼你可以使用以下代碼進行操作:
變數定義及ADO對象創建
....
strConn
=
"Provider=Microsoft.Jet.OLEDB.4.0;"
&
_
"Data
Source="
&
strExcelFile
&
_
";Extended
Properties=Excel
8.0"
strToDBConn
=
"odbc;Driver={SQL
Server};Server=IP地址;Database=資料庫名;UID=登錄用戶;PWD=密碼"
'//
以記錄集的形式打開
Excel
文件
adoConn.Open
strConn
'//
將數據插入到指定的表中
strSQL
=
"INSERT
INTO
["
&
strToDBConn
&
"].SQL資料庫中的表名
SELECT
EXCEL中的欄位名(第一行)
FROM
EXECL工作表名"
adoConn.Execute
strSQL,
,
adExecuteNoRecords
'//
這里有可能會產生一個錯誤,「系統不支持所選擇的排序。(-2147467259)」
'//
但實際上已經有執行成功了,所以忽略此錯誤
If
Err.Number
=
-2147467259
Then
Err.Clear
End
If

㈦ asp中把excel中數據導入SQL資料庫

private void add()
{
OleDbConnection connread = new OleDbConnection("provider=microsoft.jet.oledb.4.0; data source=D:\\Book1.xls; extended properties=excel 8.0");
connread.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", connread);
DataSet ds = new DataSet();
da.Fill(ds);
connread.Close();
SqlConnection conn = new SqlConnection("server=.; integrated security=true; database=demo");
conn.Open();
SqlCommand cmd = new SqlCommand("create table name(name varchar(100),namea varchar(100),nameb varchar(100))", conn);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string p=string.Format("insert into name values('{0}','{1}','{2}')",ds.Tables[0].Rows[i]["name"].ToString().Trim(),ds.Tables[0].Rows[i]["namea"].ToString().Trim(),ds.Tables[0].Rows[i]["nameb"].ToString().Trim());
cmd = new System.Data.SqlClient.SqlCommand(p, conn);
cmd.ExecuteNonQuery();
}
conn.Close();
}

熱點內容
win7網頁視頻緩存 發布:2023-04-02 11:30:41 瀏覽:715
自己開發vba編譯器 發布:2023-04-02 11:18:13 瀏覽:261
如何清理linux緩存 發布:2023-04-02 11:13:38 瀏覽:802
抖音怎麼上傳照片 發布:2023-04-02 11:11:32 瀏覽:624
有限的訪問許可權解決 發布:2023-04-02 11:04:36 瀏覽:637
sql中怎麼用 發布:2023-04-02 11:04:27 瀏覽:983
m3辦公軟體如何查看伺服器地址 發布:2023-04-02 11:04:22 瀏覽:118
430編程 發布:2023-04-02 11:01:24 瀏覽:545
伺服器保密地址 發布:2023-04-02 11:01:10 瀏覽:475
c語言與directx 發布:2023-04-02 11:01:10 瀏覽:52