Php excel export garbled problem recently a php import and export excel; tried PHPEXCEL and Spreadsheet_Excel_Writer are not easy to use, save locally is easy to use, but the output browser is garbled, in addition, the garbled file should be the HTML of the current webpage. Who can solve the problem of creating a processing object instance & nbsp; $ objExcelnewPHPExcel (php export excel garbled problem?
Recently, I am working on a php file to import and export excel files;
I tried PHPEXCEL and Spreadsheet_Excel_Writer, but they are not easy to use and save locally. However, the output browser is garbled and the garbled file should be the HTML of the current webpage. Who can solve it?
// Create a processing object instance
$ ObjExcel = new PHPExcel ();
//*************************************
// Set the basic attributes of the document
$ ObjProps = $ objExcel-> getProperties ();
$ ObjProps-> setCreator ("Zeal Li ");
$ ObjProps-> setLastModifiedBy ("Zeal Li ");
$ ObjProps-> setTitle ("Office XLS Test Document ");
$ ObjProps-> setSubject ("Office XLS Test Document, Demo ");
$ ObjProps-> setDescription ("Test document, generated by PHPExcel .");
$ ObjProps-> setKeywords ("office excel PHPExcel ");
$ ObjProps-> setCategory ("Test ");
//*************************************
// Set the current sheet index for subsequent content operations.
// Display the call only when multiple sheets are used.
// By default, PHPExcel will automatically create the first sheet and set SheetIndex = 0
$ ObjExcel-> setActiveSheetIndex (0 );
$ ObjActSheet = $ objExcel-> getActiveSheet ();
// Set the name of the current active sheet
$ ObjActSheet-> setTitle ('testsheet ');
// Go to the browser
Header ("Content-Type: application/vnd. ms-excel; charsets = UTF-8 ");
Header ("Content-Type: application/force-download ");
Header ("Content-Type: application/octet-stream ");
Header ("Content-Type: application/download ");
Header ("Content-type: charsets = utf-8 ");
Header ('content-Type: application/vnd. ms-excel ');
Header ("Content-Transfer-Encoding: binary ");
Header ('content-Disposition: attachment; filename = "01simple.xls "');
Header ('cache-Control: max-age = 0 ');
$ ObjWriter = PHPExcel_IOFactory: createWriter ($ objExcel, 'excel5 ');
$ ObjWriter-> save('01simple.xls ');
$ ObjWriter-> save ('php: // output ');
The files saved on the server are good, but there is a problem in the pop-up file stored on the client.
Garbled like:
Required bytes ?;?
???????????????????????????????????????? ???????????????????????????????????????? ???????????????????????????????????????? ????????????????? B? =? R8X "1? Calibri? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? 8 ??????????? Why? Why? F ??? F ?? Hot ??????????? Why? Too many? Required 3f? Hot Bread ?? Ff %3f3 %333 ?? F33333testSheet ?? G ??
$ }$} }$ $ }$} !! $} "" $ }### }$ $} % $} & $} ''$} ($ })) $} ** $} + + $}, $} -- $ }.. $} // $} 00 $} 11 $} 22 $} 33 $} 44 $} 55 $} 66 $} 77 $} 88 $} 99 $ }:: $ };$ }<=== }>$ }?? $ }@@} AA $} BB $} CC $} DD $} EE $} FF $} GG $} HH $} II $} JJ $} KK $} LL $} MM $} NN $} OO $} PP $} QQ $} RR $} SS $} TT $} UU $} VV $} WW $} XX $} YY $} ZZ $} [[[$ }\\\}] $} ^ $ }__ $} ''$} aa $} bb $} cc $} dd $} ee $} ff $} gg $} hh $} ii $} jj $} kk $} ll $} mm $} nn $} oo $} pp $} qq $} rr $} ss $} tt $} uu $} vv $} ww $} xx $} yy $} zz $ }{{$} | |$ }}$ }~~ $ }$ }? $ }$} }$ $ }$} $ }$} }$ $ }$} $ }$} }$ $ }$} $ }$} }$ $ }$} $ }$} }$ $ }$} $ }$} }$ $ }$} $ }$ }? $ * + ?? & Ffffff? 'Ffffffff? (?)? "DXX333333? 333333?>? @