GithubHelp home page GithubHelp logo

express-csv's People

Contributors

mblackshaw avatar nulltask avatar thrackle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

express-csv's Issues

line breakk

Having problems with line breaks, blank spaces between lines on Excel. How to solve that?

Not working on [email protected]

I'm using [email protected] for an old project. This library don't add .csv method to the right response object for this version of express.

express.response and http.ServerResponse are both available for this version, but express actually uses http.ServerResponse. So you only add .csv method on the first object, and the test passed for that reason.

Convert monkey-patching into middleware

It'd be great to have this as middleware which would add to res object the csv method.

For example:

var expressCsv = require('express-csv')

// ...

app.use(expressCsv)

// ... or only apply it to some routes ...

app.get('/some-route', expressCsv, function(req, res, next) {
  res.csv([ { a: 1, b: 2 } ])
})

Exporting array of objects, some rows have columns in a different order...

Hi,

Many thanks for this package - very useful.

I am using it to convert an array of objects, most come out ok, columns in the same order, but a few come out with the columns jumbled up - relative to the rest.

Looking at the code, it just iterates over the properties to convert it into an array.

Any plans to try to make it more consistent?

Perhaps look at the first object and then use that to determine the fields to use for the others. Although that assumes that they are all the same...

Cheers,
Chris

Bring up-to-date with Express 4.x

This package doesn't fully work with express 4.x (haven't tested other versions). More specifically, the sending of headers and status is not working, and deprecated respectively.

Fixing this is fairly easy:

Replace this.header('Content-Type', 'text/csv'); with this.set('Content-Type', 'text/csv');
and return this.send(body, headers, status); with:

this.set(headers);
return this.status(status).send(body);

Error exporting object data

Getting a strange output in the Excel CSV file:

[object Object]|"false"||"0"|"[object Object]"|"[object Object]"|"[object Object]"|"function () {
var self = this
, hookArgs // arguments eventually passed to the hook - are mutable
, lastArg = arguments[arguments.length-1]
, pres = this._pres[name]
, posts = this.posts[name]
, total = pres.length
, current = -1
, asyncsLeft = proto[name].numAsyncPres
, next = function () {
if (arguments[0] instanceof Error) {
return handleError(arguments[0]);
}
var args = Array.prototype.slice.call(arguments)
, currPre
, preArgs;
if (args.length && !(arguments[0] == null && typeof lastArg === 'function'))
hookArgs = args;
if (++current < total) {
currPre = pres[current]
if (currPre.isAsync && currPre.length < 2)
throw new Error(""Your pre must have next and done arguments -- e.g., function (next, done, ...)"");
if (currPre.length < 1)
throw new Error(""Your pre must have a next argument -- e.g., function (next, ...)"");
preArgs = (currPre.isAsync
? [once(next), once(asyncsDone)]
: [once(next)]).concat(hookArgs);
return currPre.apply(self, preArgs);
} else if (!proto[name].numAsyncPres) {
return done.apply(self, hookArgs);
}
}
, done = function () {
var args
= Array.prototype.slice.call(arguments)
, ret, total
, current
, next
, done
, postArgs;
if (current === total) {
ret = fn.apply(self, args
);
total
= posts.length;
current
= -1;
next
= function () {
if (arguments[0] instanceof Error) {
return handleError(arguments[0]);
}
var args
= Array.prototype.slice.call(arguments, 1)
, currPost
, postArgs;
if (args
.length) hookArgs = args
;
if (++current
< total
) {
currPost = posts[current
]
if (currPost.length < 1)
throw new Error(""Your post must have a next argument -- e.g., function (next, ...)"");
postArgs = [once(next
)].concat(hookArgs);
return currPost.apply(self, postArgs);
}
};
if (total
) return next
();
return ret;
}
};
if (_asyncsLeft) {
function _asyncsDone (err) {
if (err && err instanceof Error) {
return handleError(err);
}
--_asyncsLeft || _done.apply(self, hookArgs);
}
}
function handleError (err) {
if ('function' == typeof lastArg)
return lastArg(err);
if (errorCb) return errorCb.call(self, err);
throw err;
}
return _next.apply(this, arguments);
}"|"[object Object]"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.