【发布时间】:2016-04-30 06:59:12
【问题描述】:
我有以下数组。
$t= array('Super User','Admin_Sub','Catalog Management User','Order Management User','CustomerCare_Head','CustomerCare_Sub',' Finance Management User',
'Logistic Management User','Logistic_Sub','SEO_Head','SEO_Sub','Marketing Management User','Marketing_Sub','Cat_Man','Design','Business Development','Reviews',
'Catalot Management Primary User','Catalot Management Secondary User');
如果我打印数组,它显示为空。
$t= array('Super User','Admin_Sub','Catalog Management User','Order Management User','CustomerCare_Head','CustomerCare_Sub',' Finance Management User',
'Logistic Management User','Logistic_Sub','SEO_Head','SEO_Sub','Marketing Management User','Marketing_Sub','Cat_Man','Design','Reviews');
如果我打印这个数组,它打印得很好。
我已删除('业务开发', 'Catalot Management Primary User','Catalot Management Secondary User) 来自第二个阵列。这三个值阻止了数组打印。我尝试了所有可能的方法,但没有成功。
提前感谢 :)
P.S:我忘了提到它不能在 Excel 中打印。我将其作为下拉列表导入 Excel 文件
Excel::create('Users', function ($excel) use ($rs, $role_final) {
$excel->sheet('Users', function ($sheet) use ($rs, $role_final) {
if (count($rs['attachData']) > 0) {
$arr_csv = array_merge($this->arr_user, $rs['attachData']);
} else {
$arr_csv = $this->arr_user;
}
$t= array('Super User','Admin_Sub','Catalog Management User','Order Management User','CustomerCare_Head','CustomerCare_Sub',' Finance Management User',
'Logistic Management User','Logistic_Sub','SEO_Head','SEO_Sub','Marketing Management User','Marketing_Sub','Cat_Man','Design','Business Development','Reviews',
'Catalot Management Primary User','Catalot Management Secondary User');
$user_role = implode(',',$t);
$user_roles[0] = $user_role;
$sheet->rows(array($arr_csv));
$this->getDropDownListWithValidation($sheet, 'E', implode('","', $user_roles));
$sheet->setFontSize(10);
$sheet->row(1, function ($row) {
$row->setFontWeight('bold');
});
$sheet->freezeFirstRow();
});
})
->export('xls');
protected function getDropDownListWithValidation($sheet, $cell, $items)
{
$objValidation = $sheet->getCell($cell . $i)->getDataValidation();
$objValidation->setType(\PHPExcel_Cell_DataValidation::TYPE_LIST);
$objValidation->setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
$objValidation->setAllowBlank(false);
$objValidation->setShowInputMessage(true);
$objValidation->setShowErrorMessage(true);
$objValidation->setShowDropDown(true);
$objValidation->setErrorTitle('Input error');
$objValidation->setError('Value is not in list.');
$objValidation->setPromptTitle('Pick from list');
$objValidation->setPrompt('Please pick a value from the drop-down list.');
$objValidation->setFormula1('"' . $items . '"');
}
return $objValidation;
}
【问题讨论】:
-
两者都按预期打印!
-
打印正常。不确定您的问题到底是什么。
标签: php arrays excel excel-import