Dataset results in 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
 
C

Cowboy

Vanajakshi Pidatala said:
My questin are:

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

If you are using the Office objects to create Excel, you have to have Office
installed on the server. I am not fond of this option, although it works.

A better option is a tool like ExcelWriter:
http://officewriter.softartisans.com/officewriter-37.aspx

Better security and less likelihood of introducing a security hole.
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).

To read Excel spreadsheets, the user must have Excel or the Excel viewer
(free download):

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

You can code a generic excel page by simply changing MIME type and
outputting HTML tables. Not sure if this works with extremely old versions
of Excel, but Excel 2000+ will work with this idea.
4.Is there a diifrent way that I can open excel and show satase reults
in it.

Depeding on the version(s) of Excel, there are options. For the latest Excel
(2003), you can create an Excel spreadsheet that contacts a web service to
fill it. The user can keep up with the latest data by simply downloading the
spreadsheet. The downside here is when you have huge data transfer to Excel,
but the server side option could bog down here, as well.

Hope this helps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
V

Vanajakshi Pidatala

HELlO, WOULD SOME ONE PLEASE TELL ME WHY i AM NOT ABLE CREATE AN
INSTANCE OF EXCEL APP. IN A VB.NET.

The code:
Dim excelApp As Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
Is returning null to exce app.

And the code:

oExcelApp = CreateObject("Excel.Application")

is retuning the error 'can not create activex contrl'

Would some onne gove .net 1.1 version of kb article 319180,. It has
error when i am trying it in .net version 1.1.

Thanks a lot in advance.
 
O

onedaywhen

(e-mail address removed) wrote ...
Dim excelApp As Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
Is returning null to exce app.

And the code:

oExcelApp = CreateObject("Excel.Application")

is retuning the error 'can not create activex contrl'

Could be a problem with the registry. I'd suggest uninstalling MS
Office completely before reinstalling.

--
 

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