Groups | Blog | Home
all groups > sql server reporting services > february 2006 >

sql server reporting services : CSV Export


drchips NO[at]SPAM nospam.nospam
2/20/2006 4:52:35 PM
I'm using a webclient to pull back the different rendering format's
available from SQL Reports. I guess MS added CSV files and I would like to
bring that down - but I'm having a little trouble passing the paramater that
will bring it back. Following is my current list. Does anyone know what it
should by for csv? (I've tried CSV and it doesn't work.)

case _rsTypePDF:

fext = "pdf";

ReportFormat = "PDF";

break;

case _rsTypeIMAGE:

fext = "tif";

ReportFormat = "IMAGE";

break;

case _rsTypeMHTML:

fext = "htm";

ReportFormat = "MHTML";

break;

case _rsTypeEXCEL:

fext = "xls";

ReportFormat = "EXCEL";

break;



Thanks,



David

drchips NO[at]SPAM nospam.nospam
2/20/2006 6:54:41 PM
Got it to work - but realize it's not what I need.

Is there a way to render just the straight ascii in a report retaining some
of the formatting such as tabs - carriage returns - etc ?

[quoted text, click to view]

t-weilu NO[at]SPAM online.microsoft.com
2/21/2006 12:00:00 AM
Hi David,

Welcome to use MSDN Managed Newsgroup Support.

From your description, my understanding of this issue is: You want to
export the report to CSV with tab delimited. If I misunderstood your
concern, please feel free to point it out.

Reporting Services can not do it directly. Reporting Services only could
export the CSV with comma delimited. I think the best way is to do it in
Excel. You can create a new worksheet in Excel

1. Import the data from the CSV file and select the Delimited option
at the first step and select Comma as the Delimiter.

2. After import from the CSV file, you can save it as the Text(Tab
Delimited) type.


Hope this will be helpful.

Sincerely yours,

Wei Lu
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bruce L-C [MVP]
2/21/2006 8:44:08 AM
The other issue might be that he is getting the CSV in Unicode instead of
ASCII.
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"

Note the rc:Encoding that is what causes the CSV to come up in ASCII. Excel
does not know how to handle unicode and puts all the data in a single
column. With ASCII, Excel will automatically split the data out into
multiple columns.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

drchips NO[at]SPAM nospam.nospam
2/21/2006 9:41:22 AM
I need a straight ASCII dump of a report with some of the formatting - such
as returns, etc. Is there a way to get that?

[quoted text, click to view]

t-weilu NO[at]SPAM online.microsoft.com
2/22/2006 4:44:27 AM
Hi David,

Thanks for the update. And also thanks Bruce's great suggestion.

I test the solution Bruce used and it works fine on my side.

I use the following statement in a Jump to URL property of a textbox.
=Globals!ReportServerUrl & "?/SomeFolder/SomeReport&ParamName=" &
Parameters!ParamName.Value & "&rs:Format=CSV&rc:Encoding=ASCII"

I think it meet your requirement.

Hope this will be helpful.

Wei Lu
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bruce L-C [MVP]
2/22/2006 12:02:52 PM
_blank is definitely not mime type. That had to do with the frame to show in
the browser.

What you will get back is comma separated variable. Looking at what you
posted it looks like that is what you go back. If you do not want comma
separated variables then don't use CSV export.

Also, the reason you are getting back all the textbox information is because
your report has multiple textboxes above the table. What I do is add
additional table header rows, merge the cells and put my titles etc there.

While working it out I suggest using a very clean report (nothing but your
table on it).

What formatting are you expecting? CSV puts all the fields for a row on one
line separated by commas. The CSV is great for getting data into Excel.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services


[quoted text, click to view]

drchips NO[at]SPAM nospam.nospam
2/22/2006 12:41:14 PM
I'm doing this in C#.

I wasn't sure what parameter you set to "_blank" so I set the mimetype to
it. Here's my code snippet:
case _rsTypeCSV:

fext = "csv";

ReportFormat = "CSV";

encoding = "ASCII";

mimeType = "_blank";

break;

}

results = rs.Render(ReportName, ReportFormat, historyID, deviceInfo,
parameters, credentials, showHide, out encoding, out mimeType, out
reportHistoryParameters, out warnings, out streamIDs);



I'm still getting back:

textbox1,textbox47,textbox30,textbox11,textbox72,textbox65,textbox27,textbox21,textbox57,textbox9,textbox4,textbox16,textbox78,textbox80,textbox12,textbox25,textbox36,RBP,Pulse,LBP,Icd9CodesTxt,textbox61,textbox41,textbox6,ExerciseProtocol,ExerciseStage,Time,ExerciseMets,RatePressure,HeartRate1Min,textbox170,textbox166,textbox162,TermMeds,textbox158,textbox154,textbox146,textbox142,textbox138,textbox114,textbox115,textbox110,textbox111,textbox106,textbox107,textbox102,textbox103,NlLowEf,textbox65,textbox61,textbox57,textbox93,textbox89,textbox85,textbox81,textbox77,textbox73,textbox69,AerobicCapacity,textbox49,textbox45,IschemicResponse,textbox41,textbox37,textbox33,textbox21,textbox18,textbox15,textbox12,textbox4,textbox3,textbox9,DateTxt
Nuclear Stress Imaging Report,"Palms Office

The whole report is a medical record which I can't show you - however - it
has still lost all of it's formatting. I'm not sure what I'm doing wrong
here.



[quoted text, click to view]

Bruce L-C [MVP]
2/23/2006 10:26:14 AM
CSV does not do what you want. I am not aware of a straight ASCII output.
You could do html if this is from your own app and then strip the html tags
out (the .net framework has a library that would allow that).

Bruce Loehle-Conger


[quoted text, click to view]

drchips NO[at]SPAM nospam.nospam
2/23/2006 10:29:53 AM
It a medical diagnosis report. I need a straight ascii dump that retains
it's formatting as much as possible (Carriage returns - hopefully some
positioning by using spaces etc. )

Is there another format besides csv that can give me this? This information
needs to be posted to a central EMR repository for patient data and no meta
info for formatting is accepted by the system.

The way I'm sort of handling it now is to create an mshtml file - write a
bat file to launch it from my app. At that point - a transcriptionist has
to stick her cursor in the browser - hit Cntrl-A - Cntrl C - close the
browser - switch to her EMR interface - hit Cntrl V and save it. This
method doesn't bring any of the html tags over and retains some formatting.

I need to be able to eliminate the transcriptionists intervention in this so
she can focus on all the other work she has to do. Any suggestions? (I can
automate the interface between the systems with no problem - I just need the
ASCII dump)

Thanks for all your input so far.

David




[quoted text, click to view]

Bruce L-C [MVP]
2/24/2006 8:29:18 AM
One thing that might work for you but I haven't done is to use XML output
and then provide your own xslt to get a straight ascii representation of
your report.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

Bruce L-C [MVP]
2/24/2006 1:15:59 PM

Here are several ideas for you:
http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx

http://www.freevbcode.com/ShowCode.asp?ID=110

This article gives some ideas plus how it can't do everything:
http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/27332781e3126287/ceebf4e075a5a8ed%23ceebf4e075a5a8ed?sa=X&oi=groupsr&start=0&num=2

from the article:
[quoted text, click to view]
How To Strip HTML Tags :

Well, the short answer is Regular Expressions, for example:


'(assuming that you have imported System.Text.RegularExpressions)
Dim oRegEx as Regex = RegEx("<[^>]*>")
Dim myNewString as string = oRegEx.Replace(myOldString, "")


However, that won't get you anywhere close to all the way. Even after you
entirely strip out all the <htmltags> you may be left with HTML-encoded
strings such as &nbsp; which you will also want to parse. These are easily
handled with


System.Web.HTTPUtility.HTMLDecode()
[quoted text, click to view]


You might be better off with XML and XSLT as I mentioned in another post.

--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]
drchips NO[at]SPAM nospam.nospam
2/24/2006 1:18:11 PM
That would be great.

What is the name of that library?


[quoted text, click to view]
AddThis Social Bookmark Button