Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6531483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:53:00+00:00 2026-05-25T09:53:00+00:00

I found the PHPExcel library brilliant to manipulate Excel files with PHP (read, write,

  • 0

I found the PHPExcel library brilliant to manipulate Excel files with PHP (read, write, and so on).

But nowhere in the documentation is explained how to read a XLSX worksheet to feed a MySQL table…

Sorry for this silly question, but i need it for my work and found no answer on the web.

A small example could be very helpful.

Thanks a lot.

UPDATED :

I precise my question :

The only part of code i found in the documentation that could help me is to read an Excel file and display it in a HTML table :

`require_once 'phpexcel/Classes/PHPExcel.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);

$objPHPExcel = $objReader->load("edf/equipement.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();

$highestRow = $objWorksheet->getHighestRow(); 
$highestColumn = $objWorksheet->getHighestColumn(); 

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); 

echo '<table border="1">' . "\n";
for ($row = 1; $row <= $highestRow; ++$row) {
  echo '<tr>' . "\n";

  for ($col = 0; $col <= $highestColumnIndex; ++$col) {
    echo '<td>' . $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() . '</td>' . "\n";
  }

  echo '</tr>' . "\n";
}
echo '</table>' . "\n";`

I know i can use the loop to feed my MySQL table, but i don’t know how… I’m not aware in OOP…

Can somebody help me, please ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:53:01+00:00Added an answer on May 25, 2026 at 9:53 am

    The first for loops through rows, and the second one loops through columns.
    So, there are plenty of solutions to your “problem”.

    You could, for example, populate an array and make an insert statement for each row.
    As the following :

    $rows = array();
    for ($row = 1; $row <= $highestRow; ++$row) {
      for ($col = 0; $col <= $highestColumnIndex; ++$col) {
        $rows[$col] = mysql_real_espace_string($objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
      }
    
      mysql_query("INSERT INTO your_table (col1,col2) VALUES ($rows[1],$rows[2])");
    }
    

    Obviously, this code can be improved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to play with excel sheet in PHP. So i found out PHPExcel
i'm trying to read some excel files with phpexcel, which works ok so far.
I'm using getCalculatedValue() in my PHPExcel to read 34 Excel files. Unfortunately there were
Found the documentation here http://www.trirand.com/jqgridwiki/doku.php?id=wiki:toolbar_searching I want JQgrid filterToolbar blank top row in the
Found this here http://sla.ckers.org/forum/read.php?2,15812,page=2 If you copy the title of the question and run
I have built an Excel document using the PHPExcel Library. My document opens and
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
I found this open-source library that I want to use in my Java application.
I found What are mvp and mvc and what is the difference but it
I have a PHP script that will generate a report using PHPExcel from data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.