Hi Ravi,

Since you already have the csv content generated you just want to send
it out with res.write() or res.end() depending upon whether you are
writing it out in chunks or not (streaming).

To get the CSV to be a downloadable file you need to add the
'content-type' and 'content-disposition' headers to your response:
 res.header('content-type','text/csv');
 res.header('content-disposition', 'attachment; filename=report.csv');

For more complex stuff, ya-csv looks useful.

-Andrew

On Wed, Jun 20, 2012 at 1:47 AM, Matthew Vickers <[email protected]> wrote:
> I have used ya-csv in the past, it works well for our basic usage.
>
> https://github.com/koles/ya-csv
>
> Matt
>
>
>
> ----- "ravi prakash" <[email protected]> wrote:
>
>> Hi group,
>>
>> How can i generate a excel/csv file from nodejs application. Say, I
>> have a link in webpage and on click of link, i query database and put
>> result into excel/csv file. Finally the file download  must be
>> opened.
>> I am building application using nodejs+express.
>>
>> My goal is to export data into a excel/csv file ie generate excel/csv
>> file from my application.
>>
>>
>> Say i have link in webpage -----
>>
>>       <a href='/report'>Export</a>
>>
>> Server side i have code ------
>>
>> app.get('/report', function(req, res) {
>>
>>    //get data from db
>>
>>    How to put data to csv/excel file ???
>>
>> }
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to