| 
 | 
  syawqy - 2012-05-21 06:44:20  
i'm using codeigniter, i want to read data from xlsx and show it in browser 
and i got this error, but below this error i can see my data printed in browser 
sorry for my bad english 
 
A PHP Error was encountered 
 
Severity: Warning 
 
Message: fclose() expects parameter 1 to be resource, boolean given 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 193 
A PHP Error was encountered 
 
Severity: Notice 
 
Message: Undefined offset: 1 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 198 
A PHP Error was encountered 
 
Severity: Warning 
 
Message: unpack() [function.unpack]: Type x: not enough input, need 1, have 0 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 198 
A PHP Error was encountered 
 
Severity: Notice 
 
Message: Undefined offset: 1 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 199 
A PHP Error was encountered 
 
Severity: Notice 
 
Message: Trying to get property of non-object 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 348 
A PHP Error was encountered 
 
Severity: Warning 
 
Message: Invalid argument supplied for foreach() 
 
Filename: libraries/simplexlsx.php 
 
Line Number: 348 
 
  
  Sergey Shuchkin - 2012-05-21 10:26:52 -  In reply to message 1 from syawqy 
file (xlsx) not found! check file name 
  
  syawqy - 2012-05-21 12:44:55 -  In reply to message 2 from Sergey Shuchkin 
thx for your answer, but i think it's not about filename because i still get the result, anyway here's my code, is there anything wrong with it? please tell me.. thx 
 
function read() 
	{ 
		$config['upload_path'] = './temp_upload/'; 
		$config['allowed_types'] = 'xls|xlsx'; 
		$this->load->library('upload',$config); 
		 
		 
		if($this->upload->do_upload()) 
		{ 
			$du = $this->upload->data(); 
			var_dump($du['full_path']); 
			$data = @new SimpleXLSX($du['full_path']); 
			 
			$tes = $data->rows(); 
			//var_dump($tes); 
			 
			echo '<table cellpadding="10"> 
			<tr><td valign="top">'; 
 
			// output worsheet 1 
 
			list($num_cols, $num_rows) = $data->dimension(); 
 
			echo '<h1>Sheet 1</h1>'; 
			echo '<table>'; 
			$row = 0; 
			foreach( $data->rows() as $r ) { 
				echo '<tr>'; 
				for( $i=0; $i < $num_cols; $i++ ) 
				{ 
					if($row != 0 && ($i == 0 or $i == 13 or $i == 14)) { echo '<td>'.( (!empty($r[$i])) ? date('Y-m-d', $data->unixstamp($r[$i])) : ' ' ).'</td>'; } 
					else { 
					echo '<td>'.( (!empty($r[$i])) ? $r[$i] : ' ' ).'</td>'; } 
				} 
				echo '</tr>'; 
				$row++; 
			} 
			echo '</table>'; 
			 
			//unlink($du['full_path']); 
			 
			$this->load->view('exel'); 
  
  syawqy - 2012-05-23 17:46:11 -  In reply to message 3 from syawqy 
problem resolved, i just add custom function to read the file and make the constructor so it not required parameter because how CI loading library, i had to modified it like this 
 
here it is what i change from the original 
 
function __construct() { //remove the parameter 
		//$this->_unzip( $filename ); 
		//$this->_parse(); 
	} 
 
function read($filename) { //custom function to read file 
		$this->_unzip( $filename ); 
		$this->_parse(); 
	} 
  
   |