> On Feb 8, 2016, at 4:50 AM, ajay jaiswal <[email protected]> wrote: > > I am firing query to database and getting in json format . > I want to send it to client (browser) using express js. > but i am not getting the data in browser. > > app.post("/downloadImportedTable", function (req, res) { > var connection = new sql.Connection(dbConfig, function (err) { > > var dbObject = req.body.tableName; > if (err) { > res.status(500).send(String(err)); > } else { > // Query > var sqlrequest = new sql.Request(connection); > sqlrequest.query('select * from ' + dbObject, function (err, > recordset) { > > if (err) { > res.status(500).send(String(err)); > connection.close(); > } else { > //console.log(recordset);-----> it successfully fetch the > data > > res.set({ 'Content - Type': 'application/ms-excel; > charset = UTF - 8' }); > res.status(200).send(recordset); > > connection.close(); > > > }; > }); > } > }); > }; > > > The recored set contains millions of record so if i convert it using npm > json2xls it makes busy the browser and server to converting json into xlsx > .so this approach i don't want to use.
So what approach do you want to use, then? Your code above appears to get an array of data from the database and send that array directly to the browser, without any conversion. You're at minimum going to have to convert the array to some kind of text. For example, you could convert it to JSON. (Possibly node does so for you automatically; I'm not sure.) But JSON of course is not Excel-format. If you want to send in a format Excel can open, I don't see an alternative to the solution you don't want, which is to have the server convert the data to Excel format using some module. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/78A1B89A-66C8-40FD-B883-C369AAEFB277%40ryandesign.com. For more options, visit https://groups.google.com/d/optout.
