从ASP.Net导入Excel [英] Excel Import From ASP.Net

查看:87
本文介绍了从ASP.Net导入Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请为我提供有关如何消除错误的建议-
当我尝试从ASP.NET应用程序连接到Excel文档时,找不到可安装的ISAM".

我仔细阅读了它,并由于连接字符串而使evryone说出了它的原因,如果我使用jet.4.0,并且Extended Properties设置为Excel 8.0,它应该可以工作,但是我仍然遇到了erorr.

代码是:

HI all,

Please advice me on how to get rid of the error-
"Cannot find installable ISAM" when I try to connect to an Excel doc from ASP.NET app.

I read up on it and evryone says its because of the connection string and if I use jet.4.0 and Extended Properties is set to Excel 8.0 it should work, but I am still getting the erorr.

The code is:

Protected Function ExcelConnection() As OleDbCommand
    Dim xConnStr As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;Extended Properties=Excel 8.0;HDR = YES;IMEX = 1"

    ' create your excel connection object using the connection string
    Dim objXConn As New OleDbConnection(xConnStr)
    objXConn.Open()
    ' use a SQL Select command to retrieve the data from the Excel Spreadsheet
    ' the "table name" is the name of the worksheet within the spreadsheet
    ' in this case, the worksheet name is "Members" and is expressed as: [Members$]
    Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn)
    Return objCommand



请帮忙..

谢谢.



Please help..

Thanks.

推荐答案

Dim objCommand As 新建 OleDbCommand("
Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1


" ,objXConn) 返回 objCommand
", objXConn) Return objCommand



请帮忙..

谢谢.



Please help..

Thanks.


如果您使用的是MS Excel 2007,则将 Provider=Microsoft.Jet.OLEDB.4.0更改为Microsoft.ACE.OLEDB.12.0,将 Extended Properties=Excel 8.0更改为
Extended Properties=Excel 12.0在您的连接字符串中.

此处.
If you are using MS Excel 2007 than change Provider=Microsoft.Jet.OLEDB.4.0 to Microsoft.ACE.OLEDB.12.0 and Extended Properties=Excel 8.0 to
Extended Properties=Excel 12.0 in your connection string.

More details here.


这篇关于从ASP.Net导入Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆