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 7931599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:46:00+00:00 2026-06-03T20:46:00+00:00

I’m new to PHP and I am reading data from an excel spreadsheet and

  • 0

I’m new to PHP and I am reading data from an excel spreadsheet and I want to save each row as an array. After I have that array I want to pass that array to another function to “set” each array value with a specific title. I am unable to figure this out and was hoping someone could help.

Here is the first script:

    <?php 
include './Classes/PHPExcel.php';
include 'testCase.php';

class ExcelReader{

function getExcelFile(){
/*Get file from form*/
    echo 'Hello world' . "\n";
    $FileName = $_FILES["fileName"]["name"];

    /*Move file to server, if file already exists, don't move*/
    if(file_exists("uploadedFiles/".$_FILES["fileName"]["name"])){
        echo $_FILES["fileName"]["name"]." already exists";
    }
    else{
        move_uploaded_file($_FILES["fileName"]["tmp_name"],"uploadedFiles/".$_FILES["fileName"]["name"]);
        echo $_FILES["fileName"]["name"]." has been moved";



    }
    return $FileName;
}

function readExcelFile($FileName){


    /*Create reader object for file and read object in*/
    $PHPExcelReader= PHPExcel_IOFactory::createReaderForFile($FileName);
    $PHPExcelReader->setReadDataOnly(true);
    $PHPExcelObj=$PHPExcelReader->load($FileName);






    $PHPobjWorksheet = $PHPExcelObj->getActiveSheet();

    $topRow = $PHPobjWorksheet->getHighestRow();
    $topCol = $PHPobjWorksheet->getHighestColumn();

    $highestColIndex=  PHPExcel_Cell::columnIndexFromString($topCol);
    for($row=1;$row<=$topRow; $row++){

        $newTestCase = new testCase();
        $testIndex = $newTestCase->getTestCase($row, $highestColIndex, $PHPobjWorksheet);
        echo $testIndex."<- Test Index <br/>";
        $newTestCase->setTestCase($testIndex);
    }
 }
}

$newExcelReader = new ExcelReader;
$newFileName = $newExcelReader->getExcelFile();
$newExcelReader->readExcelFile($newFileName);

?>

Here is the second class that I am using to get the data and I’m trying to set:

    <?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Class for creating test cases to be sent 
 * into TestRail
 * @author Banderson
 */
class testCase {

    /*Function to get the data for each individual test case*/
    function getTestCase($row, $highestColIndex, $PHPobjWorksheet){

            echo "<br />";
            for($col=0;$col<=$highestColIndex;++$col){
                $ii=0;
                $cellValue=array($PHPobjWorksheet->getCellByColumnAndRow($col,$row)->getValue());
                echo $cellValue[$ii]. " | ";
                $ii++;


        }

    return $cellValue;

    }


    /*Function to set the data for each individual test case*/
    function setTestCase($cellValue){
                $title = $cellValue[0];
                echo $title. "<- Title"."<br/>";
                $type = $cellValue[1];
                echo $type. "<- Type"."<br/>";
                $priority = $cellValue[2];
                echo $priority. "<- Priority"."<br/>";
                $estimate = $cellValue[3];
                echo $estimate. "<- Estimate"."<br/>";
                $milestone = $cellValue[4];
                echo $milestone. "<- MileStone"."<br/>";
                $references = $cellValue[5];
                echo $references. "<- 5"."<br/>";
                $preconditions = $cellValue[6];
                echo $preconditions. "<- 6"."<br/>";
                $steps = $cellValue[7];
                echo $steps. "<- 7"."<br/>";
                $expectedResults = $cellValue[8];
                echo $expectedResults. "<- 8"."<br/>";
                $testSuit = $cellValue[9];
                echo $testSuit. "<- 9"."<br/>";


    }



}

?>

And finally here is the error message I’m getting:

    Hello world testrailtestinputV2.xlsx already exists
Title | Type | Priority | Estimate | Milestone | Reference | Preconditions | Steps | Expected Result | Section | Test Suite | | Array<- Test Index<- Title

( ! ) Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 37
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- Type

( ! ) Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 39
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- Priority

( ! ) Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 41
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- Estimate

( ! ) Notice: Undefined offset: 4 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 43
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- MileStone

( ! ) Notice: Undefined offset: 5 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 45
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- 5

( ! ) Notice: Undefined offset: 6 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 47
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- 6

( ! ) Notice: Undefined offset: 7 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 49
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- 7

( ! ) Notice: Undefined offset: 8 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 51
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- 8

( ! ) Notice: Undefined offset: 9 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 53
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.3133  5664536 testCase->setTestCase( )    ../testRailScripting.php:50
<- 9

Title 1 | Functionalit | 1 | | | | | 1. Turn phone on 2. Go to main menu 3. Push button | The screen should look like this | | | | Array<- Test Index<- Title

( ! ) Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 37
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- Type

( ! ) Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 39
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- Priority

( ! ) Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 41
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- Estimate

( ! ) Notice: Undefined offset: 4 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 43
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- MileStone

( ! ) Notice: Undefined offset: 5 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 45
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- 5

( ! ) Notice: Undefined offset: 6 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 47
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- 6

( ! ) Notice: Undefined offset: 7 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 49
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- 7

( ! ) Notice: Undefined offset: 8 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 51
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- 8

( ! ) Notice: Undefined offset: 9 in /Applications/MAMP/htdocs/TestRailIntegration/testCase.php on line 53
Call Stack
#   Time    Memory  Function    Location
1   0.0000  635280  {main}( )   ../testRailScripting.php:0
2   0.0034  749112  ExcelReader->readExcelFile( )   ../testRailScripting.php:57
3   0.5097  5675280 testCase->setTestCase( )    ../testRailScripting.php:50
<- 9

Title 2 | Functionalit | 1 | | | | | 1. Turn phone on 2. Go to main menu 3. Push button | The screen should look like this | | | | Array<- Test Index<- Title

Any help would be wonderful! Thank you in advance!

  • 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-06-03T20:46:02+00:00Added an answer on June 3, 2026 at 8:46 pm

    Your function getTestCase creates new array with one element and put it into variable $cellValue at each iteration. So, the array returned by this function contains only one element. You should fix it in this way:

    function getTestCase($row, $highestColIndex, $PHPobjWorksheet) {
      $cellValue = array();
      for($col = 0; $col <= $highestColIndex; ++$col) {
        $v = $PHPobjWorksheet->getCellByColumnAndRow($col,$row)->getValue();
        $cellValue[] = $v; //append element to the array
      }
      return $cellValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.