Welcome Guest, Not a member yet? Register   Sign In
PEAR
#1

[eluser]bhenry001[/eluser]
Is it possible to use a piece of the PEAR library in CodeIgniter? The Spreadsheet_Excel_Writer is what I have been looking for to export files to Excel. Exporting CVS or tab delimited files is too basic for my requirements. Thanks in advance.
Bruce
#2

[eluser]TheFuzzy0ne[/eluser]
I don't see why not. http://codeigniter.com/wiki/PEAR_integration/
#3

[eluser]bhenry001[/eluser]
Thanks! I just did a search and for some reason did not find anything. Just wanted to find out how difficult it would be. So far I have found everything so simple. Like integrating the PHPMailer. CodeIgniter is so sweet!
Bruce
#4

[eluser]alejandra[/eluser]
Hi,

I saw this post and I try to implement the solution describe http://codeigniter.com/wiki/PEAR_integration/

I downloaded the basic pear library and the Spreadsheet_Excel_Writer library and put then inside the pear folder as explain in the wiki but when I tested a I get an include error

My test function looks like this:


Code:
function example()
{
   $this->load->library('pearloader');
   $workbook = $this->pearloade->load('Spreadsheet_Excel_Writer','Writer');
   $workbook->send('test.xls');
        
   $worksheet->write(0, 0, 'Name');
   $worksheet->write(0, 1, 'Age');
   $worksheet->write(1, 0, 'John Smith');
   $worksheet->write(1, 1, 30);
   $worksheet->write(2, 0, 'Johann Schmidt');
   $worksheet->write(2, 1, 31);
   $worksheet->write(3, 0, 'Juan Herrera');
   $worksheet->write(3, 1, 32);
        
   // Let's send the file
   $workbook->close();
        
}


My Pearloader.php file look like this and is place inside the the libraries folder inside the application folder

Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Pearloader{
  function load($package, $class,$options = null){
   require_once('../pear/'$package.'/'.$class.'.php');
   $classname = $package."_".$class;
   if(is_null($options)){
  return new $classname();
   }else{
  return new $classname($options);
   }
  }
}

?>


I have place an image inside the Spreadsheet_Excel_Writer folder and try to access from another file using plain html and it worked (this was to check if I was giving the wrong file path), if try echoing the same image tag using php I get file not found…

Code:
<img src="../pear/Spreadsheet_Excel_Writer/image1.jpg">  //can view image
  
   &lt;?
       echo '<img src="../pear/Spreadsheet_Excel_Writer/image1.jpg">';  //can't view image
  
   ?&gt;

Help please… :-S
#5

[eluser]TheFuzzy0ne[/eluser]
You might want to consider specifying the src attribute path relative to the Web root, rather than the current URL. However, it looks like you might be trying to access images that are outside your Web root, which probably won't work.
#6

[eluser]alejandra[/eluser]
Yes I've changed it to

require_once('system/application/pear/Spreadsheet_Excel_Writer/Writer.php');

I don't know why it worked but is working, why is this?




Theme © iAndrew 2016 - Forum software by © MyBB