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

How to save correctly? #35

Closed
ghost opened this issue Feb 28, 2014 · 1 comment
Closed

How to save correctly? #35

ghost opened this issue Feb 28, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 28, 2014

Heres what I am trying to do and probably doing it all wrong! But is there a way to update the object then re-write/save it?

I have read the file in as an object type. Converted it to json did some string replacements on it then converted it back to an object. Now I want to take that object and save it back out with the new variables in it.

Other Info:
Basically I have a template xlsx file with things like {{goal0}} so I want to be able to replace those with actual values and save it so I can send out a mass email with it updated.

@MaatwebsiteSupport
Copy link
Contributor

After you have done your string replacements, you have to convert it to a nice array and give it to the ->with() method of Excel::create(). It will make a new excel file based on the array (which will have the replaced values)

Example of how the array should look

$array = array(
        array('A1','B1'),
        array('A2','B2')
);

Example of the Excel parts:

// Load file into object
$object = Excel::load('file.xlsx')->toObject();

// Do your replace functions

// Convert to an array

// Export to excel
$excel =  Excel::create('export_filename')
           ->sheet('sheetName')
           ->with($array)
          ->store('xlsx', false, true);

// Get the file to use it as attachment
$filename = $excel['full'];

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

1 participant