public function processForm(Request $request)
{
$formData= $request->all();
// Notice the use statement here, you need to provided that for a callback function
Excel::create('data', function($excel) use ($formData) {
// Notice the use statement here
$excel->sheet('Sheetname', function($sheet) use ($formData) {
$sheet->fromArray($frmData);
});
})->store('xls', public_path('uploads'));
}
public function processForm(Request $request)
{
$formData= $request->all();
// Notice the use statement here, you need to provided that for a callback function
Excel::create('data', function($excel) use ($formData) {
// Notice the use statement here
$excel->sheet('Sheetname', function($sheet) use ($formData) {
$sheet->fromArray($formData);
});
})->store('xls', public_path('uploads'));
}
I agree with you jacob I also tried to append to the file and it has the correct permissions on the server but it will not work for some strange reason. Not sure what I am missing.
public function processForm(Request $request)
{
$formData= $request->all();
// Notice the use statement here, you need to provided that for a callback function
Excel::load(public_path('uploads').'/data.xls', function($reader) use ($formData) {
// Notice the use statement here
$reader->sheet('Sheetname', function($sheet) use ($formData) {
$sheet->appendRow($formData);
});
})->export('xls');
}
The following works when calling the url directly. When using a form post it works only when creating a new file. When prependRow is called the application doesn't work. Any ideas as to what I am doing wrong.
public function addrow(){
Excel::load(public_path('uploads').'/data.xls', function($reader)
{
$reader->sheet('Sheetname',function($sheet) {
$sheet->prependRow(array(
'prepended', 'prepended'
));
});
})->export('xls');
}
Here is process form
public function processForm(Request $request)
{
$formData= $request->all();
Excel::load(public_path('uploads').'/data.xls', function($reader) use ($formData)
{
$reader->sheet('Sheetname',function($sheet) use ($formData) {
$sheet->prependRow($formData);
});
})->export('xls');
}