0

I want to export the data of a dynamic paginated html table into an excel sheet using angular js. I have in google, but they all are working for static tables,not for the one I need. I have tried the below code:

var app = angular.module('myapp', []);

app.controller('Mycn',  function($scope) {

   $scope.exportfunc = function(){
   var strCopy = document.getElementById("MyTable").innerHTML;
   window.clipboardData.setData("Text", strCopy);
   var objExcel = new ActiveXObject ("Excel.Application");
   objExcel.visible = true;

   var objWorkbook = objExcel.Workbooks.Add;
   var objWorksheet = objWorkbook.Worksheets(1);
   objWorksheet.Paste;
   }
});
  • Please describe in more detail what the problem is with your current code. – ACEG Mar 23 '17 at 09:19
  • 2
    Possible duplicate of [Export to xls using angularjs](http://stackoverflow.com/questions/21680768/export-to-xls-using-angularjs) – Mistalis Mar 23 '17 at 09:38
  • The button I have added is not working with this code. It is not exporting. Don't know why. My table is a dynamic table where pagination has been used. – Madhumita Roy Mar 23 '17 at 09:52
  • Thanks for your answer, but I have used both Blob and Alasql. None of them worked. May be I missed something – Madhumita Roy Mar 23 '17 at 09:57

1 Answers1

0

its posible using

const ExcelFile = ReactExport.ExcelFile const ExcelSheet = ReactExport.ExcelFile.ExcelSheet

const title = 'Report Name' const columns = ['Account', 'Name']

export class ComplaintExport extends Component { createData = () => { const { data, subtitle = 'Conversaciones' } = this.props

const dataSet = [{ columns: [title], data: [] }, { columns: [subtitle], data: [] }, { columns: columns, data: data }]
return dataSet   }   render() {
const dataSet = this.createData()
return (
  <ExcelFile
    element={
      <Button variant="contained" color="primary">
        Export All <Icon>attachment</Icon>
      </Button>
    }
  >
    <ExcelSheet dataSet={dataSet} name="Cons" />
  </ExcelFile>
)   }