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

setting title for columns or using balde #48

Closed
Hretic opened this issue Sep 3, 2018 · 2 comments
Closed

setting title for columns or using balde #48

Hretic opened this issue Sep 3, 2018 · 2 comments
Labels
question Further information is requested

Comments

@Hretic
Copy link

Hretic commented Sep 3, 2018

hi , is there any option to set the titles for columns ? right now it uses database column names as title alternatively i can use a balde template to set the titles for columns
is any of these 2 supported ?

@rap2hpoutre rap2hpoutre added the question Further information is requested label Sep 5, 2018
@rap2hpoutre
Copy link
Owner

rap2hpoutre commented Sep 5, 2018

Hi, and thank you for your contribution!

i can use a balde template to set the titles for columns

This is not possible :/ You could use Laravel Excel if you need this kind of options.

is there any option to set the titles for columns ?

Yes you can! You have to use a callback function as a second parameter of the export method and specify your column names.

(new FastExcel(User::all()))->export('users.csv', function ($user) {
    return [
        'Email' => $user->email,
        'First Name' => $user->firstname,
        'Last Name' => strtoupper($user->lastname),
    ];
});

Does it answer your question?

@Hretic
Copy link
Author

Hretic commented Sep 9, 2018

thanx

This is not possible :/ You could use Laravel Excel if you need this kind of options.

i used to work with maatwebsite/excel package but he made it too complicated and hard to work with in the new version , that's why i gave up on that and tried this one

Yes you can! You have to use a callback function as a second parameter of the export method and specify your column names.

great , that'll do

@Hretic Hretic closed this as completed Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants