<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## php導出excel * 使用開源插件: phpexcel * github : [https://github.com/PHPOffice/PHPExcel](https://github.com/PHPOffice/PHPExcel) >[info] 簡單封裝 ~~~ class ReportExcel { private $objPHPExcel = null; private $objSheet = null; public function __construct() { $this->objPHPExcel = new PHPExcel(); $this->objSheet = $this->objPHPExcel->getActiveSheet(); } /** * 設置標題 * @param string $title * @throws PHPExcel_Exception */ public function setTitle($title = 'Report') { $this->objPHPExcel->getProperties()->setCreator("sgfoot") ->setLastModifiedBy("sgfoot") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); $this->objSheet->setTitle($title); } //設置單元格 public function setCell($cell, $value) { $this->objSheet->setCellValue($cell, $value); } /** * 設置列寬 * @param $column * @param int $width */ public function setWidth($column, $width = 12) { $this->objSheet->getColumnDimension($column)->setWidth($width); } /** * 設置文本 * @param $cell * @param $value * @throws PHPExcel_Exception */ public function setText($cell, $value) { $this->objSheet->setCellValueExplicit($cell, $value, PHPExcel_Cell_DataType::TYPE_STRING); } /** * 設置字體和大小 * @param $columnName * @param int $fontSize * @param string $fimalyName * @author: wzl * @date: 2017 */ public function setFont($columnName, $fontSize = 12, $fimalyName = 'DengXian') { $this->objSheet->getStyle($columnName)->getFont()->setName($fimalyName)->setSize($fontSize); } /** * 設置字體顏色  * @param $columnName * @param string $color * @author: wzl * @date: 2017 */ public function setFontColor($columnName, $color = PHPExcel_Style_Color::COLOR_RED) { $this->objSheet->getStyle($columnName)->getFont()->getColor()->setARGB($color); } /** * 設置單元格里的字體位置 * @param $columnName * @param string $position * @author: wzl * @date: 2017 */ public function setFontPosition($columnName, $position = 'left') { $this->objSheet->getStyle($columnName)->getAlignment() ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER)//設置單元格垂直居中 ->setHorizontal($position);//單元格水平靠左 } /** * 設置字體為粗體 例:$obj->setBold('A1:J1'); * @param $columnName * @author: wzl * @date: 2017 */ public function setBold($columnName) { $this->objSheet->getStyle($columnName)->getFont()->setBold(true); } /** * 設置單元格垂直左右居中 * @param $columnName * @author: wzl * @date: 2017 */ public function setCellCenter($columnName) { $this->objSheet->getStyle($columnName)->getAlignment() ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER) ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER) ->setWrapText(true); } /** * 設置下劃線 * @param $columnName * @author: wzl * @date: 2017 */ public function setUnderline($columnName) { $this->objSheet->getStyle($columnName)->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); } /** * 設置邊框 * @param $columnName * @author: wzl * @date: 2017 */ public function setBorder($columnName) { $this->objSheet->getStyle($columnName)->applyFromArray($this->_setBorder()); } /** * 合并單元格 * @param $columnName * @author: wzl * @date: 2017 */ public function mergeCells($columnName) { $this->objSheet->mergeCells($columnName); } /** * 設置背景顏色,默認黃色  * const COLOR_BLACK = 'FF000000'; * const COLOR_WHITE = 'FFFFFFFF'; * const COLOR_RED = 'FFFF0000'; * const COLOR_DARKRED = 'FF800000'; * const COLOR_BLUE = 'FF0000FF'; * const COLOR_DARKBLUE = 'FF000080'; * const COLOR_GREEN = 'FF00FF00'; * const COLOR_DARKGREEN = 'FF008000'; * const COLOR_YELLOW = 'FFFFFF00'; * const COLOR_DARKYELLOW = 'FF808000'; * @param $i * @param string $color * @author: wzl * @date: 2017 */ public function setBackColor($i, $color = PHPExcel_Style_Color::COLOR_YELLOW) { $this->objSheet->getStyle($i)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);//填充顏色  $this->objSheet->getStyle($i)->getFill()->getStartColor()->setARGB($color);//填充顏色 } /** * 設置邊框 * @author: wzl * @date: 2017 * @return array */ private function _setBorder() { $styleArray = array( 'borders' => array( 'allborders' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,//細邊框 ), ), ); return $styleArray; } /** * 導出 * @param string $filename * @throws PHPExcel_Reader_Exception * @throws PHPExcel_Writer_Exception */ public function output($filename = '') { if (empty($filename)) { $filename = date('Ymd-' . mt_rand(100, 999)) . '.xlsx'; } else { if (strpos($filename, '.xlsx') === false) { $filename .= '.xlsx'; } } header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看