PHPexcel导出PDF文件,调用了domPDF,PDF文档中文都是问号

使用PHPexcel插件导出PDF文件时,调用了domPDF,但是生成的PDF文件,中文都是‘?’,英文正常,如果说编码问题,如何设置?

3个回答

我也遇到了相同问题了,诚意请教大家!

下面是问题链接

不要沉。大家怎么解决的,用哪个方法设置字体呀;或者你们怎么处理的哟

dompdf库默认不支持中文字体,只支持了4种Windows ANSI encoding编码的字体。官方原文PDF d

PDF documents internally support the following fonts: Helvetica, Times-Roman, Courier, Zapf-Dingbats, & Symbol. These fonts only support Windows ANSI encoding. In order for a PDF to display characters that are not available in Windows ANSI, you must supply an external font. 

解决方案:

1.安装DomPDF
composer require dompdf/dompdf
2.下载dompdf字体工具脚本
git clone  https://github.com/dompdf/utils.git
将文件夹中的load_font.php、autoload.inc.php复制到 dompdf目录中,与lib 和 src 目录同级
重命名autoload.inc.php为autoload.php;打开autolaod.php,修改php-font-lib和php-svg-lib为自己实际目录
修改load_foot.php文件中的autload.php目录为./autoload.php
3.下载支持中文的ttf字体
simsum字体,下载地址:https://ufonts.com/download/simsun/82073.html
将文件夹中的lsimsun.ttf复制到 dompdf目录中,与lib 和 src 目录同级
4.安装字体
php load_font.php 'simsun'  simsun.ttf
没有意外,在vendor/dompdf/dompdf/lib/fonts/目录下将产生相应的文件simsun.ttf,simsun.ufm
5.如何使用字体
在调用dompdf工具的时候,直接将字体名写入CSS代码,例如:
$header = "<style>* {font-family: \"simsun\"}</style>";
$html = $header.$result["content"];
$pdfManager = new Dompdf();
$pdfManager->loadHtml($html);
$pdfManager->render();
$pdfManager->stream();
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
phpexcel导出excel文件输出求和问题

phpexce导出excel文件用求和公式->setCellValue('E2', "=SUM(D4:D100)")输出到E2单元格,我想把这个求和结果变成数值,非公式的,怎么改

php上传excel导出pdf~菜鸟求教,大神指点

烦了我三个星期的需求:在线excel转pdf。 需求是把excel上传后经过php转为pdf,我开是利用了phpexcel,上传后再用tcpdf生成,但是phpexcel无法,或者说找不到获取列宽和行高的函数。然后就直接用phpexcel调用tcpdf的类库输出,但是就生成乱码 - -。 目前使用的环境是PHP5.4+linux+tengine 现在有几个问题,想请教各路大神: 1.phpexcel如何获取列宽和行高 2.如何生成pdf的时候不乱码 3.如果excel的内容太多如何移至下一页 不过如果有别的方法可以的话,也告诉我吧。

thinkphp5 里面怎么引入phpexcel导出xls呢

把phpexcel存到哪个目录,给一个最简单的导出xls的demo吧。导出任意一个数组到excel文件中

PHPExcel导出时无法保存,因为无法读取源文件

使用PHPexcel 导出时,在google 浏览器时下载会出现网络错误。 在Firefox 下载时读取不到源文件![图片说明](https://img-ask.csdn.net/upload/201812/18/1545103044_440383.png) 我的配置是这样的。 ``` ob_end_clean(); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header('Content-Disposition:inline;filename="'.$savefile.'.xls'); header("Content-Transfer-Encoding: binary"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); ``` 大佬们看下有啥问题吗

利用phpexcel导出excel中如何X轴和Y轴都循环输出

![图片说明](https://img-ask.csdn.net/upload/201707/24/1500884149_528129.jpg) 导出的Excel效果如图所示。 大概就是Y轴读取SQL以姓名循环输出,X轴以各时间段分别输出各科的成绩,这样X轴Y轴都循环的phpexcel导出如何实现?单独Y轴循环的输出我就会。求大神指教,最好有代码案例,谢谢!

php导出Excel,用PHPExcel导出

如题,做一个php的程序,需要导出excel,利用PHPExcel导出的,但导出的excel文件,一开始多了个回车,用文本编辑器打开,将回车删除后, 再打开导出的Excel就没问题了。求解。。。

PHPExcel 怎么在导出的时候 给单元格加公式呢

急 PHPExcel怎么在导出的时候给单元格加上公式 计算某一列的值 求大神帮忙

PHPExcel图表包含导入文件的输出已损坏

<div class="post-text" itemprop="text"> <p>I'm a biologist and try to handle a ton of data from FlowCytometry then handling it with Excel. I have exported my files in csv then I tried to put them in a pre created Excel file with php. I figured out when I read and write exactly the same Excel file with PHPExcel PHP extension it doesn't handles my charts the output file is corrupt, and Excel prompting to fix and fixes it without the charts.</p> <p>I simplified my files without any new input and produces the same results, can you help me to fix this?</p> <p>My simplified code:</p> <pre><code>/** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); ini_set('max_execution_time', '-1'); ini_set('memory_limit', '512M'); date_default_timezone_set('Europe/London'); define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '&lt;br /&gt;'); /** Include PHPExcel */ require_once dirname(__FILE__) . '/../PHPExcel/Classes/PHPExcel.php'; $txtOutputExcelName = "Histogram.xlsx"; // Create new PHPExcel object echo date('H:i:s') , " Create new PHPExcel object from import" , EOL; // Sample File Name that is going to be cloned $inputFileName = './sample/Analysis_sample.xlsx'; $objPHPExcel = new PHPExcel(); $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objReader-&gt;setIncludeCharts(TRUE); $objPHPExcel = $objReader-&gt;load($inputFileName); // Save Excel 2007 file echo date('H:i:s') , " Write to Excel2007 format" , EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter-&gt;setIncludeCharts(TRUE); $objWriter-&gt;save($txtOutputExcelName); </code></pre> <p>My simplified Excel file is here: <a href="https://dl.dropboxusercontent.com/u/4860217/Analysis_sample.xlsx" rel="nofollow">https://dl.dropboxusercontent.com/u/4860217/Analysis_sample.xlsx</a></p> <p>Thank you for your help, Zoltan</p> <ul> <li>Mac OS X 10.11.4</li> <li>PHP version 7.0.0</li> <li>PHPExcel 1.8.1</li> </ul> </div>

使用PHPExcel将xlsx转换为pdf并下载该pdf。 在localhost上工作正常

<div class="post-text" itemprop="text"> <p>This code works fine on localhost but on live server it shows</p> <blockquote> <p>File Not Found</p> </blockquote> <p>Check the file name for capitalization or other typing errors. Check to see if the file was moved, renamed or deleted.</p> <p>Here is my code </p> <p><strong>excel.php</strong></p> <pre><code>&lt;?php error_reporting(1); ini_set('display_errors', 0); ini_set('display_startup_errors', TRUE); $target = 'Myfile.xlsx'; include 'phpexcel/Classes/PHPExcel/IOFactory.php'; $inputFileType = PHPExcel_IOFactory::identify($target); function datefix_excel($excel) { $dif=(41885-$excel)*86400; $seconds=1409737670-$dif; $date=date("d/m/Y",$seconds); return $date; } //echo 'File ',pathinfo($inputFileName,PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file&lt;br /&gt;'; //echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with the identified reader type&lt;br /&gt;'; $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader-&gt;load($target); $i = 0; $found = false; try { // foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) { // //$objWorksheet = $objPHPExcel-&gt;getActiveSheet(); //now do whatever you want with the active sheet $worksheet-&gt;setShowGridLines(false); $worksheet-&gt;getPageSetup()-&gt;setOrientation(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER ); $worksheet-&gt;getPageSetup()-&gt;setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER ); $worksheet-&gt;getPageSetup()-&gt;setFitToPage(true); $worksheet-&gt;getPageSetup()-&gt;setFitToWidth(1); $worksheet-&gt;getPageSetup()-&gt;setFitToHeight(0); $worksheet-&gt;getPageSetup()-&gt;setScale(40); $worksheet-&gt;getStyle('F1:F4')-&gt;getAlignment()-&gt;setWrapText(false); $worksheet-&gt;getStyle('D6:D8')-&gt;getAlignment()-&gt;setWrapText(false); $sheetData = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null,true,true,true); $count = 0; $found == false; // $worksheetTitle = $worksheet-&gt;getTitle(); $highestRow = $worksheet-&gt;getHighestRow(); // e.g. 10 $highestColumn = $worksheet-&gt;getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $nrColumns = ord($highestColumn) - 64; for ($row = 1; $row &lt;= $highestRow; ++ $row) { for ($col = 0; $col &lt; $highestColumnIndex; ++ $col) { $cell = $worksheet-&gt;getCellByColumnAndRow($col, $row); $val = $cell-&gt;getValue(); if($val==$_REQUEST['roll']) { //echo "Roll Number found: ".$_REQUEST['roll']." &lt;br/&gt;"; $found = true; // $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('C23',$val); $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('C23',datefix_excel($objPHPExcel-&gt;getActiveSheet()-&gt;getCell('C23')-&gt;getValue())); $rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF; $rendererLibrary = 'dompdf'; $rendererLibraryPath = './' . $rendererLibrary; //require_once (realpath(dirname(dirname(dirname(__FILE__))))."/libraries/pdf.php"); //echo $rendererName.' and '.$rendererLibraryPath; if (!PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) { die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' .EOL .'at the top of this script as appropriate for your directory structure'); } header("HTTP/1.1 200 OK"); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="rename.pdf"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter-&gt;setSheetIndex($i); //$objWriter-&gt;save('test.pdf'); $objWriter-&gt;save('php://output'); break; } else{ continue; } } } // } } catch(Exception $e) { //echo $e; } ?&gt; </code></pre> </div>

使用phpexcel保存pdf会终止脚本的其余部分

<div class="post-text" itemprop="text"> <p>the echo statement is not running and the below script is also not running</p> <pre><code>header("HTTP/1.1 200 OK"); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="rename.pdf"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter-&gt;setSheetIndex($i); $objWriter-&gt;save('php://output'); echo "this is not diplaying"; //code get terminated </code></pre> </div>

使用dompdf库在PHPExcel中生成pdf文件

<div class="post-text" itemprop="text"> <p>Using dompdf library generate the pdf file, while i opened that pdf file it shows failed to load content error. I set renderer path and renderer library given below.</p> <p>$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF; $rendererLibrary = 'dompdf.php'; $rendererLibraryPath = name(<strong>FILE</strong>).'/../dompdf/libraries/dompdf/'.$rendererLibrary;</p> </div>

基本PHPExcel输出Excel文件

<div class="post-text" itemprop="text"> <p>I am using PHPExcel and executed their sample code as displayed on the website: <a href="https://phpexcel.codeplex.com/wikipage?title=Examples&amp;referringTitle=Home" rel="nofollow">https://phpexcel.codeplex.com/wikipage?title=Examples&amp;referringTitle=Home</a></p> <p>However, I can see the codes running well because I see this "message"</p> <p>10:50:52 Create new PHPExcel object 10:50:52 Set properties 10:50:52 Add some data 10:50:52 Rename sheet 10:50:52 Write to Excel2007 format 10:50:52 Done writing file.</p> <p>But I wasn't given an option to download any file? How do I trigger them to ask me to download the file?</p> </div>

页眉/页脚和分页未使用mPDF和PHPExcel导出?

<div class="post-text" itemprop="text"> <p>I use mPDF with PHPExcel and it seems like headers and footers are not exported from my excel content. Is there a way around that?</p> <p>If not, can I re-create/add the headers and footers right before the PDF is created?</p> <p>If not, is there a way to just add page numbers to the pdf?</p> <p>Thanks!</p> <p>Edit // More code. See the Header/Footer part:</p> <pre><code>PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP); $objReader = PHPExcel_IOFactory::createReader("Excel2007"); $objReader-&gt;setIncludeCharts(TRUE); $objPHPExcel = $objReader-&gt;load("excel.xlsx"); $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF; $rendererLibraryPath = dirname(__FILE__) . '/mpdf'; $objWorksheet = $objPHPExcel-&gt;getActiveSheet(); // Header and Footer $title = "Title"; $sub_title = "Subtitle"; $sub_title = "Title"; $date_exported = date('Y-m-d H:i'); $objWorksheet -&gt;getHeaderFooter()-&gt;setOddHeader('&amp;L&amp;14'.$title." &amp;11".$sub_title."&amp;R&amp;10Exported with PHP " . $date_exported); $objWorksheet -&gt;getHeaderFooter()-&gt;setEvenHeader('&amp;L&amp;14'.$title." &amp;11".$sub_title."&amp;R&amp;10Exported with PHP " . $date_exported); $objWorksheet -&gt;getHeaderFooter()-&gt;setOddFooter("&amp;RPage &amp;P of &amp;N"); $objWorksheet -&gt;getHeaderFooter()-&gt;setEvenFooter("&amp;RPage &amp;P of &amp;N"); $excelRow = 1; $excelCol = 0; $columns = Array('Title 1','Title 2','Title 3'); foreach($columns as $column_title) { $objWorksheet-&gt;setCellValueByColumnAndRow($excelCol, $excelRow, $column_title); $objWorksheet-&gt;getCellByColumnAndRow($excelCol,$excelRow)-&gt;getStyle()-&gt;applyFromArray( array( 'font' =&gt; array( 'bold' =&gt; true, ), 'alignment' =&gt; array( 'horizontal' =&gt; PHPExcel_Style_Alignment::HORIZONTAL_LEFT, ), 'borders' =&gt; array( 'top' =&gt; array( 'style' =&gt; PHPExcel_Style_Border::BORDER_THIN, 'color' =&gt; array('rgb' =&gt; '000000') ), 'bottom' =&gt; array( 'style' =&gt; PHPExcel_Style_Border::BORDER_THIN, 'color' =&gt; array('rgb' =&gt; '000000') ) ), 'fill' =&gt; array( 'type' =&gt; PHPExcel_Style_Fill::FILL_SOLID, 'color' =&gt; array('rgb' =&gt; 'd9d9d9') ) ) ); $objWorksheet-&gt;getColumnDimensionByColumn($excelCol)-&gt;setAutoSize(true); $objWorksheet-&gt;getCellByColumnAndRow($excelCol,$excelRow)-&gt;getStyle()-&gt;getAlignment()-&gt;setWrapText(false); $excelCol++; } $objWorksheet-&gt;getPageSetup()-&gt;setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $objWorksheet-&gt;getPageSetup()-&gt;setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER); $objWorksheet-&gt;getPageSetup()-&gt;setFitToPage(true); $objWorksheet-&gt;getPageSetup()-&gt;setFitToWidth(1); $objWorksheet-&gt;getPageSetup()-&gt;setFitToHeight(0); $objWorksheet-&gt;getPageMargins()-&gt;setTop(0.5); $objWorksheet-&gt;getPageMargins()-&gt;setRight(0.7); $objWorksheet-&gt;getPageMargins()-&gt;setBottom(0.5); $objWorksheet-&gt;getPageMargins()-&gt;setLeft(0.75); if (!PHPExcel_Settings::setPdfRenderer( $rendererName, $rendererLibraryPath )) { die( 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '&lt;br /&gt;' . 'at the top of this script as appropriate for your directory structure' ); } header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="pdf.pdf"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter-&gt;save('php://output'); exit; </code></pre> </div>

PHPExcel - 有时当我下载excel文件时它已损坏,有时它可以正常工作

<div class="post-text" itemprop="text"> <p>Im trying to convert a html table to excel using PHPExcel. The thing is, sometimes i get an error ('Cannot open file cause its format/extension is corrupted' and other times it doesnt and it runs perfectly. Usually i get the error on the first 3 times i try to create the file and at the fourth time it goes well.</p> <p>Does anyone have an idea on why this happens? I thought about the amount of information i put on the table but to be honest i dont know.</p> <pre><code>&lt;?php session_start(); require_once '../classes/PHPExcel-1.8/Classes/PHPExcel.php'; ini_set('max_execution_time', 300); $servidorodbc=file('../public/odbc.txt',FILE_IGNORE_NEW_LINES); $dsn=$servidorodbc['0']; $user=$servidorodbc['1']; $pwd=$servidorodbc['2']; if($pwd="''"){ $pwd=""; } $ano = addslashes( $_SESSION['anopr']); $mes = addslashes( $_SESSION['mespr']); $db = odbc_connect($dsn, $user, $pwd); $query = odbc_exec($db, "Select Cliente,Nome_Cli,CCusto,Descricao,Codigo,Nome,Tipo,Provisoes,Pagamentos,Acrescimos,Liquidacoes,Saldo,Ac_Provisoes,Ac_Pagamento,Ac_Acrescimos,Ac_Liquidacoes,Ac_Saldo,Amor_Abertura,Amor_Utilizacao,Amor_Fecho,Amor_Saldo from GP_Provisoes_Acum where Ano=".$ano." and Mes=".$mes." union all Select Cliente=0,Nome_Cli='',CCusto=0,Descricao='SOMATÓRIOS TOTAIS',Codigo=0,Nome='',Tipo='TOTAL', SUM(Provisoes) as Provisoes, SUM(Pagamentos) as Pagamentos,SUM(Acrescimos) as Acrescimos, SUM(Liquidacoes) as Liquidacoes,SUM(Saldo) as Saldo, SUM(Ac_Provisoes) as Ac_Provisoes, SUM(Ac_Pagamento) as Ac_Pagamento, SUM(Ac_Acrescimos) as Ac_Acrescimos, SUM(Ac_Liquidacoes) as Ac_Liquidacoes, SUM(Ac_Saldo) as Ac_Saldo, Amor_Abertura=0,Amor_Utilizacao=0,Amor_Fecho=0,Amor_Saldo=0 from GP_Provisoes_Acum where Ano=".$ano." and Mes=".$mes ); $objPHPExcel = new PHPExcel(); $rowCount = 1; $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('A'.$rowCount,'Cliente'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('B'.$rowCount,'Nome do Cliente'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('C'.$rowCount,'Centro de Custo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('D'.$rowCount,'Descricao'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('E'.$rowCount,'Codigo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('F'.$rowCount,'Nome'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('G'.$rowCount,'Tipo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('H'.$rowCount,'Provisoes'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('I'.$rowCount,'Pagamentos'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('J'.$rowCount,'Acrescimo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('K'.$rowCount,'Liquidacoes'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('L'.$rowCount,'Saldo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('M'.$rowCount,'Ac_Provisoes'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('N'.$rowCount,'Ac_Pagamento'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('O'.$rowCount,'Ac_Acrescimo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('P'.$rowCount,'Ac_Liquidacoes'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('Q'.$rowCount,'Ac_Saldo'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('R'.$rowCount,'Amor_Abertura'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('S'.$rowCount,'Amor_Utilização'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('T'.$rowCount,'Amor_Fecho'); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('U'.$rowCount,'Amor_Saldo'); while ($row = odbc_fetch_array($query)){ $rowCount++; $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('A'.$rowCount,$row['Cliente']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('B'.$rowCount,$row['Nome_Cli']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('C'.$rowCount,$row['CCusto']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('D'.$rowCount,$row['Descricao']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('E'.$rowCount,$row['Codigo']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('F'.$rowCount,$row['Nome']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('G'.$rowCount,$row['Tipo']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('H'.$rowCount,$row['Provisoes']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('I'.$rowCount,$row['Pagamentos']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('J'.$rowCount,$row['Acrescimos']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('K'.$rowCount,$row['Liquidacoes']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('L'.$rowCount,$row['Saldo']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('M'.$rowCount,$row['Ac_Provisoes']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('N'.$rowCount,$row['Ac_Pagamento']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('O'.$rowCount,$row['Ac_Acrescimos']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('P'.$rowCount,$row['Ac_Liquidacoes']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('Q'.$rowCount,$row['Ac_Saldo']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('R'.$rowCount,$row['Amor_Abertura']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('S'.$rowCount,$row['Amor_Utilizacao']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('T'.$rowCount,$row['Amor_Fecho']); $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('U'.$rowCount,$row['Amor_Saldo']); } header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet '); header('Content-Disposition: attachment;filename="Tabela_de_Previsoes.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); ob_end_clean(); $objWriter-&gt;save('php://output'); ?&gt; </code></pre> </div>

如何使用phpExcel模块将excel文件保存为只读模式

<div class="post-text" itemprop="text"> <p>I am trying to get users to save/download my excel file in read-only mode (apache on windows server, all users downloading are using windows).</p> <p>So far, I have looked around for a good solution and have tried everything suggested but nothing seems to be working.</p> <p>I tried adding following lines:</p> <pre><code>$objPHPExcel-&gt;getSecurity()-&gt;setLockWindows(true); $objPHPExcel-&gt;getSecurity()-&gt;setLockStructure(true); </code></pre> <p>but still it is saving in an editable mode. Am I missing something here?</p> <p>I would prefer a solution where above mentioned goal is achieved by using phpexcel but the use of core php is also acceptable.</p> <p>Something that requires a modification to phpexcel core class won't be acceptable as there's a whole bunch of applications developed by other developers in our organisation who assume core class to be untouched.</p> </div>

使用PHPExcel安装DOMPDF

<div class="post-text" itemprop="text"> <p>I am having problems exporting Excel files to <code>.pdf</code> format using <code>DOMPDF</code>. I'm using <code>PHPExcel (1.7.9, 2013-06-02)</code>, <code>TCPDF (6.2.13)</code> and <code>Dompdf (0.7.0)</code>. For the moment the testing of <code>Dompdf</code> is done on a <code>Win10/Wampserver 3.0</code> machine, but I'll have to use it on live server <code>(Apache2.2.22 and PHP5.4.35)</code>. All three packages work OK if used alone, as expected (<code>PHPExcel</code> and <code>TCPDF</code> for more than three years on both test and live servers, and <code>Dompdf</code> was installed just recently on the test bed). In addition I've been able to produce <code>.pdf</code> files with <code>PHPExcel</code> and <code>TCPDF</code>. The code is practically the same as in some of the <code>PHPExcel</code> examples and the crucial part is the following:</p> <pre><code>require_once __phpexcel__ . 'PHPExcel.php'; PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_TCPDF, __tcpdf__);` </code></pre> <p>Where <code>__phpexcel__</code> and <code>__tcpdf__</code> are constants pointing to the directories where the <code>PHPExcel.php</code> and <code>tcpdf.php</code> reside. <code>PHPExcel+TCPDF</code> work fine, but they produce a rather large <code>.pdf</code> file (1.2MB for couple of cells with UTF-8 characters).</p> <p>However, if I try to convert the same <code>.xlsx</code> file using <code>Dompdf</code> I have a problem. The crucial code in this case is</p> <pre><code>require_once __phpexcel__ . 'PHPExcel.php'; PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_DOMPDF, __dompdf__);` </code></pre> <p><code>__dompdf__</code> in this case is the directory where <code>Dompdf</code> files reside (among others: <code>dirs lib</code>, etc and <code>autoload.inc.php</code>).</p> <p>The error I receive is:</p> <blockquote> <p>Fatal error: Class 'DOMPDF' not found in <strong>phpexcel</strong>\PHPExcel\Writer\PDF\DomPDF.php on line 36.</p> </blockquote> <p>After examining the file <code>__phpexcel__\PHPExcel\Writer\PDF\DomPDF.php</code> I found that line 30 in that file is <code>$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';</code> and there is no <code>dompdf_config.inc.php</code> file in the distribution of Dompdf! Changing <code>dompdf_config.inc.php</code> to <code>autoload.inc.php</code> doesn't work!</p> <p>I'm bewildered what should I do. The samples provided at <code>PHPExcel</code> and <code>DOMPDF</code> site do not provide any answers, or I'm not able to find them. </p> </div>

使用php和mysql导出生成的excel文件大小非常大

<div class="post-text" itemprop="text"> <p>I am using php and mysql to generate excel file. Every thing works fine. I am using html table code and exporting data to excel file. But the downloaded file is having bigger size for 20k records it is showing nearly 35 MB. Below is my code .</p> <pre><code>&lt;?php $generated_date = date("Y-m-d-H-i-s"); $filename = 'order_detail_report'.$generated_date; header("Content-Type: application/xls"); header("Content-Disposition: attachment; filename=$filename.xls"); header("Pragma: no-cache"); header("Expires: 0"); ?&gt; </code></pre> <p>Html table code </p> <pre><code>&lt;table width="100%" border="0" cellspacing="0" cellpadding="0" &gt; &lt;tr&gt; &lt;th class="excel_style"&gt;Order Number&lt;/th&gt; &lt;th class="excel_style"&gt;EAN&lt;/th&gt; &lt;th class="excel_style"&gt;Article #&lt;/th&gt; &lt;th class="excel_style"&gt;Amazon Price&lt;/th&gt; &lt;th class="excel_style"&gt;ERP Price&lt;/th&gt; &lt;th class="excel_style"&gt;Requested Quantity&lt;/th&gt; &lt;th class="excel_style"&gt;Dispatch Quantity&lt;/th&gt; &lt;th class="excel_style"&gt;Rejected Quantity&lt;/th&gt; &lt;th class="excel_style"&gt;Cancelled Quantity&lt;/th&gt; &lt;/tr&gt; </code></pre> <p>While loop </p> <pre><code>&lt;?php $query = "my select query"; $res = mysqli_query($mysqliConn,$query); while($result= mysqli_fetch_assoc($res)){ ?&gt; &lt;tr&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['order_id'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['ean'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['article_no'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['net_price'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['erp_price'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['requested_quantity'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['dispatch_quantity']?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['rejected_quanity'];?&gt;&lt;/td&gt; &lt;td class="tdstyle"&gt;&lt;?php echo $result['cancelled_quantity']?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; </code></pre> <p>How to solve this size of the file problem? Any help would be greatly appreciated. If I use phpexcel library I am getting some out of memory exception. So client asked me don't use phpexcel library.</p> </div>

文件格式或扩展名无效的PHPExcel

<div class="post-text" itemprop="text"> <p>I try to use PHPExcel library for my report, this is my first time i use PHPExcel ,but error dialog appear telling that file format / extension invalid ,this is the syntax :</p> <pre><code>include '../_class/PHPExcel.php'; // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel-&gt;getProperties()-&gt;setCreator("Maarten Balliauw") -&gt;setLastModifiedBy("Rizal") -&gt;setTitle("Laporan Anggota") -&gt;setSubject("anggota") -&gt;setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") -&gt;setKeywords("office 2007 openxml php") -&gt;setCategory("Test result file"); // Create the worksheet $objPHPExcel-&gt;setActiveSheetIndex(0); $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A7', "No") -&gt;setCellValue('B7', "NIS") -&gt;setCellValue('C7', "NISN") -&gt;setCellValue('D7', "Name") -&gt;setCellValue('E7', "J.K") -&gt;setCellValue('F7', "Birth") -&gt;setCellValue('G7', "Address") -&gt;setCellValue('H7', "Job") // Redirect output to a client’s web browser (Excel2007) $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter-&gt;save(str_replace('.php', '.xlsx', __FILE__)); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="Test.xlsx"'); header('Cache-Control: max-age=0'); </code></pre> <p>anyone can help me to solve it?</p> </div>

PHPExcel克隆.xlsm与宏

<div class="post-text" itemprop="text"> <p>I'm trying to read, clone and write and .xlsm file with PHPExcel but I get an error: Fatal error: Uncaught exception 'Exception' with message 'Worksheet!G177 -&gt; Formula Error: An unexpected error occured' in...</p> <p>Anybody know how can I read, clone and write and Excel file with macros, I mean the macros are in a template (the file that I reading) I just want to clone that file and write on it, and just keep the macros in the new file. Is that possible with PHPExcel ? is there another library to do that ?</p> <p>Thanks .</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

立即提问
相关内容推荐