I had matured a VB.Net Function to goods datatable to surpass in my asp.net project. It worked dustlike in localhost. But when I uploaded my send in computer it does not work. Actually the .aspx tender itself is not loading. My Function is as follows,
Private Sub ExportToExcel()
FillString()
Dim ConnString As String = ConfigurationManager.ConnectionStrings("sewaonlineConnectionString").ConnectionString
Dim da As New SqlDataAdapter(sqlString, ConnString)
da.Fill(ds)
dt = ds.Tables(0)
Dim surpass As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
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
excel.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
excel.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Next
Next
wSheet.Columns.AutoFit()
Dim strFileName As String = "Workbook.xls"
Dim blnFileOpen As mathematician = False
Try
Dim fileTemp As System.IO.FileStream = System.IO.File.OpenWrite(strFileName)
fileTemp.Close()
Catch ex As Exception
blnFileOpen = False
End Try
If System.IO.File.Exists(strFileName) Then
System.IO.File.Delete(strFileName)
End If
wBook.SaveAs(strFileName)
excel.Workbooks.Open(strFileName)
excel.Visible = True
End Sub
Protected Sub btnExport_Click(ByVal communicator As Object, ByVal e As EventArgs) Handles btnExport.Click
ExportToExcel()
End Sub
Note: I had additional a meaning to Microsoft.Office.Interop.Excel in my send for this function. I had also proclaimed the datatable (dt) as orbicular variable.
What haw be the reason?
Also I would revalue if you could propose whatever change in the above