Welcome to the website navigation,本站只接受合法正规的企业网站,欢迎站长们提交你的网站获得展示和流量有任何问题请联系站长,欢迎大家加入本站。

                
提交网站
  • 网站:76083
  • 待审:5
  • APP:577
  • 文章:304411
  • 会员:56004
文字内链包年1000元 文字内链包年1000元 文字内链包年1000元 AI办公网站 AI绘画工具 AIchat

名站网址导航为大家免费提供关于网站编程方面的知识。

比较全面的PhP数组的使用方法小结-PhPphp技巧WLZAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

WLZAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

  • 本篇文章的具体介绍如下请大家仔细看

下载地址:http://www.codeplex.com/PhPExcel
  下面是总结的几个使用方法
  include ‘PhPExcel.php';
  include ‘PhPExcel/Writer/Excel2007.php';
  //或者include ‘PhPExcel/Writer/Excel5.php'; 用于输出.xls的
  创建一个excel
  $objPhPExcel = new PhPExcel();
  保存excel―2007格式
  $objWriter = new PhPExcel_Writer_Excel2007($objPhPExcel);
  //或者$objWriter = new PhPExcel_Writer_Excel5($objPhPExcel); 非2007格式
  $objWriter->save("xxx.xlsx");
  直接输出到浏览器
  $objWriter = new PhPExcel_Writer_Excel5($objPhPExcel);
  header("Pragma: public");
  header("Expires: 0″);
  header("Cache-Control:must-revalidate, post-check=0, pre-check=0″);
  header("Content-Type:application/force-download");
  header("Content-Type:application/vnd.ms-execl");
  header("Content-Type:application/octet-stream");
  header("Content-Type:application/download");;
  header('Content-Disposition:attachment;filename="resume.xls"‘);
  header("Content-Transfer-Encoding:binary");
  $objWriter->save('php://output');
  ――――――――――――――――――――――――――――――――――――――�C
  设置excel的属性:
  创建人
  $objPhPExcel->getProperties()->setCreator("Maarten Balliauw");
  最后修改人
  $objPhPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
  标题
  $objPhPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
  题目
  $objPhPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
  描述
  $objPhPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PhP classes.");
  关键字
  $objPhPExcel->getProperties()->setKeywords("office 2007 openxml php");
  种类
  $objPhPExcel->getProperties()->setCategory("Test result file");
  ――――――――――――――――――――――――――――――――――――――�C
  设置当前的sheet
  $objPhPExcel->setActiveSheetIndex(0);
  设置sheet的name
  $objPhPExcel->getActiveSheet()->setTitle('Simple');
  设置单元格的值
  $objPhPExcel->getActiveSheet()->setCellValue('A1′, ‘String');
  $objPhPExcel->getActiveSheet()->setCellValue('A2′, 12);
  $objPhPExcel->getActiveSheet()->setCellValue('A3′, true);
  $objPhPExcel->getActiveSheet()->setCellValue('C5′, ‘=SUM(C2:C4)');
  $objPhPExcel->getActiveSheet()->setCellValue('B8′, ‘=MIN(B2:C5)');
  合并单元格
  $objPhPExcel->getActiveSheet()->mergeCells('A18:E22′);
  分离单元格
  $objPhPExcel->getActiveSheet()->unmergeCells('A28:B28′);
保护cell
  $objPhPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
  $objPhPExcel->getActiveSheet()->protectCells('A3:E13′, ‘PhPExcel');
  设置格式
  // Set cell number formats
  echo date('h:i:s') . " Set cell number formatsn";
  $objPhPExcel->getActiveSheet()->getStyle('E4′)->getNumberFormat()->setFormatCode(PhPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
  $objPhPExcel->getActiveSheet()->duplicateStyle( $objPhPExcel->getActiveSheet()->getStyle('E4′), ‘E5:E13′ );
  设置宽width
  // Set column widths
  $objPhPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
  $objPhPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
  设置font
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFont()->setName('Candara');
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFont()->setSize(20);
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFont()->setBold(true);
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFont()->setUnderline(PhPExcel_Style_Font::UNDERLINE_SINGLE);
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFont()->getColor()->setARGB(PhPExcel_Style_Color::COLOR_WhITE);
  $objPhPExcel->getActiveSheet()->getStyle('E1′)->getFont()->getColor()->setARGB(PhPExcel_Style_Color::COLOR_WhITE);
  $objPhPExcel->getActiveSheet()->getStyle('D13′)->getFont()->setBold(true);
  $objPhPExcel->getActiveSheet()->getStyle('E13′)->getFont()->setBold(true);
  设置align
  $objPhPExcel->getActiveSheet()->getStyle('D11′)->getAlignment()->sethorizontal(PhPExcel_Style_Alignment::hORIZONTAL_RIGhT);
  $objPhPExcel->getActiveSheet()->getStyle('D12′)->getAlignment()->sethorizontal(PhPExcel_Style_Alignment::hORIZONTAL_RIGhT);
  $objPhPExcel->getActiveSheet()->getStyle('D13′)->getAlignment()->sethorizontal(PhPExcel_Style_Alignment::hORIZONTAL_RIGhT);
  $objPhPExcel->getActiveSheet()->getStyle('A18′)->getAlignment()->sethorizontal(PhPExcel_Style_Alignment::hORIZONTAL_JUSTIFY);
  //垂直居中
  $objPhPExcel->getActiveSheet()->getStyle('A18′)->getAlignment()->setVertical(PhPExcel_Style_Alignment::VERTICAL_CENTER);
  设置column的border
  $objPhPExcel->getActiveSheet()->getStyle('A4′)->getBorders()->getTop()->setBorderStyle(PhPExcel_Style_Border::BORDER_ThIN);
  $objPhPExcel->getActiveSheet()->getStyle('B4′)->getBorders()->getTop()->setBorderStyle(PhPExcel_Style_Border::BORDER_ThIN);
  $objPhPExcel->getActiveSheet()->getStyle('C4′)->getBorders()->getTop()->setBorderStyle(PhPExcel_Style_Border::BORDER_ThIN);
  $objPhPExcel->getActiveSheet()->getStyle('D4′)->getBorders()->getTop()->setBorderStyle(PhPExcel_Style_Border::BORDER_ThIN);
  $objPhPExcel->getActiveSheet()->getStyle('E4′)->getBorders()->getTop()->setBorderStyle(PhPExcel_Style_Border::BORDER_ThIN);
  设置border的color
  $objPhPExcel->getActiveSheet()->getStyle('D13′)->getBorders()->getLeft()->getColor()->setARGB('FF993300′);
  $objPhPExcel->getActiveSheet()->getStyle('D13′)->getBorders()->getTop()->getColor()->setARGB('FF993300′);
  $objPhPExcel->getActiveSheet()->getStyle('D13′)->getBorders()->getBottom()->getColor()->setARGB('FF993300′);
  $objPhPExcel->getActiveSheet()->getStyle('E13′)->getBorders()->getTop()->getColor()->setARGB('FF993300′);
  $objPhPExcel->getActiveSheet()->getStyle('E13′)->getBorders()->getBottom()->getColor()->setARGB('FF993300′);
  $objPhPExcel->getActiveSheet()->getStyle('E13′)->getBorders()->getRight()->getColor()->setARGB('FF993300′);
  设置填充颜色
  $objPhPExcel->getActiveSheet()->getStyle('A1′)->getFill()->setFillType(PhPExcel_Style_Fill::FILL_SOLID);
  $objPhPExcel->getActiveSheet()->getStyle('A1′)->getFill()->getStartColor()->setARGB('FF808080′);
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFill()->setFillType(PhPExcel_Style_Fill::FILL_SOLID);
  $objPhPExcel->getActiveSheet()->getStyle('B1′)->getFill()->getStartColor()->setARGB('FF808080′);
  加图片
  $objDrawing = new PhPExcel_Worksheet_Drawing();
  $objDrawing->setName('Logo');
  $objDrawing->setDescription('Logo');
  $objDrawing->setPath('./images/officelogo.jpg');
  $objDrawing->setheight(36);
  $objDrawing->setWorksheet($objPhPExcel->getActiveSheet());
  $objDrawing = new PhPExcel_Worksheet_Drawing();
  $objDrawing->setName('Paid');
  $objDrawing->setDescription('Paid');
  $objDrawing->setPath('./images/paid.png');
  $objDrawing->setCoordinates('B15′);
  $objDrawing->setOffsetX(110);
  $objDrawing->setRotation(25);
  $objDrawing->getShadow()->setVisible(true);
  $objDrawing->getShadow()->setDirection(45);
  $objDrawing->setWorksheet($objPhPExcel->getActiveSheet());
  在默认sheet后,创建一个worksheet
  echo date('h:i:s') . " Create new Worksheet objectn";
  $objPhPExcel->createSheet();
  $objWriter = PhPExcel_IOFactory::createWriter($objExcel, 'Excel5');
  $objWriter-save('php://output'); WLZAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

关于网站编程方面的知识就说道这里了,希望能够对大家有作用。,

标签:

分享到:

  admin

注册时间:

网站:0 个   APP:3 个  文章:0 篇

  • 76083

    网站

  • 577

    APP

  • 304411

    文章

  • 56004

    会员

赶快注册账号,推广您的网站吧!
文章分类
热门网站
最新入驻APP小程序

宝贝市场2023-02-08

宝贝市场——买手和卖家商品展示

夺宝助手2023-02-08

夺宝助手小程序,查看每日快夺宝平

查诚信2023-02-08

查诚信是一款免费的商业查询工具

车价天天报2023-02-08

快速连接汽车销售,获知汽车最新报

考勤助理小程序2023-02-08

上班签到考勤,实时定位,后台轻松

汽车报价大全查询2023-02-08

汽车报价大全查询提供最新汽车市