This is a migrated thread and some comments may be shown as answers.
Best way to intercept CSV Export?
7 Answers 109 Views
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 06 Dec 2011, 05:39 PM
We have a report containing a subreport.  When we export to CSV all the fields from the report are added to each line of data from the Subreport.

Is there some way to prevent this or to intercept the request to the export feature so that we only export the subreport raw data?

Thanks!

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 07 Dec 2011, 03:46 PM
Hello Kevin,

The main purpose of the CSV format is to transfer data between different information systems (programs). For example you may import it in MS Excel or Word. For this reason the CSV format is not designed to be human-readable and is not "WYSIWYG" as PDF or Excel formats. More about the idea that lies behind the CSV format can be read here.

To illustrate better, the data from the master and detail report is joined together into one big denormalized table with INNER JOIN.
In short, this behavior is by design and cannot be changed at this time. You can find more information about the peculiarities and limitations of both CSV and Excel formats in the following articles:

Greetings,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Kevin
Top achievements
Rank 1
answered on 07 Dec 2011, 04:55 PM
I thought an  event was fired when the export was initiated... then I could create the export myself and feed it into the stream...

I don't want human readable, I want just the detail data -- all the other columns are extraneous.
0
Kevin
Top achievements
Rank 1
answered on 08 Dec 2011, 11:54 PM
Ok...

so I found a workaround, but still having some problems.

I added a parameter for "details only" and when that is set to true, it removes the ReportHeader section from from the report before rendered.  Just drops it from the Items collection.

Cool, eh? (Setting Visible = false didn't work for this)

HOWEVER

When I export to CSV, I'm getting all the column headers in the "group" section exporting with the lines.  So I get

ColumnHeaderTextBox1, ColumnHeaderTextBox2, Call Date, Call Time, ColumnValueTextBox1, ColumnValueTextBox2, 1/1/1900, 12:00

So I tried to remove the groupsectionheader and it removes the formatting, but not the items -- so instead of white on blue (my style), the show as black on blue... but are still there in the export.

How can I remove these???
0
Steve
Telerik team
answered on 09 Dec 2011, 09:47 AM
Hi Kevin,

There is no designated event when exporting/printing. As outlined in the CSV Device Information Settings help article, the NoHeader device setting indicates whether the header row is excluded from the output. The NoStaticText indicates whether static text is excluded from the output. So adding these settings as shown in the Configuring the CSV Rendering Extension KB article should remove the undesired static data.

Regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Cyril
Top achievements
Rank 1
answered on 09 Dec 2011, 01:51 PM
I have a similar request. We have a report which contains a set of total at the top of the report and then the list of item. When we export the data to CSV, each line contains the total like

44,69,Access Data,1,CT Summation,08/12/2011 10:49 AM,2.9.1.7
44,69,Adobe,4,Adobe Flash,08/12/2011 10:49 AM,10.0
44,69,Apple,2,Apple iTunes,08/12/2011 10:49 AM,10.5.0.142
44,69,ArcSoft,1,ARCS2G,08/12/2011 10:49 AM,6.5
44,69,Autonomy,3,Autonomy EAS Client,08/12/2011 10:49 AM,6.2.1.5

The total is something that would be derived by using the CSV data so is really not needed here... There really is no way to exclude it ?
0
Kevin
Top achievements
Rank 1
answered on 09 Dec 2011, 05:13 PM
Excellent Steve... thank you!

Using NoStaticText, I was able to remove most of the problems.  NoHeader doesn't elimiate the report header, but the CSV header... so that I left to true.

I then renamed the data textboxes to what I wanted their CSV fieldnames to be and then for the main report I took all my "calculated" fields (ones with "="), most which were simply echoing report parameters, and set them to empty values.

In the code behind of the report, I set these values programmatically. To the report, they appear static, even though they are calculated at runtime.

I was then able to pull my "Detail Only" kludge and let the user browse the real report and then export to CSV.

Success!

Thanks again!
0
Kevin
Top achievements
Rank 1
answered on 09 Dec 2011, 05:13 PM
Cyril - Calculate that value if you can in the code behind of the report (.cs) and set it via code.  It will be static to the report and thus not export to CSV.
Asked by
Kevin
Top achievements
Rank 1
Answers by
Steve
Telerik team
Kevin
Top achievements
Rank 1
Cyril
Top achievements
Rank 1
Share this question
or