Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

export to csv / excel 03 Dec 2013 12:15 #11727

  • albert
  • albert's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 70
  • Thank you received: 2
Hi, normally in my old components I used the file view.raw.php to export to csv
so i did a link like this one on the default.php:
<a href="index.php?option=com_component&view=viewname&format=raw" target="_blank"><img src="components/com_component/assets/spreadsheet.png" align="right" alt="CSV" title="Export to CSV"></a>

and then on the view.raw.php
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view');

// PEAR include for generating Excel files
require_once( 'Spreadsheet/Excel/Writer.php' );

class ComponentNameViewViewName extends View
{
	var $_name = null;
	
	function __construct()
	{
		parent::__construct();
		$this->_name = 'view_report';
	}
	
	function display($tpl = null)
	{	
		$user =& JFactory::getUser();

		// report rows
		$items = array();
		
		// create excel file		
		$workbook = new Spreadsheet_Excel_Writer();
		$workbook->send("reports_" . date("Ymd") . ".xls");

		$items =& $this->get('data'); 

		if (count($items)) {
			$worksheet =& $wor
.
.
.
		$workbook->close();
		die;
	}
}
?>

Now, by using your component in 3.2 i try to put the link and the raw file and doesn't connect, could you help me please ?
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

export to csv / excel 06 Dec 2013 16:57 #11754

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Thanks !! really usefull !!
K++;
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

export to csv / excel 06 Dec 2013 19:37 #11760

  • albert
  • albert's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 70
  • Thank you received: 2
It WAS useful,
Can you help me in the link part?
I do not know why it does not reach the raw view.
Thanks

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.059 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started