Page 1 of 1

Trying to use ExportEachPageToSheet inside code behind Report

Posted: Tue Jul 04, 2023 1:52 pm
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!

Re: Trying to use ExportEachPageToSheet inside code behind Report

Posted: Wed Jul 05, 2023 7:52 am
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.