Phpexcel notes, Mpdf Export, phpexcelmpdf_php tutorial

Source: Internet
Author: User
Tags php error php error log

Phpexcel notes, Mpdf Export, phpexcelmpdf


Phpexcel Common Treatment

# #导入类库require ' phpexcel/classes/phpexcel.php '; require ' phpexcel/classes/phpexcel/writer/excel5.php '; Write-out class # #基础属性设定 $objPHPExcel = \phpexcel_iofactory::load (' A.xls ') in non-07 format; Read in the specified Excel file $objphpexcel->setactivesheetindex (0); Specify the active sheet $objphpexcel->getactivesheet ()->getdefaultstyle ()->getfont ()->setname (' Arial '); $objPHPExcel- >getproperties ()->settitle (' xxx '); # #单元格编辑 $objPHPExcel->getactivesheet ()->setcellvalue (' A3 ', ' xxx '); Set the A3 cell value to XXX # #单元格绘图 $objDrawing = new \phpexcel_worksheet_drawing (); $objDrawing->setpath (' a.jpg '); Specifies the picture path. To phpexcel/classes/phpexcel/worksheet/drawing.php:106 a remote image file_exists change to file_get_contents$objdrawing-> Setcoordinates (' A4 '); Specify the A4 cell drawing $objdrawing->setname (' photo '); $objDrawing->setdescription (' photo '); $objDrawing->setheight $objDrawing->setwidth (+), $objDrawing->setoffsetx (7), $objDrawing->setoffsety (7); $objDrawing- >setworksheet ($objPHPExcel->getactivesheet ()); # #excel文件浏览器下载导出 $filename = ' A.xls '; $encodEd_filename = Rawurlencode ($filename); $ua = $_server["Http_user_agent"];header (' content-type:application/ Vnd.ms-excel '), if (Preg_match ("/msie/", $ua) | | preg_match ("/trident\/7.0/", $ua) | | preg_match ("/edge/", $ua)) {Header (' Content-disposition:attachment; filename= '. $encoded _filename. '"');} else if (Preg_match ("/firefox/", $ua)) {header ("content-disposition:attachment; Filename*=\ "UTF8". $filename. '"');} else {header (' content-disposition:attachment; Filename= '. $filename. '"');} Header ("Pragma:no-cache"), Header ("expires:0"), $objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); $objWriter->save (' php://output '); # #excel文件html显示 (available for debugging) $objWriter = new \phpexcel_writer_html ($objPHPExcel); $objWriter->save (' php://output ');

Export PDF files from Phpexcel using the Mpdf library

$filename = ' a.pdf '; $encoded _filename = Rawurlencode ($filename); $rendererName = \phpexcel_settings::P df_renderer_ MPDF; Specifies that PDF files are exported through the Mpdf class library $rendererlibrarypath = ' phpexcel/mpdf57 '; Specify the Mpdf class library path you downloaded if (!\phpexcel_settings::setpdfrenderer ($rendererName, $rendererLibraryPath)) {die (' Set th    e $rendererName and $rendererLibraryPath values '.    Php_eol. ' As appropriate for your directory structure ');} Header (' content-type:application/pdf '); if (Preg_match ("/msie/", $ua) | | preg_match ("/trident\/7.0/", $ua) | | preg_ Match ("/edge/", $ua)) {header (' content-disposition:attachment; filename= '. $encoded _filename. '"');} else if (Preg_match ("/firefox/", $ua)) {header ("content-disposition:attachment; Filename*=\ "UTF8". $file _name. '"');} else {header (' content-disposition:attachment; filename= '. $file _name. '"');} Header ("Pragma:no-cache"), Header ("expires:0"), $objWriter = new \phpexcel_writer_pdf ($objPHPExcel); $objWriter Setprecalculateformulas (false); $objWriteR->save (' php://output '); ############################### #pdf导出失败的一些错误解决方法 ############################## # #1 PDF Chinese garbled problem phpexcel/classes/ Add two lines to the phpexcel/writer/pdf/mpdf.php:105: $pdf->USEADOBECJK = true; $pdf->setautofont (Autofont_all); # #2 Many preg_replace calls in the class library use the meta-character e, and some of the lower versions of PHP do not support the improper use of the regular expression e-metacharacters character e characters and cause the PDF error trigger point in the class library there are about five or six, because the E-metacharacters is a shell under the child process PHP call , so the error message will not be fed back to the current PHP process, so even if you configure the wrong print to the screen, the page will not display the errors, you must check the PHP error log to view the PHP error log, the hint of the preg_replace in the meta-character e calls replaced with Preg_replace_ Callback form of Call # #3 partial version Phpexcel class library has cell style judgment error lib/phpexcel/classes/phpexcel/writer/html.php:1236 add an if to determine if (! $this- >_USEINLINECSS) {$cssClass. = ' style '. $pSheet->getcell ($endCellCoord)->getxfindex ();

http://www.bkjia.com/PHPjc/1125248.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125248.html techarticle Phpexcel notes, Mpdf Export, phpexcelmpdf phpexcel common processing # #导入类库require ' phpexcel/classes/phpexcel.php '; require ' phpexcel/ Classes/phpexcel/writer/excel5.php '; Not 07 grid ...

  • 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.