import Ember from 'ember';

export default Ember.Controller.extend({
  columns: ['id', 'title', 'body'],

  actions: {
    exportToExcel: function(){
      var self = this;
      var workbook = ExcelBuilder.createWorkbook();
      var sheet = workbook.createWorksheet({name: 'Test'});

      var prepareData = [];
      prepareData.pushObject(this.get('columns'));
      this.get('model').forEach(function(item){
        prepareData.pushObject(self.get('columns').map(function(column){
          return item.get(column);
        }));
      });
      sheet.setData(prepareData);
      workbook.addWorksheet(sheet);
      var data = ExcelBuilder.createFile(workbook);

			Downloadify.create('downloadify',{
				filename: function(){
					return 'sample.xlsx';
				},
				data: function(){
					return data;
				},
				onComplete: function(){ alert('Your File Has Been Saved!'); },
				onCancel: function(){ alert('You have cancelled the saving of this file.'); },
				onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
				swf: 'downloadify.swf',
				downloadImage: 'download.png',
				width: 100,
				height: 30,
        dataType: 'base64',
				append:true
			});
    }

  }

});

@@ -308,16 +308,30 @@
  = %5B
+%5B'POPULATION'%5D
 %5D;%0A     
  pre
@@ -322,24 +322,205 @@
 ON'%5D%5D;%0A     
+ prepareData.pushObject(%5B'      ','Medicaid Expansion Adjustment', '0', '0', '0'%5D);%0A      prepareData.pushObject(%5B'      ', '%25 Var from Est. Exchange Pop', '0', '0', '0'%5D);%0A      //
  prepareData
@@ -558,16 +558,19 @@
 );%0A     
+ //
  this.ge
@@ -609,16 +609,19 @@
 )%7B%0A     
+ //
    prepa
@@ -681,24 +681,27 @@
 lumn)%7B%0A     
+ //
      return 
@@ -723,16 +723,19 @@
 );%0A     
+ //
    %7D));%0A
@@ -743,12 +743,508 @@
     
+ //
  %7D);
+%0A%0A      prepareData.pushObject(%5B'PAYER RISK ARRANGEMENTS'%5D)%0A      prepareData.pushObject(%5B'     ','%25 Commercial Revenue in Risk Contracts', 15, 15,15%5D)%0A      prepareData.pushObject(%5B'     ','%25 Medicare Revenue in Risk Contracts', 15, 15,15%5D)%0A      prepareData.pushObject(%5B'     ','%25 Medicaid Revenue in Risk Contracts', 15, 15,15%5D)%0A      prepareData.pushObject(%5B'     ','%25 of HXR Revenue in Risk Contracts', 15, 15,15%5D)%0A      prepareData.pushObject(%5B'     ','%25 Savings to Trinity', 15, 15,15%5D)
 %0A   
@@ -1912,11 +1912,13 @@
 end:
-tru
+ fals
 e%0A%09%09

put example