mardi 29 septembre 2015

(maatwebsite) Laravel-excel. Is it possible to get the latest active row (or cell) while working with a blade view?

I'm working with laravel-excel, previously I used it creating a new sheet from scratch, so I was always able to know in which row I was by just using a variable ($row).

Now I'm exploring the other way of using it, by using a blade view, and it works great, but I want to do some transformations and add some formulas from the laravel-excel side (class side), the problem is that by using a view I lost control for knowing which row am I "standing" in.

I know how to pass variables to the view but I don't know how if I can give back a variable FROM the view to the class or if there is a way in laravel-excel to get the last active row after using a view or something like that.

This is a little example of what I would like to do:

public static function makeIng($params){
    $data['parts'] = Part::confirmed()->get();
    $data['adjusts'] = Adjust::confirmed()->get();
    Excel::create('Report', function($excel) use($data){
      $excel->sheet('1', function($sheet) use($data){
        $sheet->loadView('sii.dte.excel.ing', array('data' => $data));
        $sheet->mergeCells('A1:C1');
        $sheet->mergeCells('A2:C2');
        $sheet->mergeCells('A3:C3');

        //I would "dream" to to something like this:
        //$row=$sheet->getLastRow();
        //$sheet->cell('C'.($row+1),'=sum(C4:C'.$row.')');

     });
    })->export('xls');
}

BTW, using a "count" of my data to know how many rows to add is not an option this time, I did that for another excel but this time for some interactions inside the view that won't work.

I hope you can help me, thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ju1As2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire