Trying to use ExportEachPageToSheet inside code behind Report

Stimulsoft Reports.NET discussion
Post Reply
JorisVonG
Posts: 9
Joined: Tue Jul 24, 2018 10:52 am

Trying to use ExportEachPageToSheet inside code behind Report

Post by JorisVonG »

Hello,

I'm trying to get a report exported to multiple sheets. I know I can do this by hand when exporting en check the checkbox. But I want to do this automaticly.

I tried using the following code:

Code: Select all

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.Dialogs;
using Stimulsoft.Report.Components;

namespace Reports
{
    public class Report : Stimulsoft.Report.StiReport
    {
        public Report()        {
            this.InitializeComponent();
        }

        #region StiReport Designer generated code - do not modify
		#endregion StiReport Designer generated code - do not modify
		
		StiSettings.Load();
		StiSettings.Set("StiExcelExportSetupForm", "ExportEachPageToSheet", true);
		StiSettings.Save();
    }
}
Am I doing this right? If not can you please provide correct code to use?
Thanks!
Max Shamanov
Posts: 792
Joined: Tue Sep 07, 2021 10:11 am

Re: Trying to use ExportEachPageToSheet inside code behind Report

Post by Max Shamanov »

Hello,

If you want to export the report from code, you can use the following code to do so:

Code: Select all

	    StiExcel2007ExportSettings settings = new StiExcel2007ExportSettings();

            settings.ExportEachPageToSheet = true;

            StiReport report = new StiReport();
            report.Load("path to file");
            report.Render(false);
            report.ExportDocument(StiExportFormat.Excel, "stimulsoft2.xls", settings);
Thank you.
Post Reply