php表格颜色.docx

上传人:b****6 文档编号:6094438 上传时间:2023-01-03 格式:DOCX 页数:9 大小:20.81KB
下载 相关 举报
php表格颜色.docx_第1页
第1页 / 共9页
php表格颜色.docx_第2页
第2页 / 共9页
php表格颜色.docx_第3页
第3页 / 共9页
php表格颜色.docx_第4页
第4页 / 共9页
php表格颜色.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

php表格颜色.docx

《php表格颜色.docx》由会员分享,可在线阅读,更多相关《php表格颜色.docx(9页珍藏版)》请在冰豆网上搜索。

php表格颜色.docx

php表格颜色

竭诚为您提供优质文档/双击可除

php表格颜色

  篇一:

phpword使用指南by_stone

  phpword使用指南(phpwordbeta0.6.2)

  by--stone

  首先我们要了解文档最基本的信息和设置:

  因为是国外编辑的类库,存在对中文支持的问题,使用前,我们需要进行一些修正:

  1、解决编码问题,phpword会对输入的文字进行utf8_encode编码转化,如果你使用gbk、gb2312或者utf8编码的话就会出现乱码,如果你用utf8编码,就查找类库中所有方法中的utf8_encode转码将其删除,如果你采用gbk或者gb2312编码,使用iconv进行编码转换。

  2、解决中文字体支持,在writer/word20xx/base.php中312行添加$objwriter->writeattribute(w:

eastasia,$font)

  3、启动phpzip支持,windows环境下在php配置文件php.ini中,将extension=php_zip.dll前面的分号“;”去除;(如果没有,请添加extension=php_zip.dll此行并确保php_zip.dll文件存在相应的目录),然后同样在php.ini文件中,将zlib.output_compression=off改为zlib.output_compression=on;

  计量单位:

缇(twips)

  首先解释一下phpword最基本的计量单位:

“缇”(twips),我们常常在文件中看到或使用计量单位“缇”,它是开源办公软件中最基

  本的计量单位,“缇”是"twentiethofaninchpoint"的简写,意思1/20磅,与其他常用剂量单位的换算是1缇=1/1,440英寸,1缇=1/567厘米,1缇=1/15像素

  新建文档

  添加页面

  添加默认页面(默认页面方向和页边距):

  页面样式

  创建样式数组:

  文本

  添加文本

  向文档添加文本使用方法函数:

addtext.(注意phpword会对输入的文字进行utf8_encode编码转化,如果你使用gbk、gb2312或者utf8编码的话就会出现乱码,如果你用utf8编码,就查找类库中所有方法中的utf8_encode转码将其删除,如果你采用gbk或者

  gb2312编码,使用iconv进行编码转换。

  添加换行符添加换行符,使用方法函数addtextbreak:

  添加多个换行符:

  添加分页符

  添加分页符,使用方法函数:

addpagebreak:

  添加超链接

  添加超链接,使用方法函数:

addlink:

  注意在添加链接地址时最好trim一下前后有空格很可有可能导致文档打不开

  超链接样式

  定义超链接风格的两种方法

  内嵌样式:

  或者定义一个样式定义设置超链接样式,定义一种样式后,必须把第三个参数设置为样式名称

  添加图片

  添加图片的函数方法:

addimage:

  注意在添加图片路径时最好trim一下前后有空格很可有可能导致文档打不开

  图片样式

  添加图片样式只能使用数组方式:

  篇二:

phpexcel

  phpexcel学习笔记

  首先到phpexcel官网上下载最新的phpexcel类,下周解压缩一个classes文件夹,里面包含了phpexcel.php和phpexcel的文件夹,这个类文件和文件夹是我们需要的,把classes解压到你项目的一个目录中,重名名为phpexcel,开始喽,(代码都摘自自带实例)

  程序部分

  require_once./phpexcel/phpexcel.php;

  //首先创建一个新的对象phpexcelobject

  $objphpexcel=newphpexcel();

  //设置文件的一些属性,在xls文件——>属性——>详细信息里可以看到这些值,xml表格里是没有这些值的

  $objphpexcel

  ->getproperties()//获得文件属性对象,给下文提供设置资源

  ->setcreator("maartenballiauw")//设置文件的创建者

  ->setlas(php表格颜色)tmodifiedby("maartenballiauw")//设置最后修改者->settitle("office20xxxlsxtestdocument")//设置标题->setsubject("office20xxxlsxtestdocument")//设置主题

  ->setdescription("testdocumentforoffice20xxxlsx,generatedusingphpclasses.")//设置备注

  ->setkeywords("office20xxopenxmlphp")//设置标记->setcategory("testresultfile");//设置类别//位置aaa*为下文代码位置提供锚

  //给表格添加数据

  $objphpexcel->setactivesheetindex(0)//设置第一个内置表(一个xls文件里可以有多个表)为活动的

  ->setcellValue(a1,hello)//给表的单元格设置数据->setcellValue(b2,world!

)//数据格式可以为字符串->setcellValue(c1,12)//数字型

  ->setcellValue(d2,12)//

  ->setcellValue(d3,true)//布尔型

  ->setcellValue(d4,=sum(c1:

d2));//公式

  //得到当前活动的表,注意下文教程中会经常用到$objactsheet

  $objactsheet=$objphpexcel->getactivesheet();

  //位置bbb*为下文代码位置提供锚

  //给当前活动的表设置名称

  $objactsheet->settitle(simple2222);

  代码还没有结束,可以复制下面的代码来决定我们将要做什么

  我们将要做的是

  1,直接生成一个文件

  $objwriter=

  phpexcel_ioFactory:

:

createwriter($objphpexcel,excel20xx);

  $objwriter->save(myexchel.xlsx);

  2、提示下载文件

  excel20xx.xls

  //生成20xxexcel格式的xls文件

  header(content-type:

application/vnd.ms-excel);

  header(content-disposition:

attachment;filename="01simple.xls");header(cache-control:

max-age=0);

  $objwriter=phpexcel_ioFactory:

:

createwriter($objphpexcel,excel5);$objwriter->save(php:

//output);

  exit;

  excel20xx.xlsx

  //生成20xxexcel格式的xlsx文件

  header(content-type:

  application/vnd.openxmlformats-officedocument.spreadsheetml.sheet);header(content-disposition:

attachment;filename="01simple.xlsx");header(cache-control:

max-age=0);

  $objwriter=phpexcel_ioFactory:

:

createwriter($objphpexcel,excel20xx);

  $objwriter->save(php:

//output);

  exit;

  pdf文件

  //下载一个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;

  //生成一个pdf文件

  $objwriter=phpexcel_ioFactory:

:

createwriter($objphpexcel,pdF);

  $objwriter->save(a.pdf);

  csV文件

  $objwriter=

  phpexcel_ioFactory:

:

createwriter($objphpexcel,csV)->setdelimiter(,)//设置分隔符

  ->setenclosure(")//设置包围符

  ->setlineending("\r\n")//设置行分隔符

  ->setsheetindex(0)//设置活动表

  ->save(str_replace(.php,.csv,__File__));

  html文件

  $objwriter=

  phpexcel_ioFactory:

:

createwriter($objphpexcel,html);//将$objphpecel对象转换成html格式的

  $objwriter->setsheetindex(0);//设置活动表

  //$objwriter->setimagesRoot();

  $objwriter->save(str_replace(.php,.htm,__File__));//保存文件

  设置表格样式和数据格式

  设置默认的字体和文字大小锚:

aaa

  $objphpexcel->getdefaultstyle()->getFont()->setname(arial);$objphpexcel->getdefaultstyle()->getFont()->setsize(20);

  日期格式锚:

bbb

  //获得秒值变量

  $datetimenow=time();

  //三个表格分别设置为当前实际的日期格式、时间格式、日期和时间格式

  //首先将单元格的值设置为由phpexcel_shared_date:

:

phptoexcel方法转换后的excel格式的值,然后用过得到该单元格的样式里面数字样式再设置显示格式

  $objactsheet->setcellValue(c9,

  phpexcel_shared_date:

:

phptoexcel($datetimenow));

  $objactsheet->getstyle(c9)->getnumberFormat()->setFormatcode(phpexcel_style_numberFormat:

:

FoRmat_date_yyyymmdd2);

  $objactsheet->setcellValue(c10,

  phpexcel_shared_date:

:

phptoexcel($datetimenow));

  $objactsheet->getstyle(c10)->getnumberFormat()->setFormatcode(phpexcel_style_numberFormat:

:

FoRmat_date_time4);

  $objactsheet->setcellValue(c10,

  phpexcel_shared_date:

:

phptoexcel($datetimenow));

  $objactsheet->getstyle(c10)->getnumberFormat()->setFormatcode(phpexcel_style_numberFormat:

:

FoRmat_date_time4);

  //将e4到e13的数字格式设置为euR

  $objphpexcel->getactivesheet()->getstyle(e4:

e13)->getnumberFormat()->setFormatcode(phpexcel_style_numberFormat:

:

FoRmat_cuRRency_euR_simple);

  设置列的宽度锚:

bbb

  $objactsheet->getcolumndimension(b)->setautosize(true);//内容自适应

  $objactsheet->getcolumndimension(a)->setwidth(30);//30宽

  设置文件打印的页眉和页脚锚:

bbb

  //设置打印时候的页眉页脚(设置完了以后可以通过打印预览来看效果)字符串中的);

  $objactsheet->getheaderFooter()->setoddFooter(.

  $objphpexcel->getproperties()->gettitle().);

  设置页面文字的方向和页面大小锚:

bbb

  $objphpexcel->getactivesheet()->getpagesetup()->setorientation(phpexcel_worksheet_pagesetup:

:

oRientation_landscape);

  $objphpexcel->getactivesheet()->getpagesetup()->setpapersize(phpexcel_worksheet_pagesetup:

:

papeRsize_a4);//a4纸大小

  为页眉添加图片office中有效wps中无效锚:

bbb

  $objdrawing=newphpexcel_worksheet_headerFooterdrawing();

  $objdrawing->setname(phpexcellogo);

  $objdrawing->setpath(./images/phpexcel_logo.gif);

  $objdrawing->setheight(36);

  $objphpexcel->getactivesheet()->getheaderFooter()->addimage($objdrawing,phpexcel_worksheet_headerFooter:

:

image_headeR_leFt);

  设置单元格的批注锚:

bbb

  //给单元格添加批注

  $objphpexcel->getactivesheet()->getcomment(e13)->setauthor(phpexcel);//设置作者

  $objcommentRichtext=

  $objphpexcel->getactivesheet()->getcomment(e13)->gettext()->createtextRun(phpexcel:

);//添加批注

  $objcommentRichtext->getFont()->setbold(true);//将现有批注加粗

  $objphpexcel->getactivesheet()->getcomment(e13)->gettext()->createtextRun("\r\n");//添加更多批注

  $objphpexcel->getactivesheet()->getcomment(e13)->gettext()->createtextRun(totalamountonthecurrentinvoice,includingVat.);$objphpexcel->getactivesheet()->getcomment(e13)->setwidth(100pt);//设置批注显示的宽高,在office中有效在wps中无效

  $objphpexcel->getactivesheet()->getcomment(e13)->setheight(100pt);

  $objphpexcel->getactivesheet()->getcomment(e13)->setmarginleft(150pt);

  $objphpexcel->getactivesheet()->getcomment(e13)->getFillcolor()->setRgb(eeeeee);//设置背景色,在office中有效在wps中无效

  添加文字块看效果图office中有效wps中无效锚:

bbb

  //大概翻译创建一个富文本框office有效wps无效

  $objRichtext=newphpexcel_Richtext();

  $objRichtext->createtext(thisinvoiceis);//写文字

  //添加文字并设置这段文字粗体斜体和文字颜色

  $objpayable=$objRichtext->createtextRun(payablewithinthirtydaysaftertheendofthemonth);

  $objpayable->getFont()->setbold(true);

  $objpayable->getFont()->setitalic(true);

  $objpayable->getFont()->setcolor(newphpexcel_style_color(phpexcel_style_color:

:

coloR_daRkgReen));

  $objRichtext->createtext(,unlessspecifiedotherwiseontheinvoice.);

  //将文字写到a18单元格中

  $objphpexcel->getactivesheet()->getcell(a18)->setValue($objRichtext);

  合并拆分单元格锚:

bbb

  $objphpexcel->getactivesheet()->mergecells(a28:

b28);//a28:

b28合并

  篇三:

php基础测试b(附答案)

  php基础测试题

  (答题时间:

90分钟总分100分)

  1,哪一个是比较字符串的函数

  a,strtolen()

  b,strops();

  c,substr();

  d,strcmp();

  2,哪些函数与文件上传无关或是错误的【多选题】

  a,move_uploaded_file();

  b,is_uploaded_file();

  c,move_file_uploaded();

  d,move_file_uploade();

  3,中文字符集下面描述错误的是

  a,utf-8这样来设置字符集在mysql里面是错误的。

  b.utf-8占用三个长度而gbk或gb2312占用两个长度

  c,utf-8和gb2312能使用substr来切割

  d,如果utf-8没有去掉bom头header()函数发送信息也正常

  4,下面这段代码哪段代码是正常的?

  a:

Functonshow(){

  echo‘aaaaaaaaaaa’;

  }

  b,Functonshow(){

  echo‘aaaaaaaaa’;

  }

  c,Functionshow(){

  echo‘aaaaaaaaaaa’;

  }

  d,Functionshow{

  echo‘aaaaaaaaaa’;

  }

  5,请写出以下答案运行的正确结果?

    $a=9;

  $b=9;

  $c=$a+++++$b;

  $e=$a--+--$a;

  $f=++$b+++$a;

  $g=$a--+++$b;

  echo$f+$g;

  >

  a,语法错误

  b,41

  c,36

  d,39

  6,哪一个不是分帧里面的属性?

  a,colspan

  b,cols

  c,noresize

  d,src

  7,php的mysql函数当中获得查询出来多少行的专业函数为

  a,mysql_affetced_rows()

  b,mysql_rows_num();

  c,mysql_num_rows();

  d,mysql_get_rows();

  8,在打开文件时不能打开文件的函数为

  a,file_get_contents();

  b,fopen(‘d.txt’,’r+’);

  c,unlink(‘gg.txt’);

  9,支持事务的存储引擎是谁?

  a,myisam

  b,csV

  c,innodb

  d,merge

  10,更改表字段名的标准语法为

  a,altertable表名add字段字类型[first|after]

  b,altertable表名drop字段[first|after]

  c,altertable表名change原名新名新类型[first|after]

  d,altertable表名modify原名字段类型[first|after]

  11,无法写入数据库的原因经常不可能有

  a,字符集不正确

  b,sql语句不正确,我们可以用输出来调试,并复制进工具当中进行查询c,字段名写错或数据类型不准确

  d,null类型字段当中没有插入数据

  12,唯一字符串的id的函数是?

  a,rand(0,10000);

  b,uniqid();

  c,eval();

  d,com_id();

  13,php可以html混编,当get传递一个rgb颜色名为bgcolor,自动改变背景颜色的php代码为:

  a,>

  b,”>c,">

  d,’>

  14,请写出join的作用。

  a,将字符串进行连接

  b,将数组当中的字符串以指定的字符连接返回一个字符串

  c,将数组当中的元素以指定的字符串连接返回一个字符串

  d,将数当中的元素以指定字符进行切割

  15,php的mysql系列函数中常用的遍历数据的的函数是

  a,mysql_fetch_row,mysql_fetch_assoc,mysql_affetced_rows

  b,mysql_fecth_row,mysql_fecth_assoc,mysql_affetced_rows

  c,mysql_fetch_rows,mysql_fetch_array,mysql_fetch_assoc

  d,mysql_fecth_row,mysql_fecth_array,mysql_fecth_assoc

  16,如下哪句话是对$_get,$_post,$_Request描述正确的。

  a,$_get是接收url传参,$_post是接收文件,$_Request即能接收文件也能够接收uRl传参的内容。

  b,$_post是收url传参,$_get几种方式均能接收,$_Request

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1