Hide DataBand or Table when export to CSV

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

Hide DataBand or Table when export to CSV

Post by NicolasM »

Hello,

I would like to know if it's possible to hide entire DataBand or table object when exporting to CSV format. Maybe by using tag??

Thanks in advance.

Niko
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Hide DataBand or Table when export to CSV

Post by Alex K. »

Hello,

As a way, you can use the additional code in the Exporting event of the report for disabling necessary component.
For example:

Code: Select all

DataBand1.Enabled = false;
this.Render(false);
Thank you.
NicolasM
Posts: 23
Joined: Tue Mar 08, 2016 1:53 pm

Re: Hide DataBand or Table when export to CSV

Post by NicolasM »

Hello Aleksey,

Thank you for your help. Works fine! I create a generic method for all my reports with this.
If anyone needs (my main table is called 'Table'):

Code: Select all

/// <summary> 
/// This method can be used before Render() to prepare report for CSV export. All components except 'Table' is disabled.
/// </summary>
public void PrepareForCsvExport()
{
    StiComponentsCollection stiColl = _stiReport.GetComponents();

    foreach( StiComponent comp in stiColl )
    {
        if( comp.ToolboxCategory == StiToolboxCategory.Bands )
        {
            if( comp.Name != "Table" ) comp.Enabled = false;
        }
    }
}
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Hide DataBand or Table when export to CSV

Post by Alex K. »

Hello

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply