Page 1 of 1

SOLVED: Using the CMSexcel module

Posted: Fri Oct 07, 2011 11:41 am
by Splynx
Hello

I am trying to export some data via a link to an excel sheet.

I have tried using some classes, but every time I export I get the whole admin page exported with it :-(

I have a link (this is backend BTW) pointing to a file like so:

$record->link_export = $this->CreateLink($id, 'list_export', $returnid, $icon_export, array('invitation_id'=>$record->id));

And in the file action.list_export.php I then try different stuff to get my SQL array exported - but every time I get the WHOLE admin page exported with it (as well as it does not format the data properly)

I have now imported the CMSexcel module - but I am at a loss on how to use it.

Can anyone show me a simple example on how to get my SQL data exported via a link? The help part of that module does not help me at all - any help would be appreciated - does not have to be that module (at the moment I am trying a 3rd party class)

Re: Using the CMSexcel module

Posted: Sun Oct 09, 2011 6:55 am
by Splynx
Found the solution to this

Code: Select all

$excel_db = &$gCms->GetDb();
	$excel_query = 'SELECT * from '.cms_db_prefix().'module_iminvitation_invited WHERE invitation_id = ?';
	$excel_result = $excel_db->Execute($excel_query, array($record->id));
	$aData = array();
	while ($excel_result !== false && $excel_row = $excel_result->FetchRow()) {
		$aData[] = $excel_row;
	}
	$excel_data = array('invitation' => $aData);
	$stack = $gCms->modules['CMSExcel']['object']->buildExcel($excel_data, $params = array());
	$record->link_export = $gCms->modules['CMSExcel']['object']->getExcelLink($stack,$params = array());
Where the $record->link_export is for the TPL file ofc - and to be treated as a normal link in the template.