I would like to export certain set of data downloadable for users as CVS file.
I can make the data visible as table as normal content.
Then I add the headers. (http://www.plus2net.com/php_tutorial/php_file_download.php)
What happens is that all menus etc. are part of the file.
How can I get rid of the "normal" drupal content - menus etc. and be left with the actual data?
This issue has been asked in many forus, but I found no answer:
There is also views_bonus module, but the export module seems to be missing from that one.
What I read the ability to export CVS would be enabled through that.
http://drupal.org/project/views_bonus
In my situation the "raw" php-solution would be the most efficient.
Perhaps another way to put the same question is that how one can call a funtion within same node and get a function executed?
That function would then display headers + data.
That would solve the issue.
Comments
I do this in a module the
I do this in a module the following way:
I have a function that handles both the display of the tabular data in a page and the download of the same data. I construct the array $data which contains the tabular data, with the column headings in $header. Then I use
$results = theme_table($header, $rows);to convert to HTML. I just return $results to have the table displayed in a page. For download, I useI found this works better than CSV if you have fields that can be interpreted as numbers but you don't want to be - e.g. numeric strings that begin with a 0. You have to add a space to the beginning of these - this prevents Excel interpreting the string as a number and stripping the leading 0.
If you want true CSV output then you shoud be able to modify the above accordingly. It should also work embedded within a page using PHP input format - you could use a query parameter ?download=1 or somesuch to distinguish the 2 cases.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Perfect answer!
Many thanks!
---------------------------------------------------------
Harjoituspäiväkirja - www.lenkkivihko.fi