2016-05-01 5 views
0

Excelから値の範囲を読み取ろうとしています。これは私が使用するコードです。私は3項目と一致する必要があります範囲を取得しておりますが$dataArrayのカウントが、ちょうど1であるいくつかの理由PHPExcelで値の範囲を取得する

// Include PHPExcel_IOFactory 
include 'Classes/PHPExcel/IOFactory.php'; 

$inputFileName = 'test.xlsx'; 
// Read your Excel workbook 
try { 
    $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); 
} catch(Exception $e) { 
    die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage()); 
} 


$cellValue = $objPHPExcel->getActiveSheet()->getCell('A1')->getValue(); 
echo "A1 is: ".$cellValue."<br>"; 


$dataArray = $objPHPExcel->getActiveSheet() 
->rangeToArray(
     'A1:C1',  // The worksheet range that we want to retrieve 
     NULL,  // Value that should be returned for empty cells 
     TRUE,  // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell) 
     TRUE,  // Should values be formatted (the equivalent of getFormattedValue() for each cell) 
     TRUE   // Should the array be indexed by cell row and cell column 
     ); 

echo "number of items in array: ".count($dataArray); 

。何が問題なの?

答えて

0

これは配列の配列です。 2次元配列。単一の行を表す2次元配列の各配列。クエリがA1:C3の場合、3つのプライマリ配列が返されます。

関連する問題