-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append data to existing excel? #208
Comments
Examples of appending rows can be found inside our documentation: |
Thanks for the reply! Those are only two lines of code, so I am not sure how to use them. I am trying this: Excel::load($path . '/exported.xls', function($reader){
$sheet = $reader->getActiveSheet();
// Manipulate third row
$sheet->row(3, array(
'test1', 'test2'
));
}); But I am getting The file already exists on the server and I only want to append data to it. |
Sorry, I misunderstood your question. |
Starting from version Excel::load($path . '/exported.xls', function($reader)
{
$reader->sheet(function($sheet)
{
$sheet->appendRow([
'test1', 'test2',
]);
});
})->export('xls'); If you want to edit a specific sheet, you can do: |
Thank you! That will be awesome! I really like how you maintain this package. |
You're welcome :) |
hello, |
I get this error with the code supplied: Illegal offset type in isset or empty. |
When I using this code, Excel::load(storage_path('exports') . '/report.csv', function($reader) {
$reader->sheet(function($sheet) {
$sheet->rows($data);
});
})->store('csv',storage_path('exports'),false); I am getting this error, |
Same here, I'm getting this error
from this code Excel::load($file_path, function ($excel) {
$excel->sheet(function($sheet) {
$sheet->appendRow([
'test1', 'test2',
]);
});
})->store($ext, storage_path('exports'), true); I'm using version |
You need to select a sheet, how else does Excel know where to append the row?
|
Thank you for your really fast answer @patrickbrouwers! After I put
I think my problems is same as this issue #502 (comment) or am I put the wrong so here's the example: if(! File::exists($file_path)){
$excelFile = Excel::create($filename, function ($excel) use($data)
{
$excel->setTitle('Export');
$excel->setCreator('Meta System')->setCompany('Company Sdn Bhd.');
$excel->setDescription('Export Master Data');
$excel->sheet('Sheet1', function ($sheet) use($data)
{
$sheet->fromArray($data, null, 'A1', true, true);
});
})->store($ext, storage_path('exports'), true);
}else{
$excelFile = Excel::load($file_path, function ($reader) {
$reader->sheet('Sheet1', function($sheet) {
$sheet->appendRow([
'test1', 'test2',
]);
});
})->export($ext);
} |
This worked for me
|
@ingenio-se
|
Did yo check the array you are using with the function? |
@hisway double check the name of the sheet. Its saying null because the sheet you are trying to append is incorrect. If anything copy the sheet name directly from the workbook sometimes there are leading or trailing spaces that you are not using. |
can someone explain how to do this in in 3.0 ? |
Please see #2068 |
how can i append column in the existing column?? can anyone help me out |
Hi, I saw a few people asking but I did not see a full code example (sorry if I missed it). Could you please provide a full code example of how to append data to existing Excel file?
The text was updated successfully, but these errors were encountered: