Detecting Excel Export from Report

Stimulsoft Reports.NET discussion
Post Reply
simonwhitty
Posts: 2
Joined: Wed Feb 11, 2015 6:52 pm

Detecting Excel Export from Report

Post by simonwhitty »

Hi Guys.
We are exporting the report to Excel from the Preview Window and they would like a new page triggered only during export. I have tried using the this.IsExporting, called from various events on the page with no luck.

Can i confirm that the report is not recompiled when exporting from the preview window? - that it exports as seen on screen?

Thanks
Simon :)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Detecting Excel Export from Report

Post by HighAley »

Hello, Simon.

Yes, the report is not recompiled when exporting. You could do any changes in report at the Exporting event of the report and call Render method.

Thank you.
simonwhitty
Posts: 2
Joined: Wed Feb 11, 2015 6:52 pm

Re: Detecting Excel Export from Report

Post by simonwhitty »

Thanks Aleksey, Thats Great! :D
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Detecting Excel Export from Report

Post by HighAley »

Hello.

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

Thank you.
bdayakarreddy
Posts: 7
Joined: Wed Jan 25, 2023 6:20 am

Re: Detecting Excel Export from Report

Post by bdayakarreddy »

Hi Team,

We save the report some times as pdf or some times as excel or etc.
how do we detect the selected export type in the .net ExportReport endpoint ? i shared screenshot and .net server side code, currently the code supports Excel export only, i want to make it generic to support all the types which are in screenshot.

We are using below npm packges in angular
"stimulsoft-designer-angular": "2023.3.4",
"stimulsoft-viewer-angular": "2023.3.4",


for Server side we are using Stimulsoft.Reports.Angular.NetCore 2023.1.5.


/// <summary>
/// Handles Report Export Event.
/// </summary>
/// <returns></returns>
[HttpPost("exportReport", Name = "ExportReport")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> ExportReport()
{
var requestParams = StiAngularViewer.GetRequestParams(this);
if (requestParams.Action == StiAction.ExportReport)
{
StiReport report = StiAngularViewer.GetReportObject(this);
if (report != null)
{
report.ReportName = $"{report.ReportName}_{DateTime.UtcNow.ToString("yyyyMMddHHmm")}";
}
}

//var settings = new StiPdfExportSettings
//{
// UserAccessPrivileges = StiUserAccessPrivileges.All,
// EmbeddedFonts = false,
// UseUnicode = false,
// StandardPdfFonts = true
//};

var settings = new StiExcelExportSettings();

return await StiAngularViewer.ExportReportResultAsync(this, settings).ConfigureAwait(false);
}
Attachments
Save as .png
Save as .png (24.46 KiB) Viewed 4332 times
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Detecting Excel Export from Report

Post by Lech Kulikowski »

Hello,

> i want to make it generic to support all the types which are in screenshot.

Sorry, we did not exactly understand your question. Could you explain your task in more detail?

Thank you.
bdayakarreddy
Posts: 7
Joined: Wed Jan 25, 2023 6:20 am

Re: Detecting Excel Export from Report

Post by bdayakarreddy »

Hi Lech,

Query 1
I want to know whether user exporting the report as pdf or excel or etc? i want to identify the export type in below .net ExportReport endpoint.


public IActionResult ExportReport()
{

// Some code before export

// ...

return StiAngularViewer.ExportReportResult(this);
}


https://www.stimulsoft.com/en/documenta ... export.htm



Query 2
I also want to hide the export type HTML. but below options does not work. it still shows the HTML export type when viewing the report.

options.Exports.ShowExportToHtml = false;
options.Exports.ShowExportToHtml5 = false;
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Detecting Excel Export from Report

Post by Lech Kulikowski »

Hello,

We need some time to check this possibility, we will keep you informed about the outcome as soon as possible.

Thank you.
Vadim
Posts: 409
Joined: Tue Apr 23, 2013 11:23 am

Re: Detecting Excel Export from Report

Post by Vadim »

Hello.
1.
In StiRequestParams object you will get necessary information
public IActionResult ExportReport()
{
var requestParams = StiAngularViewer.GetRequestParams(this);

2. Also you need to hide options.Exports.ShowExportToMht = false;
Post Reply