all groups > sql server reporting services > august 2005 >
You're in the

sql server reporting services

group:

Export Just Data to Excel


Export Just Data to Excel Alec Hardy
8/31/2005 1:28:02 PM
sql server reporting services:
We would like to have a way to export just the data displayed in a report to
Excel. We have looked at CSV export, but find it doesn't export well.

We would like to remove the headers from the report when it exports. The
only way we have found to do this is to create a separate report without the
RE: Export Just Data to Excel VChandy
9/8/2005 10:06:03 AM
Alex,

Yup, this was a problem for me as well but I got round it using XSL to
produce my desired CSV output. Using UrlAccess you can specify an XSL
transformation to an XML export --> CSV. Yes, got rid of those headers!
...
&rs:Command=Render&rs:Format=XML&rc:OmitSchema=True&rc:FileExtension=csv&rc:XSLT=MyReport.xsl

Sample xsl below -

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" encoding="utf-8" media-type="text/plain"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:text>Field1,Field2,Field3,Field4&#xD;</xsl:text>
<xsl:for-each
select="Report//List1/list1_FirmID/List2/List2_Details_Group/table1/Detail_Collection/Detail">
<xsl:value-of select="concat(@Field1, ',', @Field2, ',', @Field3, ',',
@Field4, ' ')" />
</xsl:for-each>
<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

[quoted text, click to view]
Re: Export Just Data to Excel Bruce L-C [MVP]
9/8/2005 12:34:27 PM
Depending on how you design your reports you can do the following to export
to Excel. Or, what I do sometimes is make a copy of the report and clean it
up for data export and then hide it in list view. If you export from Report
Manager it puts CSV data in unicode which Excel puts all in one column. If
you export in ASCII then Excel does just as you want. To prevent a problem
with cells (Excel will object to sorting the data) you need to remove any
textboxes you have (for instance with a title, showing the parameters run
etc) and instead add additional header rows, merge the cells and put your
text in there instead. I add a link at the top of the report that says
Export Data. With RS 2005 you will be able to configure it to use ASCII
instead of Unicode.

Here is an example of a Jump to URL link I use. This causes Excel to come up
with the data in a separate window:

="javascript:void(window.open('" & Globals!ReportServerUrl &
"?/SomeFolder/SomeReport&ParamName=" & Parameters!ParamName.Value &
"&rs:Format=CSV&rc:Encoding=ASCII','_blank'))"

If you don't want to have it appear in a new window then do this in jump to
URL:

=Globals!ReportServerUrl & "?/SomeFolder/SomeReport&ParamName=" &
Parameters!ParamName.Value & "&rs:Format=CSV&rc:Encoding=ASCII"

Very nice and very fast.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services


[quoted text, click to view]

AddThis Social Bookmark Button