This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
only one entry export?
Started 15 years ago by turischt | 4 posts |
-
hi,
how can I export only one or two entries, not the hole entries in de export function?
thanks
Posted 15 years ago # -
Hi,
I'm afraid there is no option to export one or two entries.
You might want to print the entry and then save it as PDF instead.MachForm Founder
Posted 15 years ago # -
ou thats bad ;-(
Posted 15 years ago # -
Having just purchased this software I found myself in need of a similar mechanism and though this topic has not been touched in a year perhaps the information may be useful to others.
Note that this requires some coding modifications in PHP so if you are not familiar with the language I would advise against attempting the procedure.
This method allows exporting of a single form to an excel sheet formatted similarly to entry view within the Mach form system.
First make a copy of export_entries.php found in the root of your Mach installation and rename it to something, say export_entries2.php.
Next, open your view_entry.php file located in the Mach install directory and navigate to the bottom of the file. Right before the ending insert the following:
<li><img src="images/icons/page_excel.gif" align="absmiddle" /> <a href="export_entries2.php?id=<?php echo $form_id; ?>&type=xls&entryid=<?php echo $entry_id; ?>" class="big_dotted_link">Export</a></li>
This will provide a link for you to click on from the view form page which will allow exporting of the data, but before it will actually work we need to modify our newly create export_entries2.php.
Open export_entries2.php and right below line 24 which is below the connect_db function and houses the gathering of posted variables add this line:
$entry_id = (int) trim($_GET['entryid']); // passed from view_entry2.php
Next, around line 254, under the section 'get form entries' modify the query to the following:
$query = "select * from <code>ap_form_{$form_id}</code> where id=$entry_id order by id asc";
Finally, we have to swap some variables around in the xls formatting functions to split the data into rows first rather than columns. Look for this around line 336 where it states if($type == 'xls').
if($type == 'xls'){ //print column header if(!$column_label_has_printed){ $i=0; foreach ($column_label as $label){ $worksheet->write($i, 0, $label,$format_bold); $i++; } $column_label_has_printed = true; } //print column data foreach ($form_data as $row_data){ $col_num = 0; foreach ($row_data as $data){ if(empty($file_url[$row_num-1][$col_num])){ $worksheet->write($col_num, 1, $data); }else{ $worksheet->writeUrl($col_num,1,$file_url[$row_num-1][$col_num],$data); } $col_num++; } } }
Note that we could use the same variable swapping to make this work with csv exports but I was only interested in Excel at the time of this hack. Also you may notice that I didn't actually change the variable names so even though they say column they are actually referring to rows because of the order of the variables passed to $worksheet->write.
One final bit, the bbcode in this forum seems to be adding extra
entries occasionally
, I'm not sure if I'm doing something wrong or the system is just wacky. Just be aware if you're pasting this directly that those tags are not supposed to be there!Hope this helps someone!
-Rafe Magnuson
Posted 14 years ago #
Reply
You must log in to post.