I have this Excel file (.xlsx):
+---+-------+
| | A |
+---+-------+
| 1 | 1 |
| 2 | =A1+1 |
| 3 | =2*3 |
+---+-------+
In Laravel I have configured this code to display the contents
return Excel::load(base_path() . '/test.xlsx')->string('csv');
which returns the text of the cells: "1","=A1+1","=3*2"
What I want is the calculated values, but with the same formatting: "1","2","6"
The code
return Excel::load(base_path() . '/test.xlsx')->get();
returns the correct calculated data, but in the wrong format.
There's an option precisely for that purpose. You probably have a config file at config/excel.php (if not just do php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" ). Take a look at the export array, which holds the following option:
/*
|--------------------------------------------------------------------------
| Pre-calculate formulas during export
|--------------------------------------------------------------------------
*/
'calculate' => false,
Set it to true and there you have it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With