
Using the StaticText configuration option found in previous forum posts, I was able to successfully generate a CSV export without unnecessary text fields. However, I didn't see an option to change the order of the fields in the resultant CSV export. It seems that they're being generated in the order in which they are created (I could be wrong). Is there any way to customize the order in which text fields appear in a CSV export?
Thanks,
Mark
12 Answers, 1 is accepted
As explained in the Design Considerations for CSV Rendering help article: "The remaining report items appear as ordered in the parent’s item collection. Each item is then rendered to a column.". So the behavior you observe is by design and expected.
Note that CSV does not respect visible/invisible sections and formatting and layout are also ignored. If you want a WYSIWYG exported file, please use the excel rendering extension.
Otherwise, if you insist on using CSV, you would have to re-order the report items in the Report item's collection in the order in which you would like them to appear.
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

The data source for my report is a stored procedure that looks like this:
SELECT u.CustomerId, c.LastName, c.FirstName, c.EmailAddress, c.ServiceStartDate, l.Title as ServiceLevel,
s.Description as AccountStatus, u.LastLoginDate, max(e.SentDate) as SentDate
FROM .... <removed unneeded from, joins, and where clauses>
GROUP BY u.CustomerId, c.LastName, c.FirstName, c.EmailAddress, c.ServiceStartDate, l.Title, s.Description, u.LastLoginDate
If I store the results of the above in a recordset the field order is the same as the select statement. I also have the data displayed on my report in the exact same order.
However, when I export to CSV the fields are re-ordered to:
CustomerId, FirstName, LastMessageSentDate, EmailAddress, ServiceStartDate, AccountStatus, LastLoginDate, LastName,
ServiceType
There are no other collections involved that I have implemented. According the the answer in the previous post I would have expected the CSV order to match the results of the select statement but this is clearly not what is happening.
Has this changed in a more recent version of Telerik Reporting? Is there a newer, more precise way to specified the column order of the CSV output?
It seems you have misunderstood the previous reply. You would have to re-order the report items in the Report item's collection in the order in which you would like them to appear and not the items in the select statement.
Kind regards,
Steve
the Telerik team

Since you underlined the report items and report item's collection (without hyperlinking to any relevant documentation) I guess there must be a collection somewhere on the report full of "items". Looking at the report properties I can see many collections (filters, groups, parameters, etc) but none of them contain any items that contain data I want exported.
I did a seach on your site in the Help/Reporting area for "report items" hoping for clarification. There I can see that the items are things like textboxes, charts, panels, SqlDataSources, etc. However, there doesn't seem to be a reference on how to access the collection so I can reorder them. A search for "report item collection" on your site yielded no useful results.
How do I access the report items collection so I can reorder the items?
Generally reordering the report items' collection is mainly viable for the CSV format, and this information is available in the Design Considerations for CSV Rendering help article: "The remaining report items appear as ordered in the parent’s item collection. Each item is then rendered to a column."
The first report item added to the report is added as first member of the report items' collection, the second report item is added as second member etc.
So if you have not taken that into account when creating the report, you would have to manually reorder the items' collection in the InitializeComponent() method. For example if you have 3 TextBox items in the detail section you would have the following markup:
this
.detail.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.textBox1,
this
.textBox2,
this
.textBox3});
If you want the value of textBox2 to be the first in the exported CSV file, you should change it accordingly:
this
.detail.Items.AddRange(
new
Telerik.Reporting.ReportItemBase[] {
this
.textBox2,
this
.textBox1,
this
.textBox3});
Regards,
Steve
the Telerik team


Just perform the same operation for all item in the order you want to see them.
-KS

var detailSection = report.Items.OfType<DetailSection>().FirstOrDefault();
var items = detailSection.Items.OfType<ReportItem>().ToList();
// Remove them, they might be in wrong order
detailSection.Items.RemoveRange(items);
// Re-order in terms of position, to ensure correct CSV exporting
items = items.OrderBy(x => x.Location.X).ThenBy(x => x.Location.Y).ToList();
// Add them again in order
detailSection.Items.AddRange(items.Cast<ReportItemBase>().ToArray());

Where do you put that code?
The comments around the InitializeComponent procedure warn that it should not be modified. I tried to reorder the controls there, but if I modify the report from the designer, all my were lost.
I tried to add the code in the report after the InitializeComponent procedure is called, but it didn't make a difference with the ASCII file.

Oh, I figured it out.
The change needs to replace the existing AddRange code further down that InitializeComponent method.
So even though the comment mentions "do not modify the contents of this method with the code editor", we go ahead and do so anyway because this is the only way to change the order of the controls.
I noticed that after I made the change, the order of the controls at the top automatically changed to the new order I specified, so that's nice.

I figured it out.
The change needs to replace the existing AddRange code further down that InitializeComponent method.
So even though the comment mentions "do not modify the contents of this method with the code editor", we go ahead and do so anyway because this is the only way to change the order of the controls.
I noticed that after I made the change, the order of the controls at the top automatically changed to the new order I specified, so that's nice.

Hi all,
I just came across this issue and fortunately could mange to find a solution, I use stand along report designer, in the Report explorer window click Report explorer tab then you can reorder it from the details section.
Regards
Ari