php - Download Excel file using PHPExcel -


I am trying to download the excel file using PHPExcel, it seems that this excel file is well downloaded But the data in the Excel file is everything Crap .. What I do not expect is that I have passed very basic ways to test my Excel sheet data output

here the code I'am Trying

  else if ($ request- & gt; p ['type'] == 'excel') {$ report_type_name = "Graph all Report "; $ ExcelReport = New ExcelApExport ($ classes, $ group_definition, $ questions, $ sample_corrections); $ ObjPHPExcel = $ ExcelReport- & gt; Export ($ set, $ disp_filter); Header ('content-type: application / vnd.ms-excel'); Header ("content-dispute: attachment;". Escape_for_content_disposition ("{$ report_name} - {$ report_type_name} -" .date ("Y-M-D.H."). ".xls")); Header ('cache-control: max-age = 0'); $ ObjWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel 2007'); $ ObjWriter- & gt; Save ('php: // output'); Go out; } Here I also make an object here and call phpexcel methods here  
  Public function export ($ set, $ disp_filter) {$ objPHPExcel = New PHPExcel (); $ ObjPHPExcel- & gt; GetProperties () - & gt; Setitle ("official excel test document"); $ ObjPHPExcel- & gt; GetProperties () - & gt; Set form ("test document"); $ ObjPHPExcel- & gt; GetProperties () - & gt; Set descriptio ("Test document for XLS, generated by using PHP classes."); // Echo date ('H: I: S'). "Add some data \ n"; $ ObjPHPExcel- & gt; SetActiveSheetIndex (0); $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; Setcell value ('A1', 'Hello'); $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; Setel Value ('B2', 'World!'); $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; Setale value ('c1', 'hello'); $ ObjPHPExcel- & gt; GetActiveSheet () - & gt; Satell Value ('D2', 'world!'); Return $ objPHPExcel; }  

This is what I get in my downloaded Excel file

Could you please suggest me why this nonsense data is displayed in my file instead of expected data in advance thanks in advance

$ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007'); This author is for

.xls x files. (See:

Then the correct header will be:

  // Redirection for client's Web browser (Excel 2007) Header ('Content-Type: App / vnd .openxmlformats-officedocument.spreadsheetml.sheet '); Header ("content-dispute: attachment;". Escape_for_content_disposition ("{$ report_name} - {$ report_type_name} -". Date ("Y-M-DHHI"). ".xlsx")); //.xlsX!  

Author of old .xls-files:

$ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel5');

View:


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -