Tag property & export to CSV

Stimulsoft Reports.NET discussion
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Tag property & export to CSV

Post by NicolasM »

Hello,

I started to use StimulSoft few weeks ago, with C# and BO.

Now I try to generate an export to CSV format. But I have a problem: when the file was generated, the first line contains: "Table_Cell5,Table_Cell6,Table_Cell7,Table_Cell8" and not my header (create with anothers Table_Cell).

So how can I have the header into the first line of my CSV file ?

I found this: http://forum.stimulsoft.com/viewtopic.php?t=649
But here, the Tag property is used and I don't know how to change it with the Designer. Can you explain me how to do, please ?

Thanks in advance for your help !
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Tag property & export to CSV

Post by Ivan »

Hello,

By default in Csv, Dbf and Xml exports only textboxes from DataBand are exported ("only data"). The default name of column corresponds to the name of the textbox.
If you want another name of column, you should rename textbox or write in the Tag property of textbox the following expression:

Code: Select all

CSV: "NameCsv"; DBF: "NameDBF"; XML: "NameXml"; Default: "NameDefaultForCsvAndDbfAndXml"; 
Please check the screenshot in attachment for information how to set the Tag property of the component.

If you use the version 2015.2 or later, you also can do the following workaround:
In the export settings menu you can set the "Bands Filter" property to the "Data and Headers/Footers", and check the "Skip Column Headers" option.
Now text from header will be exported as column headers.

Thank you.
Attachments
export_settings.png
export_settings.png (27.59 KiB) Viewed 5023 times
tag_property.png
tag_property.png (167.03 KiB) Viewed 5023 times
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Re: Tag property & export to CSV

Post by NicolasM »

Hello Ivan,

Thanks a lot for your help !

I cannot use the second method beacause I use the 2014 3.0 version. But the first method works fine ! Thanks to show me where I can edit Tag property, it's very useful.

During testing, I found a problem with this method: Report.ExportDocument(StiCsvExportService, string)
When I try to use this method, I have an exception: The incorrect type of the settings argument is used. The StiCsvExportSettings is need to be used.

Is it a bug ? Or I don't well using this methods ?

Code: Select all

Stimulsoft.Report.StiReport report = this.stiDesignerControl.Report;
report.Render(true);

// Get filepath
string filepath = GetFilePath("CSV File|*.csv");

// Export document
StiCsvExportService service = new StiCsvExportService();
report.ExportDocument(service, filepath);

// Open document
System.Diagnostics.Process.Start(filepath);
Thanks again for your help.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Tag property & export to CSV

Post by Alex K. »

Hello,

Please try to check the last build and let us know about the result.

Thank you.
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Re: Tag property & export to CSV

Post by NicolasM »

Hello Aleksey,

Thank you for your reply. Unfortunately, I think I just have a licence, not a subscription.

Thanks.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Tag property & export to CSV

Post by Ivan »

Hello,

Please try to modify your code:

Code: Select all

// Export document
StiCsvExportSettings settings = new StiCsvExportSettings();
rep.ExportDocument(StiExportFormat.Csv, filepath, settings);
Thank you.
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Re: Tag property & export to CSV

Post by NicolasM »

Hello Ivan,

Thanks for your reply.

Your code works but user cannot edit setting like with StiCsvExportService. Or I can use StiCsvExportService bialog box to get a StiCsvExportSettings?

Thanks for your help (and sorry for this later answer).
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Tag property & export to CSV

Post by HighAley »

Hello.

Yes, please, try to use next code to export the report:

Code: Select all

StiCsvExportService service = new StiCsvExportService();
service .Export(report, filepath);
Thank you.
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Re: Tag property & export to CSV

Post by NicolasM »

Hello HighAley,

Thanks for your help.

Unfortunately I have the same error with this code: The incorrect type of the 'settings' argument is used. The StiCsvExportSettings is need to be used.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Tag property & export to CSV

Post by Alex K. »

Hello,

The issue is fixed in the last build. Please try to check the build 2016.1.8 from 2016.04.15.

Thank you.
Post Reply