.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Problem with interop dll

Posted By: Subha     Posted Date: July 18, 2010    Points:2   Category :ASP.Net
I am using Interop.Microsoft.Office.Interop.Excel.dll for exporting the data from the database and transfer the data to excel.

It work fine before publishing.But after publishing the excel cannot open.It does not generate error.

Imports System.Data.SqlClient
Imports System.Data
Imports System.Reflection
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Reflection.Missing
Partial Class Attendance_UserControl_StaffMonthlyReport
Inherits System.Web.UI.UserControl
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim xlworkbook As Excel.Workbook
Dim xlworksheet As Excel.Worksheet

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
xlworkbook = New Excel.Application
Dim ds, ds1 As New DataSet
xlworkbook.Application.Visible = True
'xlworksheet = xlworkbook.ActiveSheet
xlworksheet = xlworkbook.Sheets(1)
cmd.Connection = con
cmd.CommandText = "select Rollno,name from stuattendance"
da.SelectCommand = cmd
ds1 = New DataSet()
Dim irow = 5
Dim k, sno As Integer
k = 3
sno = 1
For rowNo As Integer = 0 To ds1.Tables(0).Rows.Count - 1
xlworksheet.Cells(irow, 1) = sno
sno = sno + 1
irow += 1

End Sub

In this way i am generating the data to excel.It will work successfully before publishing.It will open the excel and fill the datas to the corresponding rows and columns.But after publishing the excel file cannot open it will not generate any error.I dont know it is the right way to generate the data to excel.


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend