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

Export from view file #26

Closed
hvilleta opened this issue Feb 12, 2014 · 9 comments
Closed

Export from view file #26

hvilleta opened this issue Feb 12, 2014 · 9 comments

Comments

@hvilleta
Copy link

Hi

I'm using your wrapper, i'm having problems exporting to xls from view file. I pass a data variable
as a parameter and then i make an echo y the view file, but it does nothing, if i don't use any php statement it does the export, i don't find other way to pass the data and render in the view.

If you have some example it would great.

@MaatwebsiteSupport
Copy link
Contributor

Hey

Did you pass the data variables as a key-value array as second parameter of the loadView()?

Example:

Excel::loadView('viewFile', array('key' => 'value'))->export('xls');

@hvilleta
Copy link
Author

No, but i still need to use echo in the view site.

Like this:

Excel::loadView('viewFile',array('key'=>'value','key'=>'value',...))

Let me know if i'm going in the right way, and how can i add more style
than just , and tag. I want to add some borders.

Thank you very much for answer.

On Wed, Feb 12, 2014 at 2:45 PM, Maatwebsite notifications@github.comwrote:

Hey

Did you pass the data variables as a key-value array as second parameter
of the loadView()?

Example:

Excel::loadView('viewFile', array('key' => 'value'))->export('xls');

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-34901360
.

Henry Villeta G.

@MaatwebsiteSupport
Copy link
Contributor

Inside the view file you will have to echo these variables (using the key as varname). If you have used a blade file, you can use the blade syntax ({{ $key }}) to echo these vars.

For border styling see: https://github.com/Maatwebsite/laravel4-PHPExcel#setting-and-styling-borders

@hvilleta
Copy link
Author

Ok, but i tried to do this way but it does not generate the excel

On Wed, Feb 12, 2014 at 2:56 PM, Maatwebsite notifications@github.comwrote:

Inside the view file you will have to echo these variables (using the key
as varname). If you have used a blade file, you can use the blade syntax ({{
$key }}) to echo these vars.

For border styling see:
https://github.com/Maatwebsite/laravel4-PHPExcel#setting-and-styling-borders

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-34902626
.

Henry Villeta G.

@MaatwebsiteSupport
Copy link
Contributor

It should if you have used the correct syntax.
Could you post the export-code and view file here.

@hvilleta
Copy link
Author

I did like this:

@foreach ($medicion as $m) @Endforeach
Fecha Extraidos Abastecidos Balance
{{$m->fecha}} {{$m->extraidos}} {{$m->abastecidos}} {{$m->balance}}

The file is blade extension

On Wed, Feb 12, 2014 at 3:01 PM, Maatwebsite notifications@github.comwrote:

It should if you have used the correct syntax.
Could you post the export-code and view file here.

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-34903129
.

Henry Villeta G.

@MaatwebsiteSupport
Copy link
Contributor

That should work, assuming your Excel export code looks like this:

Excel::loadView('folder.file', array('medicion' => $medicion))->export('xls');

I tried your view file with this example and the User model.

If it still doesn't work, which error has been thrown?

@hvilleta
Copy link
Author

Sorry, my bad.

I was making a mistake, problem fix

Than you very much for your help, nice wrapper and very useful.

On Wed, Feb 12, 2014 at 3:05 PM, henry eduardo villeta guzman <
henryvilleta.3@gmail.com> wrote:

I did like this:

@foreach ($medicion as $m) @Endforeach
Fecha Extraidos Abastecidos Balance
{{$m->fecha}} {{$m->extraidos}} {{$m->abastecidos}} {{$m->balance}}

The file is blade extension

On Wed, Feb 12, 2014 at 3:01 PM, Maatwebsite notifications@github.comwrote:

It should if you have used the correct syntax.
Could you post the export-code and view file here.

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-34903129
.

Henry Villeta G.

Henry Villeta G.

@MaatwebsiteSupport
Copy link
Contributor

No problem and thanks! :)
Enjoy the package!

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

No branches or pull requests

2 participants