Dataset reults to excel sheet

  • Thread starter Vanajakshi Pidatala
  • Start date

V

Vanajakshi Pidatala

Hello,

I am trying to show data in dataset in to an excel
sheet(ASP.NET/VB.NET). I AM DOING THIS ON SERVER(IIS SERVER) WHICH HAS
EXCEL VERSION 9. I COULD ADD REFERENCE TO EXCEL VERSION 9 AND OFFICE
VERSION 10 IN MY PROJECT. I DO NOT HAVE EXC EL VERSION 10 TO WHICH I
CAN ADD REFERENCE (WHICH I THINK IS THE PROBLEM). i AM GETTING THE
ERROR ' REFERENCE TO NULL OBJECT AT THE CODE line
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add(object
excelApp is not create and I am trying to refere it).

My questin are:

1.Do I need to have excel 10 to have this code run.

2.Do I need to have excel 10 on all clients machines(people who are
accesing this page through web page). Or is it just enough to have
excel 10 on the server(iis server).

3.Is there a way that I c an have this code run woth any version of
excel.

4.Is there a diifrent way that I can open excel and show satase reults
in it.

I AM TRYNG SOME THING LIKE THIS:

Dim excelApp As Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
'Dim excelBook As NEW Excel.Workbook
'excelBook = CType(excelApp.Workbooks(1), Excel.Workbook)
Dim excelWorksheet As NEW Excel.Worksheet
excelWorksheet = CType(excelBook.Worksheets(1),
Excel.Worksheet)
'Makes Excel invisible to the user until spreadsheet is
populated
excelApp.Visible = False
With excelWorksheet
'Format cell headings
.Range("A1").Value = "Issue Type"
.Range("A1").Font.Bold = True
.Range("A1").ColumnWidth = 200
.Range("B1").Value = "Number of Calls"
.Range("B1").Font.Bold = True
.Range("B1").ColumnWidth = 15
.Range("A2").Value = sDateRange
.Range("A2").Font.Bold = True
.Range("A2").ColumnWidth = 200


For i = 0 To dsIssueType.Tables(0).Rows.Count - 1
.Range("A" & i.ToString + 3).Value =
dsIssueType.Tables(0).Rows(i)("IssueType")
.Range("B" & i.ToString + 3).Value =
dsIssueType.Tables(0).Rows(i)("NumberOfTickets")

Next
.Range("A" & i.ToString + 4).Value = "Total Number of
Calls"
.Range("A" & i.ToString + 4).Font.Bold = True
.Range("A" & i.ToString + 4).ColumnWidth = 200
.Range("B" & i.ToString + 4).Value =
nTotalNumberOfCalls
.Range("B" & i.ToString + 4).Font.Bold = True
.Range("B" & i.ToString + 4).ColumnWidth = 15

excelApp.Visible = True
End With

Thanks a lot
 
Ad

Advertisements

C

Cor Ligthert

Hi Vanajakshi,

When you use interop as you do, than you create a tunnel to your
application.

When you use from that application features, than as far as I know should
that be the features from the existing application.

I hope it helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top