duannaxin9975 2019-01-18 17:00
浏览 85

Laravel Excel / PHPExcel,应用样式存储行数

I've created an array out of an object that I'm dumping to excel with Laravel excel/PHPExcel, but I 've made an array that stores the count of rows for the top level of the $allGroupResult array so that I can individually style those rows.

The row numbers stored in $boldRows are the rows that I want bold and to have a different width on those cells.

How can I apply the row count from $boldRows so that I can apply unique styling to those rows only?

$allgroupResult= array();
    $rowCount = 2;
    $boldRows = array();

    foreach($prices->groups as $group){ 

        //creating array items omitted 

        array_push($allgroupResult, $groupItem);    
        array_push($boldRows, $rowCount++);

        foreach($group->skus as $sku){

            //creating array items omitted

            array_push($allgroupResult, $skuItem);
            $rowCount++;    
        }
    }

    $name = 'File Export';

    $build = Excel::create($name, function ($excel) use ($allgroupResult) {

        $excel->setTitle('File Export');

        $excel->sheet('File Export', function ($sheet) use ($allgroupResult) {

            $sheet->fromArray($allgroupResult);

            // Not sure how to use $boldRows count here to make bold, wider cells, etc.
            $sheet->getStyle('A1:'.$sheet->getHighestColumn().'1')->getFont()->setBold(true);
   }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?
    • ¥15 电磁场的matlab仿真
    • ¥15 mars2d在vue3中的引入问题
    • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
    • ¥15 算法题:数的划分,用记忆化DFS做WA求调
    • ¥15 chatglm-6b应用到django项目中,模型加载失败
    • ¥15 CreateBitmapFromWicBitmap内存释放问题。
    • ¥30 win c++ socket
    • ¥15 C# datagridview 栏位进度