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.356 seconds

For starters it's just so easy to design an app in a way that I'm used to i.e. database first then views followed by customization. The fork system is pure brilliance from a developer standpoint as I can override things and still add and update my projects with minimal effort! Truly amazing to be able to build components in Joomla using incremental refinement without having to do everything by hand. Thanks for the great tool! I am so much more productive now than ever and I can't imagine building components any other way!!!!
Dave (Forum)

Get Started