Skip to content
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

Name sheets in export #40

Closed
rap2hpoutre opened this issue Jul 17, 2018 · 3 comments
Closed

Name sheets in export #40

rap2hpoutre opened this issue Jul 17, 2018 · 3 comments
Labels
enhancement New feature or request

Comments

@rap2hpoutre
Copy link
Owner

According to this comment, it would be great to be able to name sheets. As suggested by @harty, it could be done in SheetCollection constructor:

$sheets = new SheetCollection(
    [User::all(), Project::all()], 
    ['users sheet', 'project sheet']
);

So it means a new property (names) could be added to SheetCollection then it could be passed as a second argument in the SheetCollection constructor.

The main advantage to add it in the constructor is that (in a second step), it could be used in import process too: the sheet names would be loaded from the importSheets function that returns the SheetCollection. So that's cool.

One disadvantage of creating the name of the sheets via SheetCollection constructor is that there is no way to name a sheet when exporting only a Collection (e.g only one sheet) but I'm not sure it's an actual issue: the main goal is to name sheets in multiple sheets export.

@rap2hpoutre rap2hpoutre added the enhancement New feature or request label Jul 17, 2018
@SimoTod
Copy link

SimoTod commented Aug 31, 2018

How about

    'users sheet' => User::all(),
    'project sheet' => Project::all()
]);``` and still supporting `$sheets = new SheetCollection([User::all(), Project::all()]);` if you don't want to change sheet names?

When exporting a single collection, you would use `$sheets = new SheetCollection(['users' => User::all()]);`

@rap2hpoutre
Copy link
Owner Author

rap2hpoutre commented Sep 5, 2018

@SimoTod ... 👍 👍

You are totally right. Your suggestion is really good, thank you so much! I will develop it following your advice. So:

$sheets = new SheetCollection(['users' => User::all()]);
(new FastExcel($sheets))->export('file.xlsx');

@rap2hpoutre
Copy link
Owner Author

Fixed via 059442e available in v0.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants