node csv

想实现下载csv文件的功能,内容放在mysql的blob中,在网上找的都是关于csv模块的。

 

由于csv的更新,网上的很多方法都用不了,比如csv(),现在已经变了:http://csv.adaltas.com/csv/examples/

通过sudo npm install csv安装的csv模块,里面的example也是上述网址中得example。

 

后来想想,当时把csv的内容直接存到blob中,现在把它拿出来,直接下载就好,应该不需要通过csv来处理,可以试一下。

 

下载csv:http://www.nodeclass.com/articles/89571

var filename = 'sfp.csv';
res.set({
     // 文件扩展名:.xls 'Content-Type': 'application/vnd.ms-excel',
     // 当用户想把请求所得的内容存为一个文件的时候提供一个默认的文件名 'Content-Disposition': 'attachment;filename='+filename,
     //关于Pragma:no-cache,跟Cache-Control: no-cache相同。Pragma: no-cache兼容http 1.0 ,Cache-Control: no-cache是http 1.1提供的。因此,Pragma: no-cache可以应用到http 1.0 和http 1.1,而Cache-Control: no-cache只能应用于http 1.1. 'Pragma': 'no-cache', 'Expires': 0,
     'Cache-Control': 'No-cache' }); var str = 'Male,Female \n 54.,43. \n 23.,34. \n 45.,65. \n 54.,77. \n 45.,46. \n ,65.'; res.send(str);

  

posted on 2015-09-26 15:33  j.w  阅读(555)  评论(0编辑  收藏  举报