1

我有以下数组。

$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)。这三个值阻止了数组打印。我尝试了所有可能的方法,但没有成功。

提前感谢:)

PS:我忘了提到它不会在 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;
}
4

1 回答 1

0

试试下面的代码

      $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');



   $t1= 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');
 echo "<pre>";
 print_r($t);
 print_r($t1);
于 2016-04-30T07:07:27.503 回答