Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:41:11+00:00 2026-05-25T06:41:11+00:00

I have a web application that has a grid displaying a paged list of

  • 0

I have a web application that has a grid displaying a paged list of data to the user. The user needs the option to download the results to an Excel spreadsheet. However, the items displayed in the grid are, like I said, Paged and I need the whole result set. In addition, I’m only displaying about 7 fields per item, whereas the spreadsheet will contain all 20+ fields for an item. So, I’m not looking for a grid-to-Excel solution.

I’m trying to do something that I’ve actually worked with before. At a previous employer (source code not available), we had an application that contained SQL Server report as an RDLC file. We would create a ReportViewer control in code (var reportViewer = new ReportViewer()). Then, we would bind the report to the control, give it a datasource and then render the results in whatever format we needed. In my case I need an Excel File, and then stream the ExcelFile back to the user in the response.

I’m using MVC3, so I’ll be returning the Excel file as a FileContentResult. I’ve been searching the internet for a day and can’t quite find what I’m looking for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:41:11+00:00Added an answer on May 25, 2026 at 6:41 am

    Controller action. The format parameter should be ‘EXCEL’.

        public FileResult Report(String format)
        {
            LocalReport report = new LocalReport();
            report.ReportPath = Server.MapPath("~/TestReport.rdlc");
    
            report.DataSources.Clear();
            report.DataSources.Add(new ReportDataSource(GetData()));
    
            report.Refresh();
    
            return GetFileContentResult(report, format, null, "TestReport");
        }
    

    Helper method that creates a FileContentResult from any Report.

        public FileContentResult GetFileContentResult(Report report, String format, String deviceInfo, String fileDownloadName)
        {
            String mimeType;
            String encoding;
            String filenameExtension;
            String[] streamIds;
            Warning[] warnings;
    
            FileContentResult fileContentResult = new FileContentResult(report.Render(format, deviceInfo, out mimeType, out encoding, out filenameExtension, out streamIds, out warnings), mimeType);
            fileContentResult.FileDownloadName = Path.ChangeExtension(fileDownloadName, filenameExtension);
    
            return fileContentResult;
        }
    

    Edit: Forget to call the help function. Oops.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that has a requirement to take data from an
I have web application that is behind a proxy. If the user has logged
I have this web application that has grown to an unmanageable mess. I want
I have a web application that has a page that loads the content from
I have a web application that has one set of files used by 50+
I have a web application on ASP.NET (C#) that has some precompiled components. I've
I have a web application from a company that has gone out of business.
I have a particular web application that like most others, has to account for
I have a java application that has Web Services published using Axis. With the
I have a code base that has been used as an ASP.Net web application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.