2

Please there're an esay way to Import date from excel file to database using php ?

I have made it by excel_reader2

but the last char don't load and I get problem with arabic language

This is my code

    <?php
require_once 'excel_reader2.php';
$data = new Spreadsheet_Excel_Reader($url);
$page_sheet = 1;
if(count($data->sheets[$page_sheet][cells])>0) // checking sheet not empty
{

    $rows = count($data->sheets[$page_sheet][cells]);

    for($j=5;$j<=count($data->sheets[$page_sheet][cells]);$j++) // loop used to get each row of the sheet
    {
        $data->sheets[$page_sheet][cells][$j][1];
        $rowid = $data->sheets[$page_sheet][cells][$j][1];
        $phone = $data->sheets[$page_sheet][cells][$j][2];
        $season = $data->sheets[$page_sheet][cells][$j][3];
        $row = $data->sheets[$page_sheet][cells][$j][4];
        $name = $data->sheets[$page_sheet][cells][$j][5];

       echo "$name<br />";
    }
}

Sorry for my bad english please

7
  • Do you get the last character if you add one to the count? for($j=5;$j<=count($data->sheets[$page_sheet][cells])+1;$j++) Commented Feb 5, 2016 at 6:51
  • This answer might help with displaying Arabic characters stackoverflow.com/questions/3666412/… which says:"To use a coding other than UTF-8 (default) you can pass it as the 3rd parameter. $data = new Spreadsheet_Excel_Reader("test.xls",true,"UTF-16");" Commented Feb 5, 2016 at 7:02
  • If you echo any of the other items are they all blank? Can you add any more information about what you do get out and what you expect to see? Commented Feb 5, 2016 at 20:50
  • This script seems to echo everything so at least you could see what you are getting. It also seems to cope with multiple sheets in a workbook phpgang.com/… This line without any $variable = might be a problem $data->sheets[$page_sheet][cells][$j][1]; at the top of your variables block - comment it out. Commented Feb 5, 2016 at 21:06
  • Have you tried $page_sheet = 0; ? Also this was recommended on the other page an looks to have better language handling PHPExcel: phpexcel.codeplex.com also on github.com/PHPOffice/PHPExcel Commented Feb 5, 2016 at 21:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.