Export to excel from Console app

Posted on 2013-06-04
Last Modified: 2013-06-05
Hello Experts,
I need to export string data to excel using console app (C#) without using any third party libraries...

i am getting object reference error...HttpContext.Current.Response.ClearContent();

here is my code so far...( i have it on class library project)

using System.Web;

 private void ExportToExcel(string strData)
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=BatchResponse.xls");
            HttpContext.Current.Response.ContentType = "application/excel";
            catch (Exception ex)
                log.LogExceptionError("Batch Settlement Process - ExportToExcel", ex);
                log = null;

Any help?

Question by:mani_sai
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 58

Accepted Solution

Julian Hansen earned 500 total points
ID: 39221291
Where is  HttpContext defined ?

As a matter of interest, if this is a console app why are you using Http to export to Excel ?

Author Closing Comment

ID: 39224395
Thanks. figured out the solution using StreamWriter.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question