![]() ![]() |
"Export to Excel" Server Behavior
|
| See what users have to say about this extension: THANK YOU.. that totally solved my problem and it's working like magic!! Great product! I'm definitely recommending you to the DW users I know!! Erick Cardoza Randomtype I have purchased two extensions from you website and I would like to thank you for these wonderful tools. They are awesome! Thank you. Michael Kusejko BE52 Media Publishing |
Export your recordset to Microsoft Excel with a click of a button!
Compatible with ASP (VBScript and JavaScript), PHP (MySQL), ColdFusion and ASP.NET (VB) server models.
This Server Behavior will generate a Comma-delimited (.csv) file out of a Recordset without writing it to the hosting server. Your web site user will be prompted to save the file to the hard drive to be open with Microsoft Excel (with an option to open the file directly in the browser (Internet Explorer only)).
In addition you can include Recordset column names in the first row of the exported file.
"Comma-delimited" format uses comma (or semi-column -depending on the locale) as a cell delimiter and line break as a row delimiter. If a field already contains a comma or a line break an undesirable shift of data may occur. To get around this problem this Server Behavior will replace all commas and line breaks in exported file (not in the database!!!) with a character of your choice and a space character respectively. In addition you can specify your own cell delimiter character (new in version 2.2.0).
Please Note: This server behavior will export the Recordset data only, not the entire page. If you need to export the page as is to either Microsoft Word or Excel (while controlling what gets and what doesn't get to be displayed in the exported document) you can download the Save to Word or Excel Server Behavior which does just that.
If you need to you can apply this Server Behavior to more than one Recordset (you have to do this for each Recordset separately).
The Behavior will use the "First check if variable is set" set of parameters to identify which Recordset you wish to export.
To give you an idea on how the Behavior can be used in a real life application the example below demonstrates the use of the Behavior with multiple Recordsets. A table with company employees contains data for employees working in two Departments. The value of the dropdown menu is used by the Departments_rs recordset to extract the data for the selected Department only. When the form is submitted (by either selecting an item from the dropdown or clicking "Export") the Behavior is using the value of a hidden field in this form to determine that this time it will use this recordset for the export.
The page also contains Employees_Names_rs Recordset which grabs only First Name and Last Name parameters for ALL the employees regardless of the Department. Another form titled "Export Employees list (Names only)" has been added to the page. It contains its own hidden field and submit button. If this form is submitted the Behavior will catch the hidden field value and export the Employees_Names_rs Recordset.
| EMPLOYEE_ID | First Name | Last Name | Hourly Rate | Address | Department |
| 1 | Allan | Doe | $70/hr | #10 44 St, WorkCity CA | 44 |
| 4 | Frank | Doe | $40/hr | #22 5th Ave, WorkCity CA | 22 |
| 2 | Jane | Doe | $30/hr | #12 5th Ave. WorkCity CA | 44 |
| 6 | John | Doe | $55/hr | #22 5th Ave, WorkCity CA | 22 |
| 7 | Kevin | Doe | $40/hr | #2 44th St, WorkCity CA | 22 |
| 3 | Robert | Doe | $55/hr | #2 34th St, WorkCity CA | 44 |
| 5 | Tanya | Doe | $40/hr | #21 7th Ave, WorkCity CA | 22 |
Copyright 2004 Alex July, Linecraft Studio