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.105 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started