Asp.net ''将office office2013 excel下拉表格导入到sql sever

查看: 2535|回复: 10
怎样用VBA将数据导入到SQL数据库
阅读权限10
在线时间 小时
求解怎样用VBA将EXCEl的数据导入到SQL数据库
阅读权限30
在线时间 小时
本帖最后由 lin_x 于
16:34 编辑
要写代码的,而且如果数据库是在你们内部的服务器上,别人由于不能连你们内部的sql server 服务器,也帮不上忙,还是找个兼职帮你们弄吧,
或者,你服务器上应该有个叫studio mangement 的东东,用它也可以把excel 的数据导入sql server 数据库
阅读权限10
在线时间 小时
lin_x 发表于
要写代码的,而且如果数据库是在你们内部的服务器上,别人由于不能连你们内部的sql server 服务器,也帮不上 ...
恩,我知道要写代码,就是想知道怎么写的
阅读权限95
在线时间 小时
给个代码的例子:
& & Dim cnn As ADODB.Connection
& & Dim rs As ADODB.Recordset
& & Dim i As Long
& & Dim mydata As String, myTable As String, SQL As String
& & Dim wb As Workbook
& & Dim ws As Worksheet
& & Set wb = ThisWorkbook
& & Set ws = wb.Sheets(&sheet1&)
& & mydata = &工资管理&
& & myTable = &基本信息&
& & Set cnn = New ADODB.Connection
& & With cnn
& && &&&.ConnectionString = &Provider=SQLOLEDB.1;& _
& && && && && &User ID=& _
& && && && && &Data Source=THTFCOMPUTER;& _
& && && && && &Initial Catalog=& & mydata
& && &&&.Open
& & End With
& & n = ws.Range(&A65536&).End(xlUp).Row
& & For i = 2 To n
& && &&&SQL = &select * from & & myTable _
& && &&&& & where 职工编号='& & Trim(ws.Cells(i, 1).Value) & &'& _
& && &&&& & and 姓名='& & Trim(ws.Cells(i, 2).Value) & &'& _
& && &&&& & and 性别='& & Trim(ws.Cells(i, 3).Value) & &'& _
& && &&&& & and 所属部门='& & Trim(ws.Cells(i, 4).Value) & &'& _
& && &&&& & and 工资总额=& & Trim(ws.Cells(i, 5).Value) _
& && &&&& & and 备注='& & Trim(ws.Cells(i, 6).Value) & &'&
& && &&&Set rs = New ADODB.Recordset
& && &&&rs.Open SQL, cnn, adOpenKeyset, adLockOptimistic
& && &&&If rs.EOF And rs.BOF Then
& && && && &rs.AddNew
& && && && &For j = 1 To rs.Fields.Count
& && && && && & rs.Fields(j - 1) = Trim(ws.Cells(i, j).Value)
& && && && &Next j
& && && && &rs.Update
& && &&&Else
& && && && &For j = 1 To rs.Fields.Count
& && && && && & rs.Fields(j - 1) = Trim(ws.Cells(i, j).Value)
& && && && &Next j
& && && && &rs.Update
& && &&&End If
& & Next i
& & MsgBox &数据保存完毕!&, vbInformation, &保存数据&
& & rs.Close
& & cnn.Close
& & Set wb = Nothing
& & Set ws = Nothing
& & Set rs = Nothing
& & Set cnn = Nothing
阅读权限10
在线时间 小时
zez 发表于
给个代码的例子:
& & Dim cnn As ADODB.Connection
& & Dim rs As ADODB.Recordset
不能完全看懂,还要再研究下,多谢
阅读权限30
在线时间 小时
& & & & & & & &
lz不是学编程的吧,如果工作上要用,还是建议找人做,毕竟不是自己的专业,会有点力不从心的,呵呵,一点小小的建议。
阅读权限10
在线时间 小时
lin_x 发表于
lz不是学编程的吧,如果工作上要用,还是建议找人做,毕竟不是自己的专业,会有点力不从心的,呵呵,一点小 ...
恩,不是学编程的,有一点C语言基础,刚毕业没多久,想多学点东西的
阅读权限20
在线时间 小时
留下收藏,正在学习中…………
阅读权限20
在线时间 小时
顺带学习了下,不错
阅读权限10
在线时间 小时
以实现先删除表中原有数据,已WID作为关键字,随后再插入数据。
下来要实现的就是可以在对话框中输入关键字,而不是要在代码中直接填写。因为每隔一段时间就要使用新的关键字了。还有就是数据库的用户名和密码也是要更换的。Sub qqqQQQ1()
& & Dim conn As New ADODB.Connection
& & Dim conn2
& & Dim rs As New ADODB.Recordset
& & Dim i%, strTemp$, RowNum%, K%
& & Dim wkSheet As Worksheet
& & If MsgBox(&确认要导入数据吗?&, vbYesNo) = 7 Then Exit Sub
& & '建立与SQL的连接
& &conn.Open &Driver={SQL Server};server=.;uid=pwd=database=mainlogsql_&
& & Set wkSheet = Worksheets(&sheet2&)
& & '删除表中原有数据,已成功
& & strTemp = &DELETE FROM JP_JXSJB WHERE WID='H38'&
& & conn.Execute strTemp
& & RowNum = Range(&c65536&).End(xlUp).Row
& & On Error GoTo 9
& & conn.BeginTrans
& && &&&K = 0
& && &&&For i = 2 To RowNum
& && && && &If wkSheet.Cells(i, 1).Value && 0 Then
& && && && && & '拼写INSERT语句的SQL语句
& && && && && & strTemp = &insert into JP_JXSJB(WID,SKNO,RID,DATE,TIME,ACTC,JXLX,XH,DEPTH,XDD,XDF,FWD,FWF,VDEPTH,X,Y,ZWY,ZFW,QJBHL,CLSJ,BZ) &
& && && && && & strTemp = strTemp & & values( '& & wkSheet.Cells(i, 1).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 2).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 3).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 4).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 5).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 6).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 7).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 8).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 9).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 10).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 11).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 12).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 13).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 14).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 15).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 16).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 17).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 18).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 19).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 20).Value & &'&&,&&'& & _
& && && && && && && && && && && && && && && && && & wkSheet.Cells(i, 21).Value & &')&
& && && && && & '执行INSERT语句
& && && && && & conn.Execute strTemp
& && && && && & K = K + 1
& && && && &End If
& && &&&Next
& & mitTrans '结束插入操作的事务
& & ThisWorkbook.Save
& & '显示已经插入的记录条数
& & conn.Close '关闭链接
& & Set rs = Nothing '释放内存
& & Set conn = Nothing '释放内存
& &
& & Set wkSheet = Nothing
& & Application.ScreenUpdating = True
& &
& & MsgBox &导入完毕!& & Chr(10) & Chr(10) & &已经插入的条数:& & K
& & Exit Sub
9:
& & 'Conn.RollbackTrans
& & MsgBox Err.Description & &第& & i & &行 导入出错&
End Sub复制代码还是要谢谢各位的帮忙啊。对excel的控件还不是很熟悉,继续钻研中。因为不是学编程的,只能看懂,所以都是在前人的基础上直接修改代码。呵呵。希望大家不要吐槽
玩命加载中,请稍候
玩命加载中,请稍候
本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!
本站特聘法律顾问:徐怀玉律师 李志群律师
Powered byASP.NET中如何讲Excel表格中的数据导入到SQLServer中去?_百度知道
ASP.NET中如何讲Excel表格中的数据导入到SQLServer中去?
数据库是2000的。 希望大侠们能给出具体的代码。 谢谢
提问者采纳
logwrite.FileN 读取xls文件
&#47!&#39.Tables[0];;&quot!= & + msg + &);/&script&
if (dtXscript&;
return.PostedF
if (extendedName!=null)
string filePath = this.Write(&quot,extendedName);HDR=Y&请选择一个Excel文件;
string strExcel = &)
strConn = & &lt.0.ToString() == &quot.Open();Data Source=&);
myC= 0 || dtX
return null.Rows[0][0];
if (dtXls.Open();;/;;IMEX=1'Provider=MSelect
[&&/);/&请你确认上传的Excel中有资料.OLEDB;/ + tableName + &&#47.FileName), &
OleDbDataAdapter myCommand =&lt不管你是那个数据库.PostedF&UnExistMobile_Mag.DataTable dt = &资料上传成功;script&Provider=M手机号码&
if (this.ToString();).Trim().FileName, con);;&
strConn = &quot.ToLower() , strConn););alert('&lt.0!&quot.ToLower() == &quot.ACE.LogOpera(
DataSet ds =
string extendedName = fileT&#47.OLEDB;&
protected DataTable ExcelToDataTable(string fileN];&请确定Excel资料的格式为[手机号码][状态];&&#47.E
myCommand = new OleDbDataAdapter(strE || dtXfileName&请确定Excel资料的格式为[手机号码][状态].ToLower() ;&lt.Write(&quot.Extension.PostedFile,&quot!= &quot, &alert('/); && extendedNscript&/alert('Extended Properties='状态&returns&gt!= &quot.Close();;
OleDbConnection conn = new OleDbConnection(strConn);Data Source=&]&alert('&quot.4;summary&)
Response!'
dtXls = ExcelToDataTable(filePath.D-'&script&gt.xlsx&quot.Dispose().Write(&
S&条成功;script&/
FileInfo fileTag = new FileInfo(fudA&#47.Trim();
string msg = &&&//.ToLower() == &quot!&#39.ToString();
if (extendedN& + resultData[0] + &
if (dtXls==null||dtX&quot!共计&).Count &lt.ToString()).Columns[1].D记录log
BindData();)
Rscript& + resultData[1] + &quot!= &/
string tableName = schemaT'
}&#47.AppSettings[&script&#region ExcelToDataTable
/;), tableName);UnExistMobile_Mag, &/script&gt.Columns[0].Tables,然后将数据一行一行添加到数据库的表里.ToString() ;)
Response.xlsx&/
return.FileName, string extendedName)
string strConn = string.OleDbSchemaGuid.12;);&#47.xls&quot.GetOleDbSchemaTable(S&&lt.Columns[0]; &lt.Fill(ds.Data.PostedFile.Split('Excel 12;&quot.ToString();&quot.DataTable schemaTable =;
string[] resultData = result.Write(&
S&lt.aspx.fudA);Extended Properties=').OleDb!'/
strExcel = &quot。SqlConnection con = new SqlConnection(ConfigurationM/.cs&成功上传一批空号& + fileName + &/&#47.fudAreturns&
&#47!= &quot.JHDR=YES' &lt.Rows[0][2].0;param name=&/ &&summary&param& + fileName + &quot, null);
if (extendedN
}alert(&#39,将Excel里面的数据导入到数据库中的原理就是将Excel里面的数据存储到一个dataTable中.R
string result = AddXlsData(dtX条失败.fudA;数据库连接字符串
DataTable dtXls = new DataTable();)
Response.ToString() .0.Close();aa&quot.ToString() == &quot.xls&/
ds = new DataSet();.Trim() .Write(&quot.aspx&quot
AddXlsData
是什么? 我是个新手。 嘿嘿...
o,那是一个方法AddXlsData(dtXls, con);参数是dtXls(转换的dataTable),con(数据库连接字符串)
提问者评价
其他类似问题
为您推荐:
excel表格的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁已经把excel文件上传到服务器,怎么将excel中的数据导入到SQL数据库呢?用asp.net和c#
[问题点数:40分]
已经把excel文件上传到服务器,怎么将excel中的数据导入到SQL数据库呢?用asp.net和c#
[问题点数:40分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2011年9月 总版技术专家分月排行榜第一2011年8月 总版技术专家分月排行榜第一2011年7月 总版技术专家分月排行榜第一2011年6月 总版技术专家分月排行榜第一2011年5月 总版技术专家分月排行榜第一2011年4月 总版技术专家分月排行榜第一
2011年3月 总版技术专家分月排行榜第二2011年2月 总版技术专家分月排行榜第二
本帖子已过去太久远了,不再提供回复功能。& & & & 复制代码代码如下:& & & & & & & & 选择文件& & & & & & & & && & & & & & 选择文件(excel)& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & <%& & dim upfile_5xSoft_Stream& & Class upload_5xSoft& & dim Form,File,Version& & Private Sub Class_Initialize& & dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile& & dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr& & Version="任翔专用上传程序"& & if Request.TotalBytes<1 then Exit Sub& & set Form=CreateObject("Scripting.Dictionary")& & set File=CreateObject("Scripting.Dictionary")& & set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")& & upfile_5xSoft_Stream.mode=3& & upfile_5xSoft_Stream.type=1& & upfile_5xSoft_Stream.open& & upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)& & vbEnter=Chr(13)&Chr(10)& & iDivLen=inString(1,vbEnter)+1& & strDiv=subString(1,iDivLen)& & iFormStart=iDivLen& & iFormEnd=inString(iformStart,strDiv)-1& & while iFormStart < iFormEnd& & iStart=inString(iFormStart,"name=""")& & iEnd=inString(iStart+6,"""")& & mFormName=subString(iStart+6,iEnd-iStart-6)& & iFileNameStart=inString(iEnd+1,"filename=""")& & if iFileNameStart>0 and iFileNameStart<iFormEnd then& & iFileNameEnd=inString(iFileNameStart+10,"""")& & mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)& & iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)& & iEnd=inString(iStart+4,vbEnter&strDiv)& & if iEnd>iStart then& & mFileSize=iEnd-iStart-4& & else& & mFileSize=0& & end if& & set theFile=new FileInfo& & theFile.FileName=getFileName(mFileName)& & theFile.FilePath=getFilePath(mFileName)& & theFile.FileSize=mFileSize& & theFile.FileStart=iStart+4& & theFile.FormName=FormName& & file.add mFormName,theFile& & else& & iStart=inString(iEnd+1,vbEnter&vbEnter)& & iEnd=inString(iStart+4,vbEnter&strDiv)& & if iEnd>iStart then& & mFormValue=subString(iStart+4,iEnd-iStart-4)& & else& & mFormValue=""& & end if& & form.Add mFormName,mFormValue& & end if& & iFormStart=iformEnd+iDivLen& & iFormEnd=inString(iformStart,strDiv)-1& & wend& & End Sub& & Private Function subString(theStart,theLen)& & dim i,c,stemp& & upfile_5xSoft_Stream.Position=theStart-1& & stemp=""& & for i=1 to theLen& & if upfile_5xSoft_Stream.EOS then Exit for& & c=ascB(upfile_5xSoft_Stream.Read(1))& & If c > 127 Then& & if upfile_5xSoft_Stream.EOS then Exit for& & stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))& & i=i+1& & else& & stemp=stemp&Chr(c)& & End If& & Next& & subString=stemp& & End function& & Private Function inString(theStart,varStr)& & dim i,j,bt,theLen,str& & InString=0& & Str=toByte(varStr)& & theLen=LenB(Str)& & for i=theStart to upfile_5xSoft_Stream.Size-theLen& & if i>upfile_5xSoft_Stream.size then exit Function& & upfile_5xSoft_Stream.Position=i-1& & if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then& & InString=i& & for j=2 to theLen& & if upfile_5xSoft_Stream.EOS then& & inString=0& & Exit for& & end if& & if AscB(upfile_5xSoft_Stream.Read(1))AscB(MidB(Str,j,1)) then& & InString=0& & Exit For& & end if& & next& & if InString0 then Exit Function& & end if& & next& & End Function& & Private Sub Class_Terminate& & form.RemoveAll& & file.RemoveAll& & set form=nothing& & set file=nothing& & upfile_5xSoft_Stream.close& & set upfile_5xSoft_Stream=nothing& & End Sub& & Private function GetFilePath(FullPath)& & If FullPath
"" Then& & GetFilePath = left(FullPath,InStrRev(FullPath, "\"))& & Else& & GetFilePath = ""& & End If& & End function& & Private function GetFileName(FullPath)& & If FullPath
"" Then& & GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)& & Else& & GetFileName = ""& & End If& & End function& & Private function toByte(Str)& & dim i,iCode,c,iLow,iHigh& & toByte=""& & For i=1 To Len(Str)& & c=mid(Str,i,1)& & iCode =Asc(c)& & If iCode<0 Then iCode = iCode + 65535& & If iCode>255 Then& & iLow = Left(Hex(Asc(c)),2)& & iHigh =Right(Hex(Asc(c)),2)& & toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)& & Else& & toByte = toByte & chrB(AscB(c))& & End If& & Next& & End function& & End Class& & Class FileInfo& & dim FormName,FileName,FilePath,FileSize,FileStart& & Private Sub Class_Initialize& & FileName = ""& & FilePath = ""& & FileSize = 0& & FileStart= 0& & FormName = ""& & End Sub& & Public function SaveAs(FullPath)& & dim dr,ErrorChar,i& & SaveAs=1& & if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function& & if FileStart=0 or right(fullpath,1)="/" then exit function& & set dr=CreateObject("Adodb.Stream")& & dr.Mode=3& & dr.Type=1& & dr.Open& & upfile_5xSoft_Stream.position=FileStart-1& & upfile_5xSoft_Stream.copyto dr,FileSize& & dr.SaveToFile FullPath,2& & dr.Close& & set dr=nothing& & SaveAs=0& & end function& & End Class& & %>& & <%& & function sqlstr(data)& & if not isnull(data) then& & sqlstr="'"& replace(data,"'","''") &"'"& & else& & sqlstr="'"& data &"'"& & end if& & end function& & %>& & <%& & session.CodePage=936& & Server.ScriptTimeOut=600000& & set upload=new upload_5xsoft& & set file=upload.file("filexls")& & %>& & <%& & if file.fileSize>0 then& & filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)& & filename=filename+"."& & filenameend=file.filename& & filenameshow=file.filename& & filenameend=split(filenameend,".")& & if filenameend(1)="xls" then& & filename=filename&filenameend(1)& & file.saveAs Server.mappath("uploadfiles/"&filename)& & else& & response.write "数据格式不对!"& & response.write "& & & & & & & & & & & & 您可能感兴趣的文章:EXCEL数据上传到SQL SERVER中的简单实现方法Asp.net中把Excel数据存储至SQL Server中的具体实现方法如何把Excel数据导入到SQL2008数据库的实例方法Excel导入Sqlserver数据库脚本Excel数据导入Mysql数据库的实现代码把excel表格里的数据导入sql数据库的两种方法& & QQ空间
百度搜藏更多& & Tags:Excel SQLServer& & 复制链接收藏本文打印本文关闭本文返回首页& & 上一篇:asp 判断是否为搜索引擎蜘蛛的代码& & 下一篇:Microsoft JET Database Engine(0x)未指定错误的解决方法& & 相关文章asp下实现记录集内随机取记录的代码使用ODBC数据库管理Serv-U的FTP用户及相关ASP编程[附源码示例下载ASP新闻分页,将一篇过长的文章分页,生成静态页面asp在服务器把 XML 转换为 XHTML的实现代码asp adodb.stream对象的方法/属性asp下实现字符串的补充fill()asp 之上传漏洞终结篇asp ajax跨域提交数据asp实现限制搜索的关键字的函数asp验证Ip格式的函数& & 文章评论& & 最 近 更 新& & asp长文章用分页符来分页显示冒泡算法的三种JavaScript表示asp下实现替换远程文件为本地文件并保存远在ASP中用组件检测当前网卡地址的代码编写通用的asp防注入程序在Asp程序中取得表单所有内容的代码生成EAN13标准的条形码的ASP代码实例用asp实现网页调用doc附Response.Contentasp 多关键词搜索的简单实现方法比较详细的Asp伪静态化方法及Asp静态化探& & 热 点 排 行& & 错误类型:Provider (0x关于“未指定的错误”的问题 的比utf-8 网页不显示+utf-8网页乱码asp 字符串截取函数Asp 日期格式化问题C#入门教程之ListBox控件使用方法asp获取URL参数的几种方法分析总ASP注册登陆实例代码ASP UTF-8页面乱码+GB2312转UTF-asp UTF-8 乱码问题的解决方法小
声明:该文章系网友上传分享,此内容仅代表网友个人经验或观点,不代表本网站立场和观点;若未进行原创声明,则表明该文章系转载自互联网;若该文章内容涉嫌侵权,请及时向上学吧网站投诉>>
上一篇:下一篇:
相关经验教程
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益asp。net中将excel导入到sql2005中的代码_百度知道
asp。net中将excel导入到sql2005中的代码
求高手帮助,看不懂。网上找了许多都不能用。问如何用一个按钮实现将外部的excel(最好 word也可)导入到sql2005中。求代码。不要太复杂太长。邮箱@qq本人做一个学生成绩管理系统,用c#语言
提问者采纳
已发送到邮箱,请查收
提问者评价
已收到,谢谢。
采纳率100%
其他类似问题
为您推荐:
excel的相关知识
其他3条回答
一个Recordset。也可以使用DTS帮助批量导入,然后读出来.把Excel文件作为数据表,修改代码即可,选择数据表中表名,然后就可以选择了导入的数据库表将外部的excel(最好 word也可)导入到sql2005中,需要建立一个连接
#region 创建一个Excel示例
/// &summary&
/// 创建一个Excel示例
/// &/summary&
public void CreateExcel()
Excel.Application excel = new Excel.Application();
excel.Application.Workbooks.Add(true);
excel.Cells[1, 1] = &第1行第1列&;
excel.Cells[1, 2] = &第1行第2列&;
excel.Cells[2, 1] = &第2行第1列&;
excel.Cells[2, 2] = &第2行第2列&;
excel.Cells[3, 1] = &第3行第1列&;
excel.Cells[3, 2] = &第3行第2列&;
excel.ActiveWorkbook.SaveAs(&./tt.xls&, XlFileFormat.xlExcel9795, null, null,...
参考资料:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 office2013 excel加密 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信