1

我正在使用 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")

谁可以帮我这个事?任何帮助将不胜感激

4

3 回答 3

0

问题的发生是因为我将我的操作系统从 Ubuntu 14 更新到了 Ubuntu 16,这将 Libre Office 版本从 4.2 更新到了 5

Libre 5 中的 excel 文件正在以上述方式读取。所以它与 Libre 版本有关,而不是与电子表格阅读器中的任何内容有关。

于 2016-12-13T11:39:52.670 回答
0

我有同样的问题。原来那些细胞被封锁了。这就是电子表格阅读器无法正确阅读的原因。

于 2017-11-05T03:39:33.767 回答
-1

据我检查,问题出现在 Libre Office 5 上。

编辑 Excel 工作表时无法进入 Windows。

我通过读取单元格信息的原始字段来处理整数情况下的问题:

$data = new JPhpExcelReader($filename);

$id = $data->sheets[0]['cellsInfo'][$i][1]['raw'];
于 2018-08-10T12:21:14.027 回答