当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Settings::setPdfRenderer方法代码示例

本文整理汇总了PHP中PHPExcel_Settings::setPdfRenderer方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Settings::setPdfRenderer方法的具体用法?PHP PHPExcel_Settings::setPdfRenderer怎么用?PHP PHPExcel_Settings::setPdfRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Settings的用法示例。


在下文中一共展示了PHPExcel_Settings::setPdfRenderer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getReport

    public function getReport($id_report)
    {
        $report = end($this->uri->segments);
        $this->setColNames($id_report);
        $this->params['id_report'] = $id_report;
        $this->params['sidx'] = $this->sortColNames;
        $this->params['colNames'] = $this->colNames;
        $this->params['colModels'] = $this->colModels;
        if ($report == 'prev') {
            $this->template->write_view('content', 'custom_report_query/custom_report_query_preview', $this->params, TRUE);
            $this->template->render();
            // render template
        } else {
            if ($report == 'excel') {
                $nColumn = $this->uri->segment(4);
                $segment = 5;
                $listfield = array();
                for ($i = 1; $i < $nColumn; $i++) {
                    $listfield[] = str_replace("%20", " ", $this->uri->segment($segment));
                    $segment++;
                }
                $sName = $this->uri->segment($segment);
                $segment++;
                $sOrder = $this->uri->segment($segment);
                $rows = $this->custom_report_query_model->get_datas($id_report);
                $result = $this->custom_report_query_model->get_report($id_report, $sName, $sOrder)->result_array();
                $oldIncludePath = get_include_path();
                set_include_path(APPPATH . 'libraries/PHPExcel');
                include_once 'PHPExcel.php';
                include_once 'PHPExcel/Writer/Excel2007.php';
                include_once 'PHPExcel/IOFactory.php';
                if ($report == 'excel') {
                    $ext = 'xls';
                    $header = 'vnd.ms-excel';
                    $obj = 'Excel5';
                    $render = false;
                } else {
                    $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
                    $rendererLibrary = 'tcPDF5.9';
                    $rendererLibraryPath = APPPATH . 'libraries/tcpdf';
                    $ext = 'pdf';
                    $header = 'pdf';
                    $obj = 'PDF';
                    $render = true;
                }
                $objPHPExcel = new PHPExcel();
                $objPHPExcel->getProperties()->setTitle("title")->setDescription("description");
                // Assign cell values
                $objPHPExcel->setActiveSheetIndex(0);
                $sheet = $objPHPExcel->getActiveSheet();
                $sheet->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
                $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
                $sheet->setShowGridlines(true);
                foreach ($rows as $row) {
                    $row1 = $row['report_name'];
                    $row2 = $row['req_by'];
                    $row3 = date('d-m-Y');
                }
                $sheet->getRowDimension('1')->setRowHeight(10);
                $sheet->setCellValue('A1', $row1);
                $sheet->setCellValue('A2', $row2);
                $sheet->setCellValue('A3', $row3);
                $char = 65;
                $i = 0;
                foreach ($listfield as $fields) {
                    $sheet->setCellValue(chr($char) . '5', $fields);
                    ${'length' . $i} = strlen($fields);
                    $char++;
                    $i++;
                }
                $char = 65;
                if ($report == 'excel') {
                    for ($j = 0; $j < $i; $j++) {
                        $sheet->getColumnDimension(chr($char))->setAutoSize(true);
                        $char++;
                    }
                }
                $counter = 6;
                foreach ($result as $row) {
                    $char = 65;
                    if ($counter == 6 && $report == 'pdf') {
                        $charX = $char;
                        for ($j = 0; $j < $i; $j++) {
                            if (${'length' . $j} > strlen($row[$listfield[$j]])) {
                                $sheet->getColumnDimension(chr($charX))->setWidth(${'length' . $j} + 4);
                            } else {
                                $sheet->getColumnDimension(chr($charX))->setWidth(30);
                            }
                            $charX++;
                        }
                    }
                    for ($j = 0; $j < $i; $j++) {
                        $sheet->setCellValue(chr($char) . $counter, $row[$listfield[$j]]);
                        $char++;
                    }
                    $counter++;
                }
                if ($render) {
                    if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                        die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '<br />' . 'at the top of this script as appropriate for your directory structure');
//.........这里部分代码省略.........
开发者ID:ibnoe,项目名称:appymz,代码行数:101,代码来源:custom_report_query.php

示例2: pdfExport

 public static function pdfExport($data, $headerTitle = [], $headerRGBColor = 'FCFCFC')
 {
     $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
     $rendererLibraryPath = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'dompdf' . DIRECTORY_SEPARATOR . 'dompdf';
     if (!\PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
         return false;
     }
     $phpExcel = self::init($data, $headerTitle, $headerRGBColor);
     $objWriter = \PHPExcel_IOFactory::createWriter($phpExcel, 'PDF');
     $objWriter->save('php://output');
     return true;
 }
开发者ID:ashmna,项目名称:MedDocs,代码行数:12,代码来源:ExportData.php

示例3: getBlock

 public static function getBlock()
 {
     session::start();
     $block_path = __DIR__ . '/block/';
     $block_name = str_replace('_class', '', __CLASS__) . '.php';
     self::$block_name = $block_name;
     self::$blocks[$block_name] = ['name' => $block_name, 'path' => $block_path];
     // Create new PHPExcel object
     $xls = new PHPExcel();
     // Устанавливаем индекс активного листа
     $xls->setActiveSheetIndex(0);
     // Получаем активный лист
     $sheet = $xls->getActiveSheet();
     // Подписываем лист
     $sheet->setTitle('Таблица умножения');
     // Вставляем текст в ячейку A1
     $sheet->setCellValue("A1", 'Таблица умножения');
     $sheet->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('A1')->getFill()->getStartColor()->setRGB('EEEEEE');
     // Объединяем ячейки
     $sheet->mergeCells('A1:H1');
     // Выравнивание текста
     $sheet->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     for ($i = 2; $i < 10; $i++) {
         for ($j = 2; $j < 10; $j++) {
             // Выводим таблицу умножения
             $sheet->setCellValueByColumnAndRow($i - 2, $j, $i . "x" . $j . "=" . $i * $j);
             // Применяем выравнивание
             $sheet->getStyleByColumnAndRow($i - 2, $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         }
     }
     //Сохранение листа excel в PDF рабочий вариант
     //1. скачать tcpdf, распаковать в classes
     //2. в PHPExcel/Settings строка 49 заменить tcPDF на tcpdf
     //3. далее работающий код
     $rendererLibrary = 'tcpdf';
     $rendererLibraryPath = 'app/classes/' . $rendererLibrary;
     PHPExcel_Settings::setPdfRenderer('tcpdf', $rendererLibraryPath);
     $path = 'files/asdfg1_' . date('i') . '_' . date('s') . '.pdf';
     $objWriter = new PHPExcel_Writer_PDF($xls);
     $objWriter = PHPExcel_IOFactory::createWriter($xls, 'PDF');
     $objWriter->setSheetIndex(0);
     $objWriter->save($path);
     self::$values['path'] = $path;
     //echo
     //controller::call('/main/get_pdf', ['params' => ['path' => 'files/asdfg1.pdf']]);
     return self::show();
 }
开发者ID:Ate1st,项目名称:test,代码行数:48,代码来源:phpexcel_block_class.php

示例4: getThumbnail

 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     require_once 'PHPExcel/Classes/PHPExcel.php';
     require_once 'PHPExcel/Classes/PHPExcel/IOFactory.php';
     $absPath = $fileview->toTmpFile($path);
     $tmpPath = \OC_Helper::tmpFile();
     $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
     $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
     \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
     $phpexcel = new \PHPExcel($absPath);
     $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
     $excel->save($tmpPath);
     $pdf = new \imagick($tmpPath . '[0]');
     $pdf->setImageFormat('jpg');
     unlink($absPath);
     unlink($tmpPath);
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     return $image->valid() ? $image : false;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:20,代码来源:office-fallback.php

示例5: exportData

 public function exportData($filename, $type = 'xlsx')
 {
     if ($type == 'xlsx' || ($type = 'pdf')) {
         if (!is_dir('export')) {
             @mkdir('export', 0777, true);
         }
         if (isset($this->config['table_alias']) && array_key_exists($this->getTable(), $this->config['table_alias'])) {
             $name = $this->config['table_alias'][$this->getTable()];
         } else {
             $name = $this->getTable();
         }
         $path = 'export/' . ($filename == '' ? $name == '' ? uniqid() : $name : $filename);
         if (file_exists($path . '.' . $type)) {
             $path .= '_' . uniqid();
         }
         $path .= '.' . $type;
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator('User')->setLastModifiedBy('User')->setTitle("Database table dump")->setSubject("Database table dump")->setDescription("Database table dump generated on " . date('Y-m-d , H:i:s', time()))->setKeywords("dump")->setCategory("dumps");
         $objPHPExcel->setActiveSheetIndex(0);
         $objPHPExcel->getActiveSheet()->setTitle(substr($name, 0, 30));
         $column = 0;
         $info = $this->getInfo();
         $objPHPExcel->getActiveSheet()->getStyle('A1:' . chr(65 + count($this->getData()) - 1) . '1')->getFont()->setBold(true);
         foreach ($this->getData() as $title => $lines) {
             if ($info[$title]['width'] != 0) {
                 $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($column)->setWidth($info[$title]['width']);
             }
             if ($info[$title]['height'] != 0) {
                 $objPHPExcel->getActiveSheet()->getColumnDimensionByRow($row)->setHeight($info[$title]['height']);
             }
             if (isset($this->config['column_alias']) && array_key_exists($title, $this->config['column_alias'])) {
                 $title = $this->config['column_alias'][$title];
             }
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, 1, $title);
             $row = 2;
             foreach ($lines as $line) {
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, $row, $line);
                 $row++;
             }
             $column++;
         }
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
         if ($type == 'xlsx') {
             $objWriter->save('../' . $path);
         } else {
             $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
             $rendererLibrary = 'tcPDF5.9';
             $rendererLibraryPath = dirname(__FILE__) . '/tcpdf';
             $objPHPExcel->getActiveSheet()->setShowGridLines(false);
             $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
             if (count($this->getData()) < 5) {
                 $pageSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5;
             } else {
                 if (count($this->getData()) < 15) {
                     $pageSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4;
                 } else {
                     if (count($this->getData()) < 25) {
                         $pageSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_PAPER;
                     } else {
                         if (count($this->getData()) < 30) {
                             $pageSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER;
                         } else {
                             $pageSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4;
                         }
                     }
                 }
             }
             $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize($pageSize);
             if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                 die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' . PHP_EOL . 'at the top of this script as appropriate for your directory structure');
             }
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
             $objWriter->setSheetIndex(0);
             $objWriter->save('../' . $path);
         }
         return $path;
     }
     return false;
 }
开发者ID:pceuropa,项目名称:Export-Sql-to-Xlsx-PDF,代码行数:79,代码来源:export_class.php

示例6: product_actions


//.........这里部分代码省略.........
                 if (!(bool) ($r & 1)) {
                     $html .= '<td></td>';
                 }
                 $html .= '</tr></tbody></table>';
                 $this->data['r'] = $r;
                 $this->data['html'] = $html;
                 $this->data['categories'] = $this->site->getAllCategories();
                 $bc = array(array('link' => base_url(), 'page' => lang('home')), array('link' => site_url('products'), 'page' => lang('products')), array('link' => '#', 'page' => lang('print_barcodes')));
                 $meta = array('page_title' => lang('print_barcodes'), 'bc' => $bc);
                 $this->page_construct('products/print_barcodes', $meta, $this->data);
                 //$this->load->view($this->theme . 'products/print_barcodes', $this->data);
             }
             if ($this->input->post('form_action') == 'export_excel' || $this->input->post('form_action') == 'export_pdf') {
                 $this->load->library('excel');
                 $this->excel->setActiveSheetIndex(0);
                 $this->excel->getActiveSheet()->setTitle('Products');
                 $this->excel->getActiveSheet()->SetCellValue('A1', lang('product_code'));
                 $this->excel->getActiveSheet()->SetCellValue('B1', lang('product_name'));
                 $this->excel->getActiveSheet()->SetCellValue('C1', lang('category_code'));
                 $this->excel->getActiveSheet()->SetCellValue('D1', lang('unit'));
                 $this->excel->getActiveSheet()->SetCellValue('E1', lang('cost'));
                 $this->excel->getActiveSheet()->SetCellValue('F1', lang('price'));
                 $this->excel->getActiveSheet()->SetCellValue('G1', lang('alert_quantity'));
                 $this->excel->getActiveSheet()->SetCellValue('H1', lang('tax_rate'));
                 $this->excel->getActiveSheet()->SetCellValue('I1', lang('tax_method'));
                 $this->excel->getActiveSheet()->SetCellValue('J1', lang('subcategory_code'));
                 $this->excel->getActiveSheet()->SetCellValue('K1', lang('product_variants'));
                 $this->excel->getActiveSheet()->SetCellValue('L1', lang('pcf1'));
                 $this->excel->getActiveSheet()->SetCellValue('M1', lang('pcf2'));
                 $this->excel->getActiveSheet()->SetCellValue('N1', lang('pcf3'));
                 $this->excel->getActiveSheet()->SetCellValue('O1', lang('pcf4'));
                 $this->excel->getActiveSheet()->SetCellValue('P1', lang('pcf5'));
                 $this->excel->getActiveSheet()->SetCellValue('Q1', lang('pcf6'));
                 $row = 2;
                 foreach ($_POST['val'] as $id) {
                     $product = $this->products_model->getProductDetail($id);
                     $variants = $this->products_model->getProductOptions($id);
                     $product_variants = '';
                     foreach ($variants as $variant) {
                         $product_variants .= trim($variant->name) . '|';
                     }
                     $this->excel->getActiveSheet()->SetCellValue('A' . $row, $product->code);
                     $this->excel->getActiveSheet()->SetCellValue('B' . $row, $product->name);
                     $this->excel->getActiveSheet()->SetCellValue('C' . $row, $product->category_code);
                     $this->excel->getActiveSheet()->SetCellValue('D' . $row, $product->unit);
                     $this->excel->getActiveSheet()->SetCellValue('E' . $row, $product->cost);
                     $this->excel->getActiveSheet()->SetCellValue('F' . $row, $product->price);
                     $this->excel->getActiveSheet()->SetCellValue('G' . $row, $product->alert_quantity);
                     $this->excel->getActiveSheet()->SetCellValue('H' . $row, $product->tax_rate_code);
                     $this->excel->getActiveSheet()->SetCellValue('I' . $row, $product->tax_method ? lang('exclusive') : lang('inclusive'));
                     $this->excel->getActiveSheet()->SetCellValue('J' . $row, $product->subcategory_code);
                     $this->excel->getActiveSheet()->SetCellValue('K' . $row, $product_variants);
                     $this->excel->getActiveSheet()->SetCellValue('L' . $row, $product->cf1);
                     $this->excel->getActiveSheet()->SetCellValue('M' . $row, $product->cf2);
                     $this->excel->getActiveSheet()->SetCellValue('N' . $row, $product->cf3);
                     $this->excel->getActiveSheet()->SetCellValue('O' . $row, $product->cf4);
                     $this->excel->getActiveSheet()->SetCellValue('P' . $row, $product->cf5);
                     $this->excel->getActiveSheet()->SetCellValue('Q' . $row, $product->cf6);
                     $row++;
                 }
                 $this->excel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
                 $this->excel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
                 $this->excel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
                 $this->excel->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
                 $filename = 'products_' . date('Y_m_d_H_i_s');
                 if ($this->input->post('form_action') == 'export_pdf') {
                     $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
                     $this->excel->getDefaultStyle()->applyFromArray($styleArray);
                     $this->excel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
                     require_once APPPATH . "third_party" . DIRECTORY_SEPARATOR . "MPDF" . DIRECTORY_SEPARATOR . "mpdf.php";
                     $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
                     $rendererLibrary = 'MPDF';
                     $rendererLibraryPath = APPPATH . 'third_party' . DIRECTORY_SEPARATOR . $rendererLibrary;
                     if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                         die('Please set the $rendererName: ' . $rendererName . ' and $rendererLibraryPath: ' . $rendererLibraryPath . ' values' . PHP_EOL . ' as appropriate for your directory structure');
                     }
                     header('Content-Type: application/pdf');
                     header('Content-Disposition: attachment;filename="' . $filename . '.pdf"');
                     header('Cache-Control: max-age=0');
                     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF');
                     return $objWriter->save('php://output');
                 }
                 if ($this->input->post('form_action') == 'export_excel') {
                     header('Content-Type: application/vnd.ms-excel');
                     header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
                     header('Cache-Control: max-age=0');
                     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
                     return $objWriter->save('php://output');
                 }
                 redirect($_SERVER["HTTP_REFERER"]);
             }
         } else {
             $this->session->set_flashdata('error', $this->lang->line("no_product_selected"));
             redirect($_SERVER["HTTP_REFERER"]);
         }
     } else {
         $this->session->set_flashdata('error', validation_errors());
         redirect($_SERVER["HTTP_REFERER"]);
     }
 }
开发者ID:princejeru10,项目名称:dras,代码行数:101,代码来源:Products.php

示例7: update_data


//.........这里部分代码省略.........
             }
             $gtans = array_merge($gtans, array('form_id' => $submmission['form_id']));
             $gtans = array_merge($gtans, array('created_at' => $submmission['created_at']));
             $gtans2 = array_merge($gtans2, array('created_at' => $submmission['created_at']));
             $export_data[] = $gtans2;
             $answers[] = $gtans;
         }
     }
     $this->data = $answers;
     // sortable column
     $sc = array();
     $cts = $column_title;
     unset($cts['cb']);
     foreach ($cts as $key => $val) {
         $sc[$key] = array($key, TRUE);
     }
     $this->sortable_columns = $sc;
     // hidden
     $this->hidden_columns = array('form_id');
     // export to excel
     if (isset($_REQUEST['exportTo'])) {
         //$this->rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
         //$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
         $this->rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
         //$this->rendererLibrary = 'tcPDF.php';
         //$rendererLibrary = 'mPDF.php';
         //$rendererLibrary = 'domPDF0.6.0beta3';
         $this->rendererLibrary = 'dompdf';
         $this->rendererLibraryPath = JC_PATH_INCLUDES . '/PHPExcel/Writer/PDF/' . $this->rendererLibrary;
         if ($_REQUEST['exportTo'] == 'xls') {
             $flname = $form_name . ' (' . date("Y-m-d H-i-s") . ')' . '.xls';
         } else {
             if ($_REQUEST['exportTo'] == 'pdf') {
                 if (!PHPExcel_Settings::setPdfRenderer($this->rendererName, $this->rendererLibraryPath)) {
                     die("Unable to load PDF Rendering library");
                     exit;
                 }
                 $flname = $form_name . ' (' . date("Y-m-d H-i-s") . ')' . '.pdf';
             }
         }
         // Create new PHPExcel object
         $objPHPExcel = new PHPExcel();
         ob_start();
         // Set document properties
         $objPHPExcel->getProperties()->setCreator("Form Generator - Powered by Jotform")->setLastModifiedBy("Form Generator - Powered by Jotform")->setTitle($flname)->setSubject($flname)->setDescription("")->setKeywords("")->setCategory("");
         // Add First Rows / Column Title
         $ndx = 0;
         foreach ($export_columns as $column) {
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($ndx, 1, $column);
             // set background color for header
             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($ndx, 1)->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'c6efce'))));
             $ndx++;
         }
         $row = 2;
         foreach ($export_data as $datas) {
             $col = 0;
             foreach ($datas as $data) {
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data);
                 $col++;
             }
             $row++;
         }
         // Auto width
         if ($_REQUEST['exportTo'] == 'xls') {
             for ($x = 0; $x <= count($export_columns); $x++) {
                 $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($x)->setAutoSize(true);
开发者ID:elolli,项目名称:DreamItReelProductions-Website,代码行数:67,代码来源:submissions-template.php

示例8: generatePDFFile

 /**
  * @param $result
  * @param $headerRow
  * @param $pdfFileName
  * @param bool $fieldsList
  */
 public static function generatePDFFile($result, $headerRow, $pdfFileName, $fieldsList = false, $bar = null, &$cpBar)
 {
     set_error_handler('handleFalseError');
     $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
     $rendererLibrary = 'mPDF5.4';
     $rendererLibraryPath = LIBS . '/PDF/' . $rendererLibrary;
     $objPHPExcel = self::buildExcelFile($result, $headerRow, $fieldsList, $bar, $cpBar);
     if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
         die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '<br />' . 'at the top of this script as appropriate for your directory structure');
     }
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
     $objWriter->save($pdfFileName . ".pdf");
 }
开发者ID:arnon22,项目名称:transportcm,代码行数:19,代码来源:FileManager.php

示例9: dirname

//		and its directory location on your server
//$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
//$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
//$rendererLibrary = 'tcPDF5.9';
$rendererLibrary = 'mPDF5.4';
//$rendererLibrary = 'domPDF0.6.0beta3';
$rendererLibraryPath = dirname(__FILE__) . '/../../../libraries/PDF/' . $rendererLibrary;
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("PDF Test Document")->setSubject("PDF Test Document")->setDescription("Test document for PDF, generated using PHP classes.")->setKeywords("pdf php")->setCategory("Test result file");
// Add some data
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Hello')->setCellValue('B2', 'world!')->setCellValue('C1', 'Hello')->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A4', 'Miscellaneous glyphs')->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->getActiveSheet()->setShowGridLines(false);
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
    die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '<br />' . 'at the top of this script as appropriate for your directory structure');
}
// Redirect output to a client’s web browser (PDF)
header('Content-Type: application/pdf');
header('Content-Disposition: attachment;filename="01simple.pdf"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save('php://output');
exit;
开发者ID:arjunkumar786,项目名称:faces,代码行数:31,代码来源:01simple-download-pdf.php

示例10: array

$qryEleves = $db->prepare($sql);
$lblEleves = array('Nom', 'Prénom', 'Téléphone', 'Natel père', 'Natel mère', 'Adresse e-mail', 'Adresse', 'NPA', 'Ville');
// Spreadsheet columns
define('COL_EMAIL', 'F');
define('COL_NPA', 'H');
// The worksheet's last column is determined by the number of fields returned
// by the query to retrieve children, minus 1 (the degre is not shown)
$last_col = PHPExcel_Cell::stringFromColumnIndex(count($lblEleves) - 1);
// Statistics
$classe_count = 0;
$classe_effectif = 0;
$total_effectif = 0;
$total_eleves = 0;
// Set PDF renderer
if (ExportFileFormat::isPDF()) {
    PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_MPDF, $pdf_renderer_path) or die("Impossible d'initialiser le générateur de PDF");
}
// Autosize columns: set font path to improve columns' width estimation.
if (php_uname('s') == 'Linux') {
    $font_path = '/usr/share/fonts/truetype/msttcorefonts/';
} else {
    $font_path = 'C:/Windows/Fonts/';
}
PHPExcel_Shared_Font::setTrueTypeFontPath($font_path);
// ----------------------------------------------------------------------------
// Process classes
//
echo "\n";
foreach ($qryClasses as $classe) {
    $classe_count++;
    // To collect address to whom the list will be sent
开发者ID:dregad,项目名称:apecove,代码行数:31,代码来源:export_classes.php

示例11: getRrgisterlogs

 function getRrgisterlogs($pdf = NULL, $xls = NULL)
 {
     $this->sma->checkPermissions('register', TRUE);
     if ($this->input->get('user')) {
         $user = $this->input->get('user');
     } else {
         $user = NULL;
     }
     if ($this->input->get('start_date')) {
         $start_date = $this->input->get('start_date');
     } else {
         $start_date = NULL;
     }
     if ($this->input->get('end_date')) {
         $end_date = $this->input->get('end_date');
     } else {
         $end_date = NULL;
     }
     if ($start_date) {
         $start_date = $this->sma->fld($start_date);
         $end_date = $this->sma->fld($end_date);
     }
     if ($pdf || $xls) {
         $this->db->select("date, closed_at, CONCAT(" . $this->db->dbprefix('users') . ".first_name, ' ', " . $this->db->dbprefix('users') . ".last_name, ' (', users.email, ')') as user, cash_in_hand, total_cc_slips, total_cheques, total_cash, total_cc_slips_submitted, total_cheques_submitted,total_cash_submitted, note", FALSE)->from("pos_register")->join('users', 'users.id=pos_register.user_id', 'left')->order_by('date desc');
         //->where('status', 'close');
         if ($user) {
             $this->db->where('pos_register.user_id', $user);
         }
         if ($start_date) {
             $this->db->where('date BETWEEN "' . $start_date . '" and "' . $end_date . '"');
         }
         $q = $this->db->get();
         if ($q->num_rows() > 0) {
             foreach ($q->result() as $row) {
                 $data[] = $row;
             }
         } else {
             $data = NULL;
         }
         if (!empty($data)) {
             $this->load->library('excel');
             $this->excel->setActiveSheetIndex(0);
             $this->excel->getActiveSheet()->setTitle(lang('register_report'));
             $this->excel->getActiveSheet()->SetCellValue('A1', lang('open_time'));
             $this->excel->getActiveSheet()->SetCellValue('B1', lang('close_time'));
             $this->excel->getActiveSheet()->SetCellValue('C1', lang('user'));
             $this->excel->getActiveSheet()->SetCellValue('D1', lang('cash_in_hand'));
             $this->excel->getActiveSheet()->SetCellValue('E1', lang('cc_slips'));
             $this->excel->getActiveSheet()->SetCellValue('F1', lang('cheques'));
             $this->excel->getActiveSheet()->SetCellValue('G1', lang('total_cash'));
             $this->excel->getActiveSheet()->SetCellValue('H1', lang('cc_slips_submitted'));
             $this->excel->getActiveSheet()->SetCellValue('I1', lang('cheques_submitted'));
             $this->excel->getActiveSheet()->SetCellValue('J1', lang('total_cash_submitted'));
             $this->excel->getActiveSheet()->SetCellValue('K1', lang('note'));
             $row = 2;
             foreach ($data as $data_row) {
                 $this->excel->getActiveSheet()->SetCellValue('A' . $row, $this->sma->hrld($data_row->date));
                 $this->excel->getActiveSheet()->SetCellValue('B' . $row, $data_row->closed_at);
                 $this->excel->getActiveSheet()->SetCellValue('C' . $row, $data_row->user);
                 $this->excel->getActiveSheet()->SetCellValue('D' . $row, $data_row->cash_in_hand);
                 $this->excel->getActiveSheet()->SetCellValue('E' . $row, $data_row->total_cc_slips);
                 $this->excel->getActiveSheet()->SetCellValue('F' . $row, $data_row->total_cheques);
                 $this->excel->getActiveSheet()->SetCellValue('G' . $row, $data_row->total_cash);
                 $this->excel->getActiveSheet()->SetCellValue('H' . $row, $data_row->total_cc_slips_submitted);
                 $this->excel->getActiveSheet()->SetCellValue('I' . $row, $data_row->total_cheques_submitted);
                 $this->excel->getActiveSheet()->SetCellValue('J' . $row, $data_row->total_cash_submitted);
                 $this->excel->getActiveSheet()->SetCellValue('K' . $row, $data_row->note);
                 if ($data_row->total_cash_submitted < $data_row->total_cash || $data_row->total_cheques_submitted < $data_row->total_cheques || $data_row->total_cc_slips_submitted < $data_row->total_cc_slips) {
                     $this->excel->getActiveSheet()->getStyle('A' . $row . ':K' . $row)->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F2DEDE'))));
                 }
                 $row++;
             }
             $this->excel->getActiveSheet()->getColumnDimension('A')->setWidth(25);
             $this->excel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
             $this->excel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
             $this->excel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
             $this->excel->getActiveSheet()->getColumnDimension('K')->setWidth(35);
             $filename = 'register_report';
             $this->excel->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
             if ($pdf) {
                 $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
                 $this->excel->getDefaultStyle()->applyFromArray($styleArray);
                 $this->excel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
                 require_once APPPATH . "third_party" . DIRECTORY_SEPARATOR . "MPDF" . DIRECTORY_SEPARATOR . "mpdf.php";
                 $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
                 $rendererLibrary = 'MPDF';
                 $rendererLibraryPath = APPPATH . 'third_party' . DIRECTORY_SEPARATOR . $rendererLibrary;
                 if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                     die('Please set the $rendererName: ' . $rendererName . ' and $rendererLibraryPath: ' . $rendererLibraryPath . ' values' . PHP_EOL . ' as appropriate for your directory structure');
                 }
                 header('Content-Type: application/pdf');
                 header('Content-Disposition: attachment;filename="' . $filename . '.pdf"');
                 header('Cache-Control: max-age=0');
                 $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF');
//.........这里部分代码省略.........
开发者ID:princejeru10,项目名称:dras,代码行数:101,代码来源:Reports.php

示例12: error_reporting

include_once '/class/CategorieFrais.php';
include_once '/class/Devise.php';
if (isset($_GET['id']) && !empty($_GET['id'])) {
    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
    date_default_timezone_set('Europe/Paris');
    /** PHPExcel_IOFactory */
    require_once '/ressources/PHPExcel_1.8.0_doc/Classes/PHPExcel/IOFactory.php';
    require_once '/ressources/PHPExcel_1.8.0_doc/Classes/PHPExcel/Writer/PDF.php';
    include '/ressources/PHPExcel_1.8.0_doc/Classes/PHPExcel/Writer/Excel2007.php';
    $objReader = PHPExcel_IOFactory::createReader('Excel5');
    // Chemin d'accès à la librairie de convesion tcPDF
    $rendererLibraryPath = 'ressources/PHPExcel_1.8.0_doc/Classes/libs/tcpdf';
    PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_TCPDF, $rendererLibraryPath);
    $objPHPExcel = $objReader->load("ressources/PHPExcel_1.8.0_doc/Examples/templates/templateEnote.xls");
    //On fait un clone de la note pour obtenir toutes ses informations
    $CloneNote = Note::getNoteById($bdd, $_GET['id']);
    $allFraisFromThisNote = $CloneNote->getListFrais($bdd);
    //Clone de la devise pour avoir toutes ses informations
    $CloneDevise = Devise::getDeviseById($bdd, $sessionUser->getDevise());
    //Ecrit le nom et le login de l'utilisateur ainsi que sa devise
    $nomUtilisateur = str_replace(" ", "", $sessionUser->getName());
    $objPHPExcel->getActiveSheet()->setCellValue('B8', $nomUtilisateur);
    $objPHPExcel->getActiveSheet()->setCellValue('F8', $sessionUser->getLogin());
    $objPHPExcel->getActiveSheet()->setCellValue('J8', $CloneDevise->getName());
    $datePremierFrais;
    $dateDernierFrais;
    $totalAvance = 0;
    $totalCase = 0;
开发者ID:JuanTrochez,项目名称:enote,代码行数:31,代码来源:impressionController.php

示例13: export

 function export($id = NULL, $pdf = NULL, $xls = NULL)
 {
     $data = $this->get_stuff();
     //print_r($data);exit;
     if (isset($_GET['s'])) {
         $data = $this->get_otherstuff();
     }
     if ($pdf || $xls) {
         //echo "good";exit;
         if (!empty($data)) {
             $this->load->library('excel');
             $this->excel->setActiveSheetIndex(0);
             $this->excel->getActiveSheet()->setTitle(lang('sales_report'));
             $this->excel->getActiveSheet()->SetCellValue('A1', lang('full_name'));
             $this->excel->getActiveSheet()->SetCellValue('B1', lang('category'));
             $this->excel->getActiveSheet()->SetCellValue('C1', date('M-Y', $this->getMonths()));
             $this->excel->getActiveSheet()->SetCellValue('D1', date('M-Y', $this->getMonths(1)));
             $this->excel->getActiveSheet()->SetCellValue('E1', date('M-Y', $this->getMonths(2)));
             $this->excel->getActiveSheet()->SetCellValue('F1', date('M-Y', $this->getMonths(3)));
             $this->excel->getActiveSheet()->SetCellValue('G1', date('M-Y', $this->getMonths(4)));
             $this->excel->getActiveSheet()->SetCellValue('H1', date('M-Y', $this->getMonths(5)));
             $this->excel->getActiveSheet()->SetCellValue('I1', date('M-Y', $this->getMonths(6)));
             $this->excel->getActiveSheet()->SetCellValue('J1', date('M-Y', $this->getMonths(7)));
             $this->excel->getActiveSheet()->SetCellValue('K1', date('M-Y', $this->getMonths(8)));
             $this->excel->getActiveSheet()->SetCellValue('L1', date('M-Y', $this->getMonths(9)));
             $this->excel->getActiveSheet()->SetCellValue('M1', date('M-Y', $this->getMonths(10)));
             $this->excel->getActiveSheet()->SetCellValue('N1', date('M-Y', $this->getMonths(11)));
             $row = 2;
             $total = 0;
             $paid = 0;
             $balance = 0;
             $target = $this->data['targets'];
             for ($i = 0; $i < count($data) - 1; $i++) {
                 $this->excel->getActiveSheet()->SetCellValue('A' . $row, $target[0]->full_name);
                 $this->excel->getActiveSheet()->SetCellValue('B' . $row, $data[$i][0]);
                 $this->excel->getActiveSheet()->SetCellValue('C' . $row, $data[$i][1]);
                 $this->excel->getActiveSheet()->SetCellValue('D' . $row, number_format($data[$i][2], 2));
                 $this->excel->getActiveSheet()->SetCellValue('E' . $row, number_format($data[$i][3], 2));
                 $this->excel->getActiveSheet()->SetCellValue('F' . $row, number_format($data[$i][4], 2));
                 $this->excel->getActiveSheet()->SetCellValue('G' . $row, number_format($data[$i][5], 2));
                 $this->excel->getActiveSheet()->SetCellValue('H' . $row, number_format($data[$i][6], 2));
                 $this->excel->getActiveSheet()->SetCellValue('I' . $row, number_format($data[$i][7], 2));
                 $this->excel->getActiveSheet()->SetCellValue('J' . $row, number_format($data[$i][8], 2));
                 $this->excel->getActiveSheet()->SetCellValue('K' . $row, number_format($data[$i][9], 2));
                 $this->excel->getActiveSheet()->SetCellValue('L' . $row, number_format($data[$i][10], 2));
                 $this->excel->getActiveSheet()->SetCellValue('M' . $row, number_format($data[$i][11], 2));
                 $this->excel->getActiveSheet()->SetCellValue('N' . $row, number_format($data[$i][12], 2));
                 $row++;
                 $j = $i;
             }
             $j = count($data) - 1;
             $this->excel->getActiveSheet()->getStyle("C" . $row . ":N" . $row)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_MEDIUM);
             $this->excel->getActiveSheet()->SetCellValue('A' . $row, $target[0]->full_name . ' TOTAL');
             $this->excel->getActiveSheet()->SetCellValue('C' . $row, $data[$j][1]);
             $this->excel->getActiveSheet()->SetCellValue('D' . $row, number_format($data[$j][2], 2));
             $this->excel->getActiveSheet()->SetCellValue('E' . $row, number_format($data[$j][3], 2));
             $this->excel->getActiveSheet()->SetCellValue('F' . $row, number_format($data[$j][4], 2));
             $this->excel->getActiveSheet()->SetCellValue('G' . $row, number_format($data[$j][5], 2));
             $this->excel->getActiveSheet()->SetCellValue('H' . $row, number_format($data[$j][6], 2));
             $this->excel->getActiveSheet()->SetCellValue('I' . $row, number_format($data[$j][7], 2));
             $this->excel->getActiveSheet()->SetCellValue('J' . $row, number_format($data[$j][8], 2));
             $this->excel->getActiveSheet()->SetCellValue('K' . $row, number_format($data[$j][9], 2));
             $this->excel->getActiveSheet()->SetCellValue('L' . $row, number_format($data[$j][10], 2));
             $this->excel->getActiveSheet()->SetCellValue('M' . $row, number_format($data[$j][11], 2));
             $this->excel->getActiveSheet()->SetCellValue('N' . $row, number_format($data[$j][12], 2));
             $this->excel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
             $this->excel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
             $this->excel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('D')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('F')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('G')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('H')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('I')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('J')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('K')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('L')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
             $this->excel->getActiveSheet()->getColumnDimension('N')->setWidth(10);
             $filename = 'targets';
             $this->excel->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
             if ($pdf) {
                 $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
                 $this->excel->getDefaultStyle()->applyFromArray($styleArray);
                 $this->excel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
                 require_once APPPATH . "third_party" . DIRECTORY_SEPARATOR . "MPDF" . DIRECTORY_SEPARATOR . "mpdf.php";
                 $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
                 $rendererLibrary = 'MPDF';
                 $rendererLibraryPath = APPPATH . 'third_party' . DIRECTORY_SEPARATOR . $rendererLibrary;
                 if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
                     die('Please set the $rendererName: ' . $rendererName . ' and $rendererLibraryPath: ' . $rendererLibraryPath . ' values' . PHP_EOL . ' as appropriate for your directory structure');
                 }
                 header('Content-Type: application/pdf');
                 header('Content-Disposition: attachment;filename="' . $filename . '.pdf"');
                 header('Cache-Control: max-age=0');
                 $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF');
                 $objWriter->save('php://output');
                 exit;
             }
             if ($xls) {
//.........这里部分代码省略.........
开发者ID:NimzyMaina,项目名称:sma,代码行数:101,代码来源:Target.php

示例14: date_default_timezone_set

date_default_timezone_set('Asia/Tokyo');
require __DIR__ . '/vendor/autoload.php';
$products = [['Microsoft Excel 2016', 14000, 2], ['Microsoft Word 2016', 14800, 1], ['Microsoft PowerPoint 2016', 15000, 1]];
$book = PHPExcel_IOFactory::load('templates/13-見積書テンプレート.xlsx');
$sheet = $book->getActiveSheet();
$rowOffset = 3;
foreach ($products as $row => $product) {
    foreach ($product as $col => $value) {
        $sheet->setCellValueByColumnAndRow($col, $row + $rowOffset, $value);
    }
}
$excelWriter = PHPExcel_IOFactory::createWriter($book, 'Excel2007');
$excelWriter->save('output/13-excel.xlsx');
// tcPDF
PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_TCPDF, __DIR__ . '/vendor/tecnickcom/tcpdf');
$pdfWriter = PHPExcel_IOFactory::createWriter($book, 'PDF');
$pdfWriter->save('output/13-tcPDF.pdf');
// DomPDF
PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_DOMPDF, __DIR__ . '/vendor/dompdf/dompdf');
$pdfWriter = PHPExcel_IOFactory::createWriter($book, 'PDF');
$pdfWriter->save('output/13-Dompdf.pdf');
// mPDF
PHPExcel_Settings::setPdfRenderer(PHPExcel_Settings::PDF_RENDERER_MPDF, __DIR__ . '/vendor/mpdf/mpdf');
$pdfWriter = PHPExcel_IOFactory::createWriter($book, 'PDF');
$pdfWriter->save('output/13-mPDF.pdf');
// LibreOfficeでPDF化する
$soffice = '/Applications/LibreOffice.app/Contents/MacOS/soffice';
$outdir = __DIR__ . '/output';
$command = "{$soffice} --headless --convert-to pdf --outdir {$outdir} {$outdir}/13-excel.xlsx";
echo $command, PHP_EOL;
passthru($command);
开发者ID:suin,项目名称:phpexcel-playground,代码行数:31,代码来源:13-output-pdf.php

示例15: test

 public function test()
 {
     // 		ini_set("memory_limit","1024M");
     // 		$html = file_get_contents('../'.EXPORT_TEMP_PATH.'13554680705609.html');;
     // 		require_once dirname(__FILE__)."/../Util/MPDF54/mpdf.php";
     // 		$mpdf=new mPDF();
     // 		$mpdf->useAdobeCJK = true;		// Default setting in config.php
     // 		// You can set this to false if you have defined other CJK fonts
     // 		$mpdf->SetAutoFont(AUTOFONT_CJK);	//	AUTOFONT_CJK | AUTOFONT_THAIVIET | AUTOFONT_RTL | AUTOFONT_INDIC	// AUTOFONT_ALL
     // 		// () = default ALL, 0 turns OFF (default initially)
     // 		$mpdf->WriteHTML($html);
     // 		$filename = '../'.EXPORT_TEMP_PATH.'13554680705609'.'_'.rand(100,999).'.pdf';
     // 		$mpdf->Output($filename);
     // 		echo $filename;
     // 		Log::write(date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" );
     // 		$objReader = PHPExcel_IOFactory::createReader('Excel5');
     // 		$objPHPExcel = $objReader->load(EXCEL_TEMPLATES_PATH."track_template.xls");
     $objReader = PHPExcel_IOFactory::createReader('Excel2007');
     $objPHPExcel = $objReader->load(EXCEL_TEMPLATES_PATH . "track_template.xlsx");
     $row = 9;
     $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, date('Y-m-d H:i:s'))->setCellValue('B' . $row, '内蒙古自治区包头市东河区,西脑包南五道巷-巴彦塔拉西大街交叉路口,包头市东河区国家税务局,中国石油宁鹿大酒店,出租车上下客站附近')->setCellValue('C' . $row, 25.33)->setCellValue('D' . $row, '东北')->setCellValue('E' . $row, '正常');
     $objPHPExcel->getActiveSheet()->getRowDimension($row)->setRowHeight(-1);
     // 		$ws  = "\nwidth A:" . $objPHPExcel->getActiveSheet()->getColumnDimension('A')->getWidth();
     // 		$ws .= "\nwidth B:" . $objPHPExcel->getActiveSheet()->getColumnDimension('B')->getWidth();
     // 		$ws .= "\nwidth C:" . $objPHPExcel->getActiveSheet()->getColumnDimension('C')->getWidth();
     // 		$ws .= "\nwidth D:" . $objPHPExcel->getActiveSheet()->getColumnDimension('D')->getWidth();
     // 		$ws .= "\nwidth E:" . $objPHPExcel->getActiveSheet()->getColumnDimension('E')->getWidth();
     // 		Log::write($ws);
     $widthPT = ($objPHPExcel->getActiveSheet()->getColumnDimension('A')->getWidth() + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->getWidth() + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->getWidth() + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->getWidth() + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->getWidth()) * 6;
     //经验:导出成Excel2007
     // 				* 4.7499; //经验:导出成PDF
     Log::write("\n-----------widthPT:" . $widthPT . "-----------");
     $widthPX = round($widthPT * 4 / 3);
     Log::write("\n-----------widthPX:" . $widthPX . "-----------");
     $heightPT = 300;
     $heightPX = 400;
     $objPHPExcel->getActiveSheet()->getRowDimension('6')->setRowHeight($heightPT);
     $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
     $rendererLibrary = 'mPDF5.4';
     $rendererLibraryPath = dirname(__FILE__) . '/../Util/MPDF54';
     PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
     // 		$widthPX +=-2;	//Excel5和Excel2007才需要
     // 		$heightPX +=-2;
     $url = 'http://api.map.baidu.com/staticimage?width=' . $widthPX . '&height=' . $heightPX . '&center=116.468265,39.90692&zoom=11&markers=116.418822,39.859083|116.49586,39.960917&markerStyles=l,|l,';
     $newfname = '../' . EXPORT_TEMP_PATH . 'staticimage.png';
     $file = fopen($url, "rb");
     if ($file) {
         $newf = fopen($newfname, "wb");
         if ($newf) {
             while (!feof($file)) {
                 fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
             }
         }
     }
     if ($file) {
         fclose($file);
     }
     if ($newf) {
         fclose($newf);
     }
     $objDrawing = new PHPExcel_Worksheet_Drawing();
     $objDrawing->setName('map');
     $objDrawing->setDescription('Map');
     $objDrawing->setPath('../' . EXPORT_TEMP_PATH . 'staticimage.png');
     // 		$objDrawing->setOffsetX(1);	//Excel5和Excel2007才需要
     // 		$objDrawing->setOffsetY(1);
     // 		$objDrawing->setHeight($heightPT);
     $objDrawing->setCoordinates('A6');
     $objDrawing->getShadow()->setVisible(true);
     $objDrawing->getShadow()->setDirection(45);
     $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
     $wd = "\nWidth: " . $objDrawing->getWidth();
     $wd .= "\nHeight: " . $objDrawing->getHeight();
     Log::write($wd);
     $file = EXPORT_TEMP_PATH . time() . rand(1000, 9999) . '.pdf';
     $objPHPExcel->getActiveSheet()->setShowGridlines(false);
     //要导出成PDF(或者HTML)这个比较重要,否则表格线会造成出来的结果不好
     ini_set("memory_limit", "1024M");
     //MPDF消耗内存比较厉害
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
     $objWriter->setImagesRoot('..');
     $objWriter->setPrintParams('A4', 'P', '', '', '', '', 16, 16, 15, 15, 9, 9, true, null, null);
     $objWriter->save('../' . $file);
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
     $objWriter->save('../' . str_replace('.pdf', '.html', $file));
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save('../' . str_replace('.pdf', '.xls', $file));
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('../' . str_replace('.pdf', '.xlsx', $file));
 }
开发者ID:jumboluo,项目名称:tracking,代码行数:90,代码来源:LogAction.class.php


注:本文中的PHPExcel_Settings::setPdfRenderer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。