PHP Export Excel garbled related issues

Source: Internet
Author: User
PHP Export Excel garbled problem
Recently in doing a PHP import export Excel;
Try Phpexcel and spreadsheet_excel_writer are not good use, save Local is useful, but output browser is garbled, and can see garbled file should be the current page of HTML. Who can fix this?
Create a Processing object instance
$objExcel = new Phpexcel ();

//*************************************
Set document basic Properties
$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");

//*************************************
Sets the current sheet index for subsequent content operations.
It is generally only necessary to display a call when multiple sheet are used.
By default, Phpexcel automatically creates the first sheet to be set sheetindex=0
$objExcel->setactivesheetindex (0);


$objActSheet = $objExcel->getactivesheet ();

Sets the name of the currently active sheet
$objActSheet->settitle (' Testsheet ');

to the browser
Header ("Content-type:application/vnd.ms-excel; Charset=utf-8 ");
Header ("Content-type:application/force-download");
Header ("Content-type:application/octet-stream");
Header ("Content-type:application/download");
Header ("Content-type:charset=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 file saved on the server is OK, but there is a problem with the file that pops up on the client.
Garbled as:
Xing yo?;?
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????? b?=?r8x "1? Calibri??????????????????????? 8??????????? Vast cabinet? f??? F?? Hot??????????? 櫶 櫶 虣? 虣 3f? Hot 櫶?? 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? ' Ffffff? (?)?" dxx333333?333333?>?@
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.