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

  • SEARCH
  • Home
  • 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 9180659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:06:35+00:00 2026-06-17T18:06:35+00:00

The following code accesses a helper method which creates and returns an EPPlus ExcelPackage,

  • 0

The following code accesses a helper method which creates and returns an EPPlus ExcelPackage, then returns the package to the browser:

public ActionResult DownloadMatrixExcel(int projectId)
        {
            try
            {
                // Get project details
                var project = (from p in db.Projects
                               where p.ProjectId == projectId
                               select new
                               {
                                   companyName = p.Company.Name,
                                   projectName = p.Name
                               }).Single();

                // Must append file type to file download responses
                var fileName = project.projectName + "-" + project.companyName + "-" + DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture) + ".xlsx";

                // Configure response
                Response.Clear();
                Response.BufferOutput = false;
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);

                // Create and populate excel package
                var matrixSpreadsheet = ExcelHelper.BuildMatrixExcel(projectId);
                matrixSpreadsheet.SaveAs(Response.OutputStream);

            }
            catch (Exception e)
            {
                return Content("Error: " + e.Message);
            }

            // Download okay - No ViewResult
            return new EmptyResult();
        } 

Works fine in every browser I have tested but FireFox 18.0.1 (have yet to test other FF versions) trims the file name at the first space, so “someproject – somecompany – thedate” is just “someproject”. I can do a Replace and remove spaces but this makes some file names look a bit odd. File extension seems to be intact and no other issues but wondered if anyone could offer an explanation or fix?

  • 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-06-17T18:06:36+00:00Added an answer on June 17, 2026 at 6:06 pm

    Okay, found the answer here while researching another issue: File Download issue in FireFox only

    Response.AddHeader("Content-Disposition", 
                        string.Format("attachment; filename = \"{0}\"",
                        System.IO.Path.GetFileName(FileName)));
    

    This will also give the file the correct content type when you choose to save rather than open in browser in FireFox.

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

Sidebar

Related Questions

I have the following code on my site, which when it accesses Twitter's API
Following code is generated by a for loop. <form action=saveresponse.php method=POST name=mainForm> <input class=cbox_yes
Following code iterates through many data-rows, calcs some score per row and then sorts
The following code accesses a servlet's name: servletConfig.getServletName() . Can I access a servlet's
I see the following code fragment in a legacy application that accesses Informix through
Consider the following method signature: public static bool TryGetPolls(out List<Poll> polls, out string errorMessage)
The following code says that passing the map as const into the operator[] method
I have the following code (below) in my app, which simply tries to use
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to

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.