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

  • Home
  • SEARCH
  • 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 7167581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:36:20+00:00 2026-05-28T14:36:20+00:00

it is about a for loop problem for ($row = 1; $row <= $highestRow;

  • 0

it is about a for loop problem

for ($row = 1; $row <= $highestRow; $row++) {
    echo "<tr>";
    for ($column = 0; $column < $highestColumn; $column++) {
        $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();
        echo "<td>";
        //echo $val;
        echo $row,$column;
        echo "</td>";
  }
  echo "</tr>";
}

the highest row and highestcolumn are both are 4 in this case
OUTPUT:

test.xlsx

Import from spreadsheet files

Unname coloum 0  Unname coloum 1  Unname coloum 2  Unname coloum 3  
    13                   13               13                13
    23                   23               23                23
    33                   33               33                33
    43                   43               43                43

the value of column is 3 and never change( it should at least be 0?) , i haven’t initialize it before, it is strange

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../style/form1.css" />
    <script type="text/javascript" src="../plugin/easyui/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../plugin/easyui/jquery.easyui.min.js"></script>
    </script>
</head>
<body>


<?
session_start();

$file=$_POST['excel'];

include '../plugin/excel/Classes/PHPExcel/IOFactory.php';
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$PHPExcel = $reader->load($file);
$sheet = $PHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
?>
<div id="stylized" class="view">
<h1><?echo $file;?></h1> 
<p>Import from spreadsheet files</p>
<table id="tt" class="easyui-datagrid" style="width:auto;height:auto;" >
<thead>
<tr>
<?
for ($head = 0; $head < $highestColumn; $head++){
echo "<th field='col' $head> Unname coloum $head </th>";
}
?></tr>
</thead>
<tbody>

<?

for ($row = 1; $row <= $highestRow; $row++) {
    echo "<tr>";
    for ($column = 0; $column < $highestColumn; $column++) {
    $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();
    echo "<td>";
    //echo $val;
    echo "$row,$column";
    echo "</td>";
  }
  echo "</tr>";
}


?>
</tbody>
</table>
<div class="spacer"></div>
</div>
</body>
</html>

thanks

  • 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-28T14:36:20+00:00Added an answer on May 28, 2026 at 2:36 pm

    Too big for a comment:

    Try changing

    $highestRow = $sheet->getHighestRow(); 
    $highestColumn = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()); 
    

    to

    $highestRow = $sheet->getHighestRow(); 
    $highestColumn = $sheet->getHighestColumn(); 
    $highestColumn++;
    

    and

    for ($head = 0; $head < $highestColumn; $head++){  
        echo "<th field='col' $head> Unname coloum $head </th>";  
    }
    

    to

    for ($head = 'A'; $head !== $highestColumn; $head++){  
        echo "<th field='col' $head> Unname coloum $head </th>";  
    }
    

    and

    for ($column = 0; $column < $highestColumn; $column++) {        
        $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();        
        echo "<td>";        
        //echo $val;        
        echo "$row,$column";        
        echo "</td>";        
    } 
    

    to

    for ($column = 'A'; $column !== $highestColumn; $column++) {     
        // $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();     
        echo "<td>";     
        //echo $val;     
        echo $row , $column;     
        echo "</td>";     
    }  
    

    Note that I’ve commented out the getCell call for the moment

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

Sidebar

Related Questions

When I run this code, About half-way through the concatenation loop, $xml becomes null
I've been given the following problem about loop invariants: Consider x=4; for(i=5;i<k;i++) { a=a+x+i;
I have asked a couple of questions about this for loop: String[] book =
I'm pretty new to C++ so I'm not sure I'm going about this problem
Similar to this problem here: Old Question about C# debugging I'm trying to debug
The code below shows me (I think) that the for each loop is about
First time poster here. A quick question about setting up a loop here. I
I have a code structure something like this: For row = 1 To numRows
I have a loop on the server ( C# ) that does this: for(i=0;i<=Request.Files.Count
I know this has been talked about here before. However, my situation is a

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.