惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - s1ihome

弹框居中的方法 如何 clone git 项目到一个非空目录 Uiautomatorviewer报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetException 常见银行卡号账号长度参考表 TP5.0 数据库查询is not null vscode 中sftp配置 移动端H5上传图片并压缩上传 Thinkphp关联模型使用 centos 7 pdo thinkphp 5 where 组合条件map数组or [转]处理上百万条的数据库如何提高处理查询速度 连接oracle读取数据 SQL SERVER批量修改表名前缀 java开发微信公众平台备忘 AngularJS小试牛刀 spring mvc开发过程知识点记录 微信公众平台项目中遇到的小问题40016,Invalid button size Dynamic Virtual Channels 木马的隐藏方式
php导出excel
s1ihome · 2015-09-09 · via 博客园 - s1ihome

感觉技术掌握的有些太杂了,一会儿鼓捣java,一会儿鼓捣php,一边还搞着.net, maybe this just is life.

此前同事给某县政法委做的一套维稳信息平台,数据库是封装了mysql,现在客户想把里面的数据导出迁移到省里的某套平台中,最好是导出到excel中,网上搜索资料后算是简单实现了。

1.下载PHPExcel类库,http://phpexcel.codeplex.com/,放入本地Lib/phpexcel中

2.参照示例实现导出excel代码如下:

  include_once './lib/phpexcel/PHPExcel.class.php';
  include_once './lib/phpexcel/phpexcel/IOFactory.php';

  $inputFileName='./dispute.xls';
  $excel = PHPExcel_IOFactory::load($inputFileName);
  $excel->getProperties()->setCreator("sxg")
     ->setLastModifiedBy("sxg")
     ->setTitle("矛盾纠纷导出数据")
     ->setSubject("矛盾纠纷导出数据")
     ->setDescription("dispute矛盾纠纷导出数据");
  $excel->setActiveSheetIndex(0);
  $objActSheet = $excel->getActiveSheet();

  $SQL = "SELECT * FROM dispute order by dispId limit 0,2";
  
  $rst = DB::Execute($SQL, 20011, 'dispute', 'admin', '', '',"query");
  $arr = split("\1",$rst);
  $row=2;
  foreach($arr as $rs){
    $col=0;
    $valArr = split("\2",$rs);
    foreach($valArr as $val) {
     $objActSheet->setCellValueByColumnAndRow($col,$row,$val);
     $col++;
    }
    $row++;
  }
  $objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  $objWriter->save(str_replace('.php', '.xls', __FILE__));