ilich / MvcReportViewer

ASP.NET MVC Html Helpers for ReportViewer Control.
MIT License
280 stars 131 forks source link

MvcReportViewer change export filename with default export button #162

Open cuongbk81 opened 8 years ago

cuongbk81 commented 8 years ago

I use mvcreportviewer for my solution, i config as:

@Html.MvcReportViewerFluent("App_Data/Report/TestReport.rdlc").ProcessingMode(ProcessingMode.Local).ReportParameters(new { ReportName = Model.ReportName, Province = Model.Province }).LocalDataSource("TestDataset", Model.Data).ControlSettings(settings).Attributes(new { Height = 750, Width = "100%", style = "border: none" })

I want use default export button of viewer and i want to change export filename with timestamp. Now, export filename is "TestReport", that isn't meaning. Please help me!

P/s: i don't want to create new action Excel Download as:

private ActionResult DownloadReport(ReportFormat format, bool isLocalReport, string filename = null) { if (isLocalReport) { return this.Report( format, LocalReportName, new { Parameter1 = "Test", Parameter2 = 123 }, ProcessingMode.Local, new Dictionary<string, DataTable> { { "Products", LocalData.GetProducts() }, { "Cities", LocalData.GetCities() } }, filename); }

        return this.Report(
            format,
            RemoteReportName,
            new { Parameter1 = "Hello World!", Parameter2 = DateTime.Now, Parameter3 = 12345, Parameter4 = (DateTime?)null },
            filename: filename);
    }
splendid25 commented 8 years ago

Hi, I also would like to modify the generated filename.

I managed to do it like like this in ReportViewerExtensions.cs :

In SetupLocalProcessing : if (parameters?.ControlSettings?.DisplayName != null) localReport.DisplayName = parameters.ControlSettings.DisplayName; In SetupRemoteProcessing : if (parameters?.ControlSettings?.DisplayName != null) serverReport.DisplayName = parameters.ControlSettings.DisplayName; And in ControlSettings.cs : public string DisplayName { get; set; }

Could you add it to the next NuGet package? Thanks

vivekcpatel commented 7 years ago

I also would like to have a different report name when user clicks on export button. How could i do that?

ilich commented 7 years ago

I do not think you can change the report name whn uer clicks export button. This is the part of the original report viewer web control.

Could you send me a pull request for the proposed features, please?

sven5 commented 7 years ago

It is possible to change the report file name through JavaScript. I'm currently using this because of the missing DisplayName property in 0.8.3. This is kind of a hack. I'm looking forward to have the DisplayName property in 0.8.4

Thanks Sven