Welcome Guest, Not a member yet? Register   Sign In
Extract excel data using php
#1

[eluser]MASS MASS[/eluser]
Is it possible to extract excel(xls extension) data from php and CI....then that will stored in to our database
#2

[eluser]xwero[/eluser]
It depends on which kind of xls files you are dealing with, if you have to process older files i would suggest the excel reader library otherwise you can use the excel reader library found on the wiki.

They both act the same reading the files, they make an multidimensional array of the xls file. Then it is up to you how to store this array.
#3

[eluser]MASS MASS[/eluser]
Thanks for your suggestion .....already i got solution

better you go for the below link


http://sourceforge.net/project/showfiles..._id=106368


please download Spreadsheet_Excel_Reader.zip not phpExcelReader.zip

its working fine............
#4

[eluser]MASS MASS[/eluser]
again i am facing problem with this class


The filename excelfilename.xls is not readable........
#5

[eluser]xwero[/eluser]
How do you read it? I mean what is the code you use to read the xls
#6

[eluser]MASS MASS[/eluser]
http://sourceforge.net/project/showfiles..._id=106368

download from above link --> Spreadsheet_Excel_Reader.zip


i am using php code same as in below link .......please refer below link


http://www.simonshareef.com/article/read...-using-php
#7

[eluser]xwero[/eluser]
I never encountered problems using the same code.

Try to put the xls file in another directory or check if the file rights are sufficient. Those are the only two things i can think of that would cause this error.
#8

[eluser]MASS MASS[/eluser]
First thing i am taking uploaded file from users when upload the excel file ...
this is for upload file

$config['upload_path'] = './system/application/views/';
$config['allowed_types'] = 'xls';
$config['max_size']= '5000';
$config['max_width']= '2000';
$config['max_height']= '2000';
$this->load->library('upload', $config);
$this->upload->do_upload();
$file_upload = $this->upload->data();
$userfile = $file_upload['file_name'];
$arr_data['filename'] = $userfile;
$this->load->view('excel',$arr_data);

then i am using reader.php class to extract (view page)

$data = new Spreadsheet_Excel_Reader();
//print_r($data);

$data->setOutputEncoding('CP1251');


$data->read($filename);
error_reporting(E_ALL ^ E_NOTICE);

$total_row = $data->sheets[0]['numRows'];


$startRow = 1;
$cells = $data->sheets[0]['cells'];

echo "<table border='1' style='font-size:14px;font-family:Arial;'>
<tr><td align=center>email_id</td><td align=center>First Name</td><td align=center>lastname</td></tr>";

for ($row = $startRow;$row <= $total_row;$row++)
{
$email = $cells[$row][1];
$first_name = $cells[$row][2];
$last_name = $cells[$row][3];

/* Then display them */
echo "<tr><td>" . $email . "</td>";
echo "<td>" . $first_name . "</td>";
echo "<td>" . $last_name . "</td></tr>";

}

echo "</table>";


question is while uploading file whether i have to give permission to that xls file ......is it possible
#9

[eluser]xwero[/eluser]
I just wrapped the basic library code of CI around the reader.php file and i call the library like
Code:
$this->load->library('Excelreader');
$this->excelreader->setOutputEncoding('CP1251');
This probably doesn't matter, i think the problem is with the $filename variable. You need the full file path to read the xls file.

In the example code they assume the reader.php file and the xls are in the same directory.
#10

[eluser]MASS MASS[/eluser]
$filename variable not a problem .....be'coz if i echo that variable it will display file name correctly......it not a problem

code is working properly in case of other excel file ..............


only uploaded excel file are not working properly......what's the region




Theme © iAndrew 2016 - Forum software by © MyBB