PC Review


Reply
Thread Tools Rate Thread

Dataset results in excel sheet

 
 
Vanajakshi Pidatala
Guest
Posts: n/a
 
      18th May 2004
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
 
Reply With Quote
 
 
 
 
Cowboy
Guest
Posts: n/a
 
      18th May 2004
"Vanajakshi Pidatala" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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...writer-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!
************************************************


 
Reply With Quote
 
Vanajakshi Pidatala
Guest
Posts: n/a
 
      19th May 2004
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.
 
Reply With Quote
 
Val Mazur
Guest
Posts: n/a
 
      20th May 2004
Hi,

You actually do not need Excel itself to work with Excel file from VB. You
could use ADO.NET in combination with Jet provider to do this. It does not
require installation of the Excel COM in this case. Check next examples how
to do this

http://support.microsoft.com/default...Product=adonet

http://support.microsoft.com/default...Product=adonet

--
Val Mazur
Microsoft MVP


"Vanajakshi Pidatala" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
onedaywhen
Guest
Posts: n/a
 
      20th May 2004
(E-Mail 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.

--
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Split text file into Excel sheet and separate the final results intoa new sheet Luciano Paulino da Silva Microsoft Excel Worksheet Functions 8 18th Apr 2009 02:00 AM
Export DataSet/ XML as Excel Sheet Sachin Salgarkar Microsoft ASP .NET 3 4th Aug 2006 04:40 PM
Exporting a search results to Excel sheet. chetna kalra via AccessMonster.com Microsoft Access External Data 1 20th Apr 2005 04:01 PM
Dataset reults to excel sheet Vanajakshi Pidatala Microsoft VB .NET 1 19th May 2004 08:40 AM
Exporting a dataset to an excel sheet. raj Microsoft Dot NET Framework Forms 1 27th Dec 2003 04:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 AM.