Solve different browser download file name garbled var useragent = (req.headers[' user-agent ']| | "). toLowerCase (); Res.set (' Content-type ', ' application/octet-stream;charset=utf-8 '); if (Useragent.indexof (' MSIE ') >= 0 | | Useragent.indexof (' Chrome ') >= 0) { res.setheader (' content-disposition ', ' attachment; Filename= ' + encodeURIComponent (filename));} else if (useragent.indexof (' Firefox ') >= 0) { res.setheader (' content-disposition ', ' attachment; filename*= ') Utf8\ ' \ ' + encodeuricomponent (filename) + ' "');} else { res.setheader (' content-disposition ', ' attachment; Filename= ' + new Buffer (filename). toString (' binary '));} Solve Excel open content garbled var databuffer = buffer.concat ([New Buffer (' \xef\xbb\xbf ', ' binary '), new buffer (data)]); Res.send ( DataBuffer);
Original address: http://imziv.com/blog/article/read.htm?id=55
NodeJS CSV export file name and content garbled resolution