- 浏览: 268132 次
- 性别:
- 来自: 济南
文章分类
最新评论
-
hyxj1220:
原来是这么回事,,谢谢了
document的execCommand解释 -
zouhongmin:
太强了,我膜拜你,要向你学习。
减肥日志 -
codeboy_wang:
超炫 超喜欢
document的execCommand解释 -
laiang8283:
博主男的女的,100斤也不是很胖啊
减肥日志 -
yixiaof:
博主真有毅力啊。
减肥日志
http://hi.baidu.com/straul/blog/item/f48c7889302523bb0f2444d9.html
http://phpexcel.codeplex.com/SourceControl/changeset/view/66096#1718995
phpexcelreader
http://hi.baidu.com/zengfeng75/blog/item/7271becc7745721900e92836.html
http://hi.baidu.com/hu5210898/blog/item/b2920d022448699bd43f7cf6.html
http://woshao.com/article/936d90c8be8d11df8ddb000c295b2b8d/
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.intro.php
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php
旋转指针效果
http://www.leafiy.com/tech/1143.html
PHPEXCEL使用实例 收藏
最近在项目中要用到PHP生成EXCEL,上网找了一下,发现PHPEXCEL挺不错,用了一下,感觉还行,就是设置单元格格式的时候比较麻烦,总体来说功能还是比较强大的,还有生成PDF什么的,发一个实例吧
view plaincopy to clipboardprint?
<?php
require_once 'PHPExcel.php';
require_once 'PHPExcel/Writer/Excel5.php';
require_once("..\include\mysqlconn.php");
$sdate=$_POST["sdate"];//接受传递过来的生成时间段
$edate=$_POST["edate"];
//$sdate='2009-01-01';
//$edate='2009-04-01';
$cancel_time=date("YmdHis");
$data=new MysqlConn();
$data->connect();
$sql="select * from employee_addminus where (oper_time between '$sdate' and '$edate') and isCanceled=0";
// 创建一个处理对象实例
$objExcel = new PHPExcel();
// 创建文件格式写入对象实例, uncomment
$objWriter = new PHPExcel_Writer_Excel5($objExcel);
//设置文档基本属性
$objProps = $objExcel->getProperties();
$objProps->setCreator("章贡区医疗保险局");
$objProps->setLastModifiedBy("章贡区医疗保险局");
$objProps->setTitle("章贡区医疗保险局职工月增减变动报表");
$objProps->setSubject("章贡区医疗保险局职工月增减变动报表");
$objProps->setDescription("章贡区医疗保险局职工月增减变动报表");
$objProps->setKeywords("章贡区医疗保险局职工月增减变动报表");
$objProps->setCategory("变动报表");
//*************************************
//设置当前的sheet索引,用于后续的内容操作。
//一般只有在使用多个sheet的时候才需要显示调用。
//缺省情况下,PHPExcel会自动创建第一个sheet被设置SheetIndex=0
$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet();
//设置当前活动sheet的名称
$objActSheet->setTitle('月增减变动报表');
//*************************************
//
//设置宽度,这个值和EXCEL里的不同,不知道是什么单位,略小于EXCEL中的宽度
$objActSheet->getColumnDimension('A')->setWidth(20);
$objActSheet->getColumnDimension('B')->setWidth(10);
$objActSheet->getColumnDimension('C')->setWidth(6);
$objActSheet->getColumnDimension('D')->setWidth(20);
$objActSheet->getColumnDimension('E')->setWidth(12);
$objActSheet->getColumnDimension('F')->setWidth(10);
$objActSheet->getColumnDimension('G')->setWidth(20);
$objActSheet->getColumnDimension('H')->setWidth(18);
$objActSheet->getColumnDimension('I')->setWidth(12);
$objActSheet->getColumnDimension('J')->setWidth(8);
$objActSheet->getColumnDimension('K')->setWidth(8);
$objActSheet->getColumnDimension('L')->setWidth(12);
$objActSheet->getColumnDimension('M')->setWidth(10);
$objActSheet->getColumnDimension('N')->setWidth(10);
$objActSheet->getRowDimension(1)->setRowHeight(30);
$objActSheet->getRowDimension(2)->setRowHeight(27);
$objActSheet->getRowDimension(3)->setRowHeight(16);
//设置单元格的值
$objActSheet->setCellValue('A1', '章贡区医疗保险局职工月增减变动报表');
//合并单元格
$objActSheet->mergeCells('A1:N1');
//设置样式
$objStyleA1 = $objActSheet->getStyle('A1');
$objStyleA1->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objFontA1 = $objStyleA1->getFont();
$objFontA1->setName('宋体');
$objFontA1->setSize(18);
$objFontA1->setBold(true);
//设置居中对齐
$objActSheet->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('B2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('C2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('D2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('E2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('F2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('G2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('H2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('I2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('J2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('K2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('L2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('M2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('N2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->setCellValue('A2', '现所在单位');
$objActSheet->setCellValue('B2', '姓名');
$objActSheet->setCellValue('C2', '性别');
$objActSheet->setCellValue('D2', '身份证号码');
$objActSheet->setCellValue('E2', '参保时间');
$objActSheet->setCellValue('F2', '增减原因');
$objActSheet->setCellValue('G2', '原所在单位');
$objActSheet->setCellValue('H2', '增减时间');
$objActSheet->setCellValue('I2', '退休时间');
$objActSheet->setCellValue('J2', '原工资');
$objActSheet->setCellValue('K2', '现工资');
$objActSheet->setCellValue('L2', '定点医院');
$objActSheet->setCellValue('M2', '操作人');
$objActSheet->setCellValue('N2', '备注');
//设置边框
$objActSheet->getStyle('A2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$query=$data->query($sql);
$i=1;
//从数据库取值循环输出
while($result=mysql_fetch_row($query)){
$personName=$result[1];
$idcard=$result[2];
$old_company=$result[3];
$new_company=$result[4];
$sex=$result[5];
$start_time=$result[6];
$reason=$result[7];
$retire_time=$result[8];
$old_wages=$result[9];
$new_wages=$result[10];
$hospital=$result[11];
$remarks=$result[12];
$operator=$result[13];
$oper_time=$result[14];
$n=$i+2;
$objActSheet->getStyle('B'.$n)->getNumberFormat()->setFormatCode('@');
$objActSheet->getStyle('E'.$n)->getNumberFormat()->setFormatCode('@');
$objActSheet->getRowDimension($n)->setRowHeight(16);
$objActSheet->getStyle('A'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$xb="男";
if($sex==1){
$xb="女";
}
$objActSheet->setCellValue('A'.$n, $new_company);
$objActSheet->setCellValue('B'.$n, $personName);
$objActSheet->setCellValue('C'.$n, $xb);
$objActSheet->setCellValue('D'.$n, ' '.$idcard.' ');
$objActSheet->setCellValue('E'.$n, $start_time);
$objActSheet->setCellValue('F'.$n, $reason);
$objActSheet->setCellValue('G'.$n, $old_company);
$objActSheet->setCellValue('H'.$n, $oper_time);
$objActSheet->setCellValue('I'.$n, $retire_time);
$objActSheet->setCellValue('J'.$n, $old_wages);
$objActSheet->setCellValue('K'.$n, $new_wages);
$objActSheet->setCellValue('L'.$n, $hospital);
$objActSheet->setCellValue('M'.$n, $operator);
$objActSheet->setCellValue('N'.$n, $remarks);
$i++;
}
//*************************************
//输出内容
//
$outputFileName = "tables/".$cancel_time."addminus.xls";
//到文件
$objWriter->save($outputFileName);
//下面这个输出我是有个页面用Ajax接收返回的信息
echo("<a href="tables/".$cancel_time."addminus.xls" mce_href="tables/".$cancel_time."addminus.xls" target='_blank'>点击下载电子表</a>");
?>
监听浏览器关闭窗口消息
Onunload与Onbeforeunload
Onunload,onbeforeunload都是在刷新或关闭时调用,可以在<script>脚本中通过window.onunload来指定或者在<body>里指定。区别在于onbeforeunload在onunload之前执行,它还可以阻止onunload的执行。
Onbeforeunload也是在页面刷新或关闭时调用,Onbeforeunload是正要去服务器读取新的页面时调用,此时还没开始读取;而onunload则已经从服务器上读到了需要加载的新的页面,在即将替换掉当前页面时调用。Onunload是无法阻止页面的更新和关闭的。而 Onbeforeunload 可以做到。曾经做一个考试系统,涉及到防止用户半途退出考试(有意或者无意),代码如下:
Java代码
<script type="text/javascript">
<!--
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning;
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning);
}
// -->
</script>
Java代码
这段代码在FF和IE上都能正确执行.再点击关闭按钮时首先触发obbeforeunload事件,点击否定时不执行onload事件.
Java代码
通常应用在 注销session等等登陆信息 等方面....
Java代码
这里一并推荐一个ActionScript3的好教程: <a href="http://gskinner.com/talks/as3workshop/">http://gskinner.com/talks/as3workshop/</a>
写道
运用onunload事件判断浏览器是刷新还是关闭窗口
写道
function CloseOpen(event) {
if(event.clientX<=0 && event.clientY<0) {
alert("关闭");
}
else
{
alert("刷新或离开");
}
}
Java代码
window.onbeforeunload = function() //author: meizz
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
alert("是关闭而非刷新");
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
PHP里有用plit()有时会出现Warning: split(): REG_EMPTY.
<?
$str="q63|q64|q65|";
$str1=split('|',$str);
for($i=0;$i<count($str1);$i++)
{
echo $str1[$i]."<br>";
}
?>
纠正这个错误:将"|"用"\"引用,即改成$str1=split('\|',$str);就哦了
http://phpexcel.codeplex.com/SourceControl/changeset/view/66096#1718995
phpexcelreader
http://hi.baidu.com/zengfeng75/blog/item/7271becc7745721900e92836.html
http://hi.baidu.com/hu5210898/blog/item/b2920d022448699bd43f7cf6.html
http://woshao.com/article/936d90c8be8d11df8ddb000c295b2b8d/
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.intro.php
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php
旋转指针效果
http://www.leafiy.com/tech/1143.html
PHPEXCEL使用实例 收藏
最近在项目中要用到PHP生成EXCEL,上网找了一下,发现PHPEXCEL挺不错,用了一下,感觉还行,就是设置单元格格式的时候比较麻烦,总体来说功能还是比较强大的,还有生成PDF什么的,发一个实例吧
view plaincopy to clipboardprint?
<?php
require_once 'PHPExcel.php';
require_once 'PHPExcel/Writer/Excel5.php';
require_once("..\include\mysqlconn.php");
$sdate=$_POST["sdate"];//接受传递过来的生成时间段
$edate=$_POST["edate"];
//$sdate='2009-01-01';
//$edate='2009-04-01';
$cancel_time=date("YmdHis");
$data=new MysqlConn();
$data->connect();
$sql="select * from employee_addminus where (oper_time between '$sdate' and '$edate') and isCanceled=0";
// 创建一个处理对象实例
$objExcel = new PHPExcel();
// 创建文件格式写入对象实例, uncomment
$objWriter = new PHPExcel_Writer_Excel5($objExcel);
//设置文档基本属性
$objProps = $objExcel->getProperties();
$objProps->setCreator("章贡区医疗保险局");
$objProps->setLastModifiedBy("章贡区医疗保险局");
$objProps->setTitle("章贡区医疗保险局职工月增减变动报表");
$objProps->setSubject("章贡区医疗保险局职工月增减变动报表");
$objProps->setDescription("章贡区医疗保险局职工月增减变动报表");
$objProps->setKeywords("章贡区医疗保险局职工月增减变动报表");
$objProps->setCategory("变动报表");
//*************************************
//设置当前的sheet索引,用于后续的内容操作。
//一般只有在使用多个sheet的时候才需要显示调用。
//缺省情况下,PHPExcel会自动创建第一个sheet被设置SheetIndex=0
$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet();
//设置当前活动sheet的名称
$objActSheet->setTitle('月增减变动报表');
//*************************************
//
//设置宽度,这个值和EXCEL里的不同,不知道是什么单位,略小于EXCEL中的宽度
$objActSheet->getColumnDimension('A')->setWidth(20);
$objActSheet->getColumnDimension('B')->setWidth(10);
$objActSheet->getColumnDimension('C')->setWidth(6);
$objActSheet->getColumnDimension('D')->setWidth(20);
$objActSheet->getColumnDimension('E')->setWidth(12);
$objActSheet->getColumnDimension('F')->setWidth(10);
$objActSheet->getColumnDimension('G')->setWidth(20);
$objActSheet->getColumnDimension('H')->setWidth(18);
$objActSheet->getColumnDimension('I')->setWidth(12);
$objActSheet->getColumnDimension('J')->setWidth(8);
$objActSheet->getColumnDimension('K')->setWidth(8);
$objActSheet->getColumnDimension('L')->setWidth(12);
$objActSheet->getColumnDimension('M')->setWidth(10);
$objActSheet->getColumnDimension('N')->setWidth(10);
$objActSheet->getRowDimension(1)->setRowHeight(30);
$objActSheet->getRowDimension(2)->setRowHeight(27);
$objActSheet->getRowDimension(3)->setRowHeight(16);
//设置单元格的值
$objActSheet->setCellValue('A1', '章贡区医疗保险局职工月增减变动报表');
//合并单元格
$objActSheet->mergeCells('A1:N1');
//设置样式
$objStyleA1 = $objActSheet->getStyle('A1');
$objStyleA1->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objFontA1 = $objStyleA1->getFont();
$objFontA1->setName('宋体');
$objFontA1->setSize(18);
$objFontA1->setBold(true);
//设置居中对齐
$objActSheet->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('B2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('C2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('D2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('E2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('F2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('G2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('H2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('I2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('J2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('K2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('L2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('M2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->getStyle('N2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->setCellValue('A2', '现所在单位');
$objActSheet->setCellValue('B2', '姓名');
$objActSheet->setCellValue('C2', '性别');
$objActSheet->setCellValue('D2', '身份证号码');
$objActSheet->setCellValue('E2', '参保时间');
$objActSheet->setCellValue('F2', '增减原因');
$objActSheet->setCellValue('G2', '原所在单位');
$objActSheet->setCellValue('H2', '增减时间');
$objActSheet->setCellValue('I2', '退休时间');
$objActSheet->setCellValue('J2', '原工资');
$objActSheet->setCellValue('K2', '现工资');
$objActSheet->setCellValue('L2', '定点医院');
$objActSheet->setCellValue('M2', '操作人');
$objActSheet->setCellValue('N2', '备注');
//设置边框
$objActSheet->getStyle('A2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$query=$data->query($sql);
$i=1;
//从数据库取值循环输出
while($result=mysql_fetch_row($query)){
$personName=$result[1];
$idcard=$result[2];
$old_company=$result[3];
$new_company=$result[4];
$sex=$result[5];
$start_time=$result[6];
$reason=$result[7];
$retire_time=$result[8];
$old_wages=$result[9];
$new_wages=$result[10];
$hospital=$result[11];
$remarks=$result[12];
$operator=$result[13];
$oper_time=$result[14];
$n=$i+2;
$objActSheet->getStyle('B'.$n)->getNumberFormat()->setFormatCode('@');
$objActSheet->getStyle('E'.$n)->getNumberFormat()->setFormatCode('@');
$objActSheet->getRowDimension($n)->setRowHeight(16);
$objActSheet->getStyle('A'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('A'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('B'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('C'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('D'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('E'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('F'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('G'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('H'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('I'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('J'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('K'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('L'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('M'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$objActSheet->getStyle('N'.$n)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
$xb="男";
if($sex==1){
$xb="女";
}
$objActSheet->setCellValue('A'.$n, $new_company);
$objActSheet->setCellValue('B'.$n, $personName);
$objActSheet->setCellValue('C'.$n, $xb);
$objActSheet->setCellValue('D'.$n, ' '.$idcard.' ');
$objActSheet->setCellValue('E'.$n, $start_time);
$objActSheet->setCellValue('F'.$n, $reason);
$objActSheet->setCellValue('G'.$n, $old_company);
$objActSheet->setCellValue('H'.$n, $oper_time);
$objActSheet->setCellValue('I'.$n, $retire_time);
$objActSheet->setCellValue('J'.$n, $old_wages);
$objActSheet->setCellValue('K'.$n, $new_wages);
$objActSheet->setCellValue('L'.$n, $hospital);
$objActSheet->setCellValue('M'.$n, $operator);
$objActSheet->setCellValue('N'.$n, $remarks);
$i++;
}
//*************************************
//输出内容
//
$outputFileName = "tables/".$cancel_time."addminus.xls";
//到文件
$objWriter->save($outputFileName);
//下面这个输出我是有个页面用Ajax接收返回的信息
echo("<a href="tables/".$cancel_time."addminus.xls" mce_href="tables/".$cancel_time."addminus.xls" target='_blank'>点击下载电子表</a>");
?>
监听浏览器关闭窗口消息
Onunload与Onbeforeunload
Onunload,onbeforeunload都是在刷新或关闭时调用,可以在<script>脚本中通过window.onunload来指定或者在<body>里指定。区别在于onbeforeunload在onunload之前执行,它还可以阻止onunload的执行。
Onbeforeunload也是在页面刷新或关闭时调用,Onbeforeunload是正要去服务器读取新的页面时调用,此时还没开始读取;而onunload则已经从服务器上读到了需要加载的新的页面,在即将替换掉当前页面时调用。Onunload是无法阻止页面的更新和关闭的。而 Onbeforeunload 可以做到。曾经做一个考试系统,涉及到防止用户半途退出考试(有意或者无意),代码如下:
Java代码
<script type="text/javascript">
<!--
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning;
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning);
}
// -->
</script>
Java代码
这段代码在FF和IE上都能正确执行.再点击关闭按钮时首先触发obbeforeunload事件,点击否定时不执行onload事件.
Java代码
通常应用在 注销session等等登陆信息 等方面....
Java代码
这里一并推荐一个ActionScript3的好教程: <a href="http://gskinner.com/talks/as3workshop/">http://gskinner.com/talks/as3workshop/</a>
写道
运用onunload事件判断浏览器是刷新还是关闭窗口
写道
function CloseOpen(event) {
if(event.clientX<=0 && event.clientY<0) {
alert("关闭");
}
else
{
alert("刷新或离开");
}
}
Java代码
window.onbeforeunload = function() //author: meizz
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
alert("是关闭而非刷新");
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
PHP里有用plit()有时会出现Warning: split(): REG_EMPTY.
<?
$str="q63|q64|q65|";
$str1=split('|',$str);
for($i=0;$i<count($str1);$i++)
{
echo $str1[$i]."<br>";
}
?>
纠正这个错误:将"|"用"\"引用,即改成$str1=split('\|',$str);就哦了
发表评论
-
学习关键词
2011-11-02 09:55 635php 正则表达式分割字符 split the phrase ... -
web系统权限管理实现
2011-08-29 16:54 898计算最大值时,忽略那个F。计算温度差时,但凡有F的那个点 ... -
cakephp系统优化
2011-08-02 08:57 893这几天的工作就是系统的最后优化! 1)把页面元素的初始化值写 ... -
php数据库备份和恢复
2011-07-22 13:41 8521)在php.ini里把disable_functions = ... -
cakephp---webservice
2011-07-12 16:24 789http://topic.csdn.net/u/2011011 ... -
cakephp工作笔记20110601_控制器中访问其他控制器方法
2011-06-01 15:02 811requestAction(string $url, arra ... -
cakephp工作笔记42-3态按钮效果
2011-04-27 16:45 733http://widowmaker.kiev.ua/check ... -
php编辑器--phpdesinger7
2011-01-17 09:00 793官方网站http://www.mpsoftware.dk/ph ... -
ACTIVEX控件数字证书
2011-01-04 21:33 891http://wenku.baidu.com/view/2be ... -
cakephp工作笔记25----web项目打包生成exe,备份初始化信息
2010-12-30 14:07 14881)打包内容phpnow+web系统+mysql 2)打包步骤 ... -
cakephp工作笔记24---php编程规范
2010-12-23 15:14 812PHP文件夹/文件命名规范 ----------------- ... -
cakephp工作笔记23---php机制解析
2010-12-23 14:06 836PHP和Python/Ruby的运行机制有一个本质区别:PHP ... -
cakephp工作笔记17---mysql事务篇
2010-12-14 10:22 1740cakephp1.3版本开始支持事务操作: 例子 functi ... -
cakephp工作笔记16---cakephp缓存和session篇
2010-12-02 16:54 2536http://www.cnblogs.com/confach/ ... -
cakephp工作笔记16---报表篇
2010-11-04 16:44 8103d报表 http://www.maani.us/xml_ch ... -
php高手博客
2010-10-30 19:39 715http://www.zendstudio.net/zend- ... -
cakephp工作笔记41-- move_uploaded_file 中文乱码问题或上传失败问题
2010-10-27 16:06 2288move_uploaded_file 中文乱码问题或上传失败问 ... -
cakephp工作笔记40-登录权限管理+天气预报服务
2010-10-25 16:01 921http://blog.lixiphp.com/cakephp ... -
php 如何发送http请求和实现https接口
2010-10-20 09:49 1764如题,接口如下 1。 输 ... -
解决 PHPNOW 在 DOS 命令行下却无法链接 MySQL 的技术笔记
2010-07-23 10:48 1917,php-apache2handler.ini中, 已经将 p ...
相关推荐
- `install.txt`:提供了安装和配置PHPExcel的指南,指导开发者如何将库集成到他们的项目中。 - `Examples`:包含了一系列示例代码,展示了如何使用PHPExcel进行实际操作,是学习库功能的好资源。 - `Documentation`...
9. `PHPExcel_1.7.9_doc.zip` - 可能是 PHPExcel 文档的另一个压缩包,包含了更多关于库的详细信息和使用指南。 10. `Examples` - 这可能是一个目录,包含了更多的 PHP 示例代码,涵盖各种 PHPExcel 功能。 通过...
对于初学者来说,这是理解和使用 PHPExcel 的关键资源,提供了详细的使用指南和常见问题解答。 总结来说,PHPExcel 是一个强大的工具,它使 PHP 开发者能够方便地生成和处理 Excel 文件。通过学习和实践提供的示例...
《PhpExcel中文帮助手册》是针对PHP开发者的一份详细指南,它提供了如何在PHP环境中操作和处理Excel文件的详细步骤。PhpExcel库允许开发人员创建、读取和修改Microsoft Excel文件,支持多种格式,如Excel2007(.xlsx...
首先,API(Application Programming Interface)文档是开发者理解和使用PHPExcel的核心指南。API文档详细列出了PHPExcel提供的各种类、方法和属性,以及它们的功能和用法。通过阅读API文档,开发者可以了解到如何...
《PHPExcel开发手册》是针对PHP开发者的详尽指南,它主要涵盖了如何使用PHPExcel库来创建、编辑和处理Excel文件的各个细节。此手册是官方文档的中文翻译版本,旨在帮助中国开发者更好地理解和应用这个强大的PHP库。 ...
标签"PHPExcel"进一步确认了这个压缩包与PHPExcel库有关,这可能包含库的源码、文档、示例代码或者安装指南等资源。开发者可以通过学习和理解这些资源来更好地利用PHPExcel。 在压缩包文件名称列表中,"package.xml...
在项目中使用PHPExcel,首先需要下载对应的版本,例如1.7.7。在提供的压缩包文件中,`changelog.txt`记录了版本的更新历史,`license.txt`包含库的授权信息,`install.txt`则提供了安装指南。根据`install.txt`的...
3. **install.txt**:安装指南,详细说明了将PHPExcel集成到PHP项目中的步骤,包括依赖项、配置和安装过程。对于初次使用者来说,这是非常宝贵的资源。 4. **Documentation**:此目录可能包含了PHPExcel的用户手册...
这个中文帮助手册提供了详尽的指南,包括了各种属性和操作方法,并且每个知识点都配备了实例,使得学习和应用变得更加直观。 首先,设置 Excel 文档的基本属性是非常重要的,例如创建人、最后修改人、标题、题目、...
- **install.txt**:安装指南,提供了将PHPExcel集成到你的PHP项目中的步骤和注意事项,包括安装依赖、引入库文件以及配置等。 - **Documentation**:此目录可能包含PHPExcel的完整文档,包括API参考、教程和示例...
`install.txt`提供了安装指南,按照其中的步骤,开发者可以快速将PHPExcel集成到自己的项目中。 `绿盟.url`可能是一个链接,指向关于PHPExcel的更多资源或社区支持,对于解决疑难问题或者寻求帮助非常有用。`...
这个1.7.6版本的文档合集提供了全面的开发者和用户指南,是学习和掌握PHPExcel不可或缺的资源。 首先,"PHPExcel developer documentation.doc"是针对开发者的详细文档,它涵盖了库的基本结构、类和方法的介绍。在...
通过使用PHPExcel,开发者可以方便地在Web应用中生成报表、导出数据或者进行数据分析,而无需依赖Microsoft Office或安装任何其他软件。 二、Excel属性设置 在手册中,你会了解到如何设置Excel工作簿的基本属性,如...
3. install.txt: 提供了详细的安装指南,帮助开发者正确地将PHPExcel集成到自己的项目中。 4. Classes: 这是一个包含所有核心类的目录,是PHPExcel库的核心部分,开发者可以通过这些类实现与Excel文件的交互。 总结...
3. install.txt:安装指南,详细描述了如何在PHP环境中安装和配置PHPExcel,包括依赖项和配置步骤。 4. Documentation:这部分可能包含了库的用户手册、API参考、教程和其他学习资源,帮助开发者理解和使用PHPExcel...
本文将详细介绍如何使用PHPExcel库来导出数据为Excel文件,并提供一些优化的实践指南。 ### PHPExcel库简介 PHPExcel是一个独立于商业软件的库,它允许开发者使用PHP语言来读取、写入、修改和创建Excel文件。它...
2. 阅读`changelog.txt`了解版本更新内容,`install.txt`提供安装指南。 3. 将`Classes`目录中的文件引入到PHP项目中,通过require_once语句加载必要的类文件。 4. 遵循示例代码或API文档,根据项目需求编写读写...
- **创建工作簿**: 使用`PHPExcel`类实例化一个新的工作簿对象。 - **添加工作表**: 通过工作簿对象添加新的工作表。 - **写入数据**: 在指定的工作表上设置单元格值。 **1.4 有用链接和工具** - **OpenXML/...