Hi
I am developing one website,in that i will export values from data table to excel file,using excel.interop.dll,in developing machine installed ms office 2013, so it works,but when i deploy in server machine which is not have ms office or excel.interop.dll ,so it show error like this
Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
How to solve this problem without installing ms office in main server,main server never allowed to install any software,so dont suggest me to install ms office,separate dll can install,if possible then how ?
This is my code
Imports Microsoft.Office.Interop
Dim sqlcon As New SqlConnection(ConfigurationManager.ConnectionStrings("CS").ToString())
Dim objDataAdapter As New SqlDataAdapter(ExcQuery, sqlcon)
Dim objDataTable As New DataTable
objDataAdapter.Fill(objDataTable)
dynamicFLXname = Date.Now.ToString("ddMMMyyyyhhmmss", System.Globalization.CultureInfo.InvariantCulture)
dynamicFLXname = dynamicFLXname + ".xlsx"
Dim strFileName As String = Server.MapPath(".") + "\Temp\" + dynamicFLXname
If objDataTable.Rows.Count = 0 Then
manager.Alert("No Result !")
Exit Sub
End If
If objDataTable.Rows.Count > 0 Then
Dim _excel As New Excel.Application
Dim wBook As Excel.Workbook
Dim wSheet As Excel.Worksheet
wBook = _excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
Dim dt As System.Data.DataTable = objDataTable
Dim dc As System.Data.DataColumn
Dim dr As System.Data.DataRow
Dim colIndex As Integer = 0
Dim rowIndex As Integer = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
wSheet.Cells(1, colIndex) = dc.ColumnName
Next
For Each dr In dt.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
wSheet.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Next
Next
wSheet.Columns.AutoFit()
wBook.SaveAs(strFileName)
wBook.Close(False)
_excel.Quit()
What I have tried:
I am try to refer excel dll directly,not work,i try to refer ms office object 15.0 object library ,never work.
Regards
Aravind