See attached patch file.

Note that this patch also includes a little detection on the import, if the field name contains 'email' it will use email type, 'date' will use date type. Disregard whatever you don't like, just thought I'd post it in case you want to use it.

Would be nice to have it integrated so that it would be a part of the admin functionality.

Usage:

return tablemanager_display(1, NULL, false, array(), array('csvdump' => true));

Comments

mattsteven’s picture

I should also mention that (@@ -1647,6 +1667,12 @@) there's a sort of useless bit of code in there that I inserted when I was trying to use to fix the delete column problem. The patch should be picked over carefully, sorry about that.

robin t’s picture

Title: Patch for simple export to cvs function » Patch for simple export to csv function
StatusFileSize
new4.47 KB

Good work! I cleaned up your patch, fixed some crop'ing, and added proper \" escaping in the csv (my fingers can also only type cvs) output.
I also changed the default output to explicit typed output to support the selection type. I have not tested the other data types.
Content type is set to text/csv and opens fine in openoffice.

The usage of your patch is not quite apparent so here is a small tutorial of my usage:

Create a node showing the table normally:

[tablemanager:2,,true]
<br/><a href="/node/160">Export as CSV</a>

Create another node (this is 160 in my case) returning the CSV:

[tablemanager:2,,true,null,csvdump=1]

Once this node is created, it is only possible to edit via the path:
.../node/160/edit

Personally, I think the extra node is a kludge but it is not straight forward to render the table through an autogenerated link because the content is generated as a filter.
Consider a node with 2 tables or tables with non default display parameters...

pobster’s picture

Status: Needs review » Closed (fixed)

I'm not sure I'm keen on the code being applied to the display function? Anyways, it's all pretty irrelevant now - I've included an export csv function in the 6.x branch and when that's finished it'll be backported to 5.x - I'm going to close this issue as obviously the csv export function is complete and already working.

Pobster