2011-04-11 2 views
0

고객이 웹 사이트에서 가격 목록을 원합니다. 스프레드 시트 (.xlsx)를 데이터 소스로 사용하여 웹 사이트에 표시되기 전에 데이터 처리를 제한하려고합니다.vb 웹 응용 프로그램의 스프레드 시트 연결

이 사이트는 IIS 7에서 실행되고 있습니다. 서버는 Windows Server 2008입니다. .NET Framework 4.0에서도이 업데이트를 제공합니다.

Office 패키지가 설치되어 있지 않으며 문제가있는 곳에서 직감을 가졌지 만 실제로 확신하고 싶습니다.

는 Heres는 오류 텍스트 내가 갖는 :

System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at Products.Page_Load(Object sender, EventArgs e) in C:\HostingSpaces\webbuddies\waterinc.webbuddies.co.za\wwwroot\Products.aspx.vb:line 14

Heres는 내 코드 :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
' Here's the connection string as defined in web.config: 
' <connectionStrings> 
'  <add name="xlsx" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=App_Data/Pricelist.xlsx;Extended Properties=Excel 8.0;" /> 
' </connectionStrings> 
    Dim con As New OleDbConnection(ConfigurationManager.ConnectionStrings("xlsx").ConnectionString) 

    ' The spreadsheet has 4 sheets in it, 1 for each category on the client's pricelist. 
    Try 
     con.Open() 

     Dim dsWater As DataSet 
     Dim daWater As New OleDbDataAdapter 
     daWater.SelectCommand = New OleDbCommand("SELECT * FROM Water", con) 

     Dim dsJuice As DataSet 
     Dim daJuice As New OleDbDataAdapter 
     daJuice.SelectCommand = New OleDbCommand("SELECT * FROM FruitJiuce", con) 

     Dim dsMix As DataSet 
     Dim daMix As New OleDbDataAdapter 
     daMix.SelectCommand = New OleDbCommand("SELECT * FROM MuffinMix", con) 

     Dim dsMisc As DataSet 
     Dim daMisc As New OleDbDataAdapter 
     daMisc.SelectCommand = New OleDbCommand("SELECT * FROM Miscellaneous", con) 

     daWater.Fill(dsWater, "Water") 
     daJuice.Fill(dsJuice, "FruitJuice") 
     daMix.Fill(dsMix, "MuffinMix") 
     daMisc.Fill(dsMisc, "Miscellaneous") 

     rptWater.DataSource = dsWater : rptWater.DataBind() 
     rptJuices.DataSource = dsJuice : rptJuices.DataBind() 
     rptMixes.DataSource = dsMix : rptMixes.DataBind() 
     rptMisc.DataSource = dsMisc : rptJuices.DataBind() 

     con.Close() 
    Catch ex As Exception 
     errorMessage = ex.ToString 
     lblResponse.Text = "Could not connect to one or more data sources required to display the " & _ 
      "pricelist. Please contact the webmaster." & vbCrLf & errorMessage 
     lblResponse.ForeColor = Drawing.Color.Red 
    End Try 
End Sub 

EDIT 1
난에 2007 사무실 드라이버를 설치 게시 이후 서버에서 첫 번째 대답의 링크를 클릭하고 두 번째 대답에 따라 연결 문자열을 수정했습니다.

<connectionStrings> 
    <add name="xlsx" connectionString="Provider=Microsoft.ACE.OLEDB.12.0; Data Source=App_Data/Pricelist.xlsx; Extended Properties=Excel 12.0 Xml; HDR=YES;"/> 
</connectionStrings> 

답변

0

XLSX 파일의 경우 이와 같이 연결 문자열을 수정해야합니다.

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES"; 

자세한 정보는 - http://connectionstrings.com/excel-2007

+0

내가 공급자 = Microsoft.ACE.OLEDB.21.0 '로 시작,'하지만이를 타이핑으로 지금은 내가 서버에 설치된 2007 오피스 드라이버를 가지고 있지 않은 것을 나에게 발생 당시 ... – Ortund

+0

2003/2007/2010을 사용하고있는 Excel의 버전은 무엇입니까? 2007 년은 Microsoft.ACE.OLEDB.12.0이고 2010 년에는 Microsoft.ACE.OLEDB.14.0입니다. – Anuraj

+0

Office 사용 207 Pro – Ortund