[英]php spreadsheet excel reader returning anonymous values
我正在使用 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")
誰可以幫我這個事? 任何幫助將不勝感激
出現問題是因為我將操作系統從 Ubuntu 14 更新到 Ubuntu 16,這將 Libre Office 版本從 4.2 更新到 5
Libre 5 中的 excel 文件正在以上述方式讀取。 所以它與 Libre 版本有關,而不是來自電子表格閱讀器的任何內容。
我有同樣的問題。 原來,那些細胞被封鎖了。 這就是電子表格閱讀器無法正確讀取的原因。
據我檢查,問題出在 Libre Office 5 上。
編輯 Excel 工作表時無法進入 Windows。
我通過讀取整數情況下 cellinfo 的原始字段來處理這個問題:
$data = new JPhpExcelReader($filename);
$id = $data->sheets[0]['cellsInfo'][$i][1]['raw'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.