Current location: Hot Scripts Forums » Programming Languages » ASP » How to download data from datagrid to Excel?


How to download data from datagrid to Excel?

Reply
  #1 (permalink)  
Old 09-14-03, 10:44 PM
engheegoh engheegoh is offline
New Member
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to download data from datagrid to Excel?

Goodday,

I have a download button in my web page. When i click on the button, it should be able to download all the data in the datagrid to excel.

But i am getting this error:-
System.Runtime.InteropServices.COMException: Member not found.

I have included the following namespace in the web page but still error.......
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Excel" %>

Here is my coding
=============
asp Code:
  1. Dim rw As DataGridItem
  2. Dim clcnt As Integer
  3. Dim clval As String
  4. Dim oExcel As Excel.Application
  5. Dim oBook As Excel.Workbook
  6. Dim oSheet As Excel.Worksheet
  7.            
  8.  
  9. oExcel = CreateObject("Excel.Application")
  10. oBook = oExcel.Workbooks.Add
  11. oSheet = oBook.Worksheets(1)
  12.  
  13. dim rcnt as integer
  14. rcnt=1
  15. For Each rw In dgSummary.Items
  16.     For clcnt = 0 To rw.Cells.Count - 1
  17.       clval = rw.Cells(0).Text.ToString
  18.       oSheet.Cells(rcnt, clcnt).value = clval
  19.     Next
  20.     rcnt=rcnt +1
  21. Next
  22.  
  23. oBook.SaveAs("c:\myfile.xls")
Anyone can help me?
Thank you very very much.

Last edited by Nico; 10-09-08 at 03:14 AM. Reason: Wrappers.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
one-page form/catalog in php, data fed in with .csv file? domaky PHP 2 10-25-03 09:32 AM
Print data by date perleo PHP 2 08-09-03 09:35 AM
importing data from MS Access to Excel using ASP craigger1 ASP 1 08-05-03 03:11 PM
Form to Excel markpilkinton Script Requests 1 07-11-03 04:17 PM
cannot display the complete data najmun PHP 2 07-04-03 02:52 PM


All times are GMT -5. The time now is 03:30 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.