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 8695111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:57:04+00:00 2026-06-13T00:57:04+00:00

I am trying to create an excel sheet in a code-behind and then download

  • 0

I am trying to create an excel sheet in a code-behind and then download it. I don’t want to save the file on the disk, I want to directly send it as a response, I tried the following code. But im not getting the exact excel.

Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;


            xlApp = new Excel.ApplicationClass();
            xlWorkBook = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            for (int i = 1; i <= 100; i++)
                for (int j = 1; j < 100; j++)
                    xlWorkSheet.Cells[i, j] = i + "  : " + j;

            Response.ContentType = "application/vnd.ms-excel";
            Response.AppendHeader("Content-Disposition", "attachment; filename=translationText.xls");
            this.EnableViewState = false;
            Response.Write(xlWorkSheet);
            Response.End();

            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);

How to send the excel worksheet object as the response. So, that user will be prompted to download the excel file

  • 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-13T00:57:05+00:00Added an answer on June 13, 2026 at 12:57 am
    Response.ContentType = "application/vnd.ms-excel";
    Response.AppendHeader("Content-Disposition", "attachment; filename=translationText.xls");
    Response.Write("<table>");
    for (int i = 1; i <= 100; i++)
    {
        Response.Write("<tr>");
        for (int j = 1; j < 100; j++)
        {
            Response.Write("<td>"+i + "  : " + j+"</td>");            
        }
        Response.Write("</tr>");
    }
    Response.Write("</table>");
    Response.Flush();
    Response.End();
    

    try the above code, you dont need to create an excel object here, if you are reading from an excel and then writing it is different code.

    well the different code to read and write the excel file to the browser is by

    Response.BinaryWrite(yourexcelstream)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an excel file and make that available as download. But
I am trying to create dynamic excel sheet, with the help of php using
I'm trying to create a multi-sheet excel document, and thus far I'd been doing
I'm trying to create an Excel file with C# COM interop but seems it
I am trying to send an OOXML Excel file to the browser based on
I am trying to create an Excel sheet using the Spreadsheet_Excel_Writer that comes with
I am trying to get data from Excel File to DataTable. Here's my code-snippet
I am trying to create an Excel Connection Manager from an Excel file that
I'm trying to create a new Excel file using jxl, but am having a
I am beginner to Apache POI api. I am trying to create excel sheet

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.