我正在使用 php 电子表格 excel 阅读器来读取 excel 文件并进行一些操作。它工作正常,突然开始在整数列的情况下返回值“General”
Sample rows from excel:
代码:
$dataFields = array("alias"=>"alias","store_quantity"=>"store_quantity","godown_quantity"=>"godown_quantity","name"=>"name");
$mandatoryFeilds = array("alias","store_quantity","godown_quantity","name");
$fieldsPos = array();
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read($_FILES['upload-file']['tmp_name']);
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
if ( isset($data->sheets[0]['cells'][1][$j]) == true )
{
$fieldsPos[$data->sheets[0]['cells'][1][$j]] = $j;
if(array_search($data->sheets[0]['cells'][1][$j],$mandatoryFeilds)!==false)
{
unset($mandatoryFeilds[array_search($data->sheets[0]['cells'][1][$j],$mandatoryFeilds)]);
}
}
}
if(count($mandatoryFeilds)>0)
{
die('Some of the mandatory columns are missing in excel');
}
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
{
//printing the output here to check values received from excel which are some anonymous values getting returned
var_dump($data->sheets[0]['cells'][$i]);
}
输出:
array("alias"=>"General","name"=>"Item A","store_quantity"=>"General","godown_quantity"=>"General")
谁可以帮我这个事?任何帮助将不胜感激