$csv_rows = array();
//header
$csv_rows[] = array(t('#'), t('Customer'), t('Username'), t('Orders'), t('Products'), t('Total'), t('Average'));

//content: fetch data using while
$csv_rows[] = array($customer_number, $customer_order_name, $customer_name, $orders, $products, $total_revenue, $average_revenue);
//now data stored in array

$csv_data = uc_reports_store_csv('uc_customers', $csv_rows);
//uc_reports_store_csv is ubercart's function

//provide link for download file
l(t('Export to CSV file.'), 'admin/store/reports/getcsv/'. $csv_data['report'] .'/'. $csv_data['user'])

Advertisements