473,700 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export to excel from MS SQL using ASP

4 New Member
Hi Champs - I need little help from you all.

I am new to ASP and need to generate a code having functionality to export the query results to Excel.

Right now, the user is getting the report on the page itself and now i need to provide him fuctionality to export the same results in excel. I need to provide a button on the top and with the clik of it the user will able to export the whole data (query result data - already on the page) into excel sheet.

Please let me know how to do it. I have whole existing code for the page where query results are shown on webpage.

Thanks a lot.

Its really urgent.

Regards,
SP
Aug 3 '09 #1
5 7249
GazMathias
228 Recognized Expert New Member
Hi,

I am new to ASP and need to generate a code having functionality to export the query results to Excel.
ASP or ASP.NET?

If ASP:

I once wrote a library that would take the query results from a recordset and create a spreadsheet from it.

On the page you would just need to add this line where you would like a link to appear:

Expand|Select|Wrap|Line Numbers
  1. ExcelDownload xl, RS, "Speadsheets/KPIDeliveryStats Jun 09.xls"
  2.  
Where RS is a ByRef name of the Recordset.
Spreadsheets is a folder in your app's file system
xl is the name the library would give the Excel object instance it creates.

On page, you would see a "Create Spreadsheet" link that would change to "Excel File Generated - Click to download."

Obviously, this only creates spreadsheets from the recordset data, not what is displayed on screen.

Would that be of any use to you?

Gaz
Aug 3 '09 #2
simbhasin
4 New Member
Thanks Gaz,

I tried to put this string in my code. But not able to get it done.

Here is the code file. Can you please look into it and let me know where should i add this string

I have changed the file extension from asp to txt

Thanks for all your help.

Regards,
SP
Attached Files
File Type: txt SRQUERY.txt (24.8 KB, 1088 views)
Aug 4 '09 #3
simbhasin
4 New Member
Th actual thing is:

I am creating a asp page that wiil fetch data from database and export that to excel.

Existing fuctionality is being acheived by creating an HTML table to display the data. Now that it displays the data correctly in IE, I want to it to be stored in excel file too by showing one extra button over there on the output screen for the query

Please help.

Thanks
Aug 4 '09 #4
GazMathias
228 Recognized Expert New Member
Hi,

The library of functions I mention in my previous post will export what comes out of the database to Excel in exactly the manner you describe.

http://bytes.com/topic/asp-classic/i...yed-data-excel

Please re-read my prior post and the above article and decide which method is right for you.

Gaz
Aug 4 '09 #5
simbhasin
4 New Member
Thanks a lot Gaz

It really worked for me. I was little confused, things are pretty clear now.
Actually, this is my first assignment in ASP and it was urgent too.


Thanks for all your help and support.

SP
Aug 5 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5029
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType = "application/vnd.ms-excel") This works fine with Excel 2003 but with older versions (I tested Excel...
6
13135
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel spreadsheet. I'm having trouble with my code at the point at which it hits ".ReadRecords" -- the module just runs and runs without generating anything. I've gotten this code to correctly save .rpt files without any data, but not with data, nor have I been...
5
8671
by: Igor | last post by:
Hi everyone! I have a question about exporting data to Microsoft Excel. I am writing program in C# and have to export some data to excel workbook. It works very good using OLE technology, but it requires Microsoft Excel installed on every machine with my program. It is not quite convenient to do so. Is there another way to export data to Excel, or how simply create file of Microsoft Excel format from my program (of cause, the format of...
8
2852
by: DC Gringo | last post by:
I have a simple button that should open another window and export a datagrid to an Excel file. I'm getting: "Name 'window' is not declared." What do I need to declare or import? <INPUT ID="Button5" ONCLICK="Button5_Click" NAME="Button5" TYPE="button" VALUE="Export to Excel"> Sub Button5_Click()
6
4062
by: Elena | last post by:
I'm trying to export data to an Excel worksheet. I can export the data in the cell values perfectly. I need the code to change a header and footer for the worksheet, not for the columns. Is this possible? If so, I really need the code immediately. Thank you, Elena
5
31918
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
1
9775
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping to export two Tables (or queries...not sure which to use - they both seem to have the same data) in...
1
10494
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am trying to export to Excel using a command in an Access Form. RowID strFY AccountID CostElementWBS 1 2008 1 7 2 2008 1 7 I want to...
3
7154
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
2
6413
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the method.... it creates 6 sheets # region Namespaces using System;
0
8726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8645
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.