1.如何在php下实现word转换成HTML,都进来看看吧
你好,试试我这个吧
刚刚测试完的。
@author axgle
直接用php把word文档转化成HTML文件
适用于windows和安装了word的环境
*/
function word2html($wfilepath)
{
$word=new COM("Word.Application") or die("无法打开 MS Word");
$word->visible = 1 ;
$word->Documents->Open($wfilepath)or die("无法打开这个文件");
$htmlpath= substr($wfilepath,0,-4);
$word->ActiveDocument->SaveAs($htmlpath,8);
$word->quit(0);
}
$w="G:/mon/conn.php';// New Word Document$PHPWord = new PHPWord();/**********文本格式的word text.php************/// New portrait section//逗号 分割字符串$arr = $_REQUEST['arr'];$a = explode(',',$arr);//echo $arr; date_default_timezone_set("Asia/Shanghai");//设置一个时区$tm=date('Y-m-d H:i:s');//exit($tm);/**********前多日雨量*********/ if(in_array('1', $a, TRUE)){$section = $PHPWord->createSection();$PHPWord->addFontStyle('rStyle', array('bold'=>false, 'italic'=>false, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));$c = "前三日雨量报表";$section->addText($c, 'rStyle', 'pStyle');$styleTable = array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80);$styleFirstRow = array('borderBottomSize'=>18, 'borderBottomColor'=>'0000FF', 'bgColor'=>'66BBFF');// Define cell style arrays$styleCell = array('valign'=>'center');// Define font style for first row$fontStyle = array('bold'=>true, 'align'=>'center');//设置标题$PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));// Add table style$PHPWord->addTableStyle('myOwnTableStyle', $styleTable, $styleFirstRow);// Add table$table = $section->addTable('myOwnTableStyle');// Add row设置行高$table->addRow(500);$table->addCell(2300, $styleCell)->addText('站码', $fontStyle);$table->addCell(2300, $styleCell)->addText('站名', $fontStyle);$table->addCell(2300, $styleCell)->addText('雨量', $fontStyle);$table->addCell(2300, $styleCell)->addText('水文站监测类型', $fontStyle);$conn = mssql_connect($config['mssql']['host'],$config['mssql']['user'],$config['mssql']['password']); mssql_select_db($config['mssql']['dbname'],$conn);$stm = date('Y-m-d H:i:s',strtotime('-3 days'));$sql = "EXEC HNOW05_GETPPSPACE '','','".$stm."',1,1";$res=mssql_query($sql); while($arr = mssql_fetch_array($res)){//echo $arr["STCD"]."";$table->addRow();$table->addCell(2300)->addText($arr["STCD"]);$table->addCell(2300)->addText($arr["STNM"]);$table->addCell(2300)->addText($arr["P"]); if($arr["STTP"] == 'MM'){$table->addCell(2300)->addText('气象站'); }else if($arr["STTP"] == 'BB'){$table->addCell(2300)->addText('蒸发站'); }else if($arr["STTP"] == 'DD'){$table->addCell(2300)->addText('堰闸水文站'); }else if($arr["STTP"] == 'TT'){$table->addCell(2300)->addText('落潮位站'); }else if($arr["STTP"] == 'DP'){$table->addCell(2300)->addText('泵站'); }else if($arr["STTP"] == 'SS'){$table->addCell(2300)->addText('墒情站'); }else if($arr["STTP"] == 'PP'){$table->addCell(2300)->addText('雨量站'); }else if($arr["STTP"] == 'ZZ'){$table->addCell(2300)->addText('河道水位水文站'); }else if($arr["STTP"] == 'RR'){$table->addCell(2300)->addText('水库水文站'); }else if($arr["STTP"] == 'ZG'){$table->addCell(2300)->addText('地下水站'); }else if($arr["STTP"] == 'ZB'){$table->addCell(2300)->addText('分洪水位站'); } }$section->addTextBreak(2); }else{ }/******地质灾害*******/ if(in_array('3', $a, TRUE)){$section = $PHPWord->createSection();$PHPWord->addFontStyle('rStyle', array('bold'=>false, 'italic'=>false, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));$c = "地质灾害";$section->addText($c, 'rStyle', 'pStyle');$content="根据市气象局未来24小时降雨预报和市水利局实时降雨数据,市国土资源局进行了地质灾害预报,请有关部门关注 实时预警信息,做好地质灾害防范工作";$section->addText($content);// Add image elements$section->addImage("images/image001.jpg", array('width'=>600, 'height'=>480, 'align'=>'center')); }else{ }// Save File$fileName = "word报表".date("YmdHis"); header("Content-type: application/vnd.ms-word"); header("Content-Disposition:attachment;filename=".$fileName.".docx"); header('Cache-Control: max-age=0');$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');$objWriter->save('php://output');。
5.txt多行合并成一行和批量修改文件名
第一个问题,用Word打开该txt文件,然后Ctrl+H打开替换对话框,单击高级或者更多,勾选使用通配符,在查找框中输入:\,*^13
在替换为框中输入:,
单击全部替换即可,就可以将各行合并成一行了。
至于第二个问题吗,有点麻烦,毕竟字母只有26个,万一你的文件数超过了26个,此后怎么办?你没有给出具体的命名规则,我猜想,没有现成的工具软件的,只能请别人重新开发符合你特定需要的。或者请人帮你用Word编一段VBA宏代码也行。
6.怎样将php文档转为word文档
pdf格式的文件如何转换成Word文档(2种方法)
1、用ScanSoft PDF Converter Pro v3.0 特别版
为PDF转换提供了完整的解决方案,能合并,转换,直接编辑PDF文件
2、可以利用Office 2003中的Microsoft Office Document Imaging组件来实现PDF转WORD文档,
也就是说利用WORD来完成该任务。方法如下:
用Adobe Reader打开想转换的PDF文件,接下来选择“文件→打印”菜单,在打开的“打印”窗口中将“打印机”
栏中的名称设置为“Microsoft Office Document Image Writer”,确认后将该PDF文件输出为MDI格式的虚拟打印文件。
注:如果没有找到“Microsoft Office Document Image Writer”项,使用Office 2003安装光盘中的“添加/删除
组件”更新安装该组件,选中“Office 工具 Microsoft DRAW转换器”。
然后,运行“Microsoft Office Document Imaging”,并利用它来打开刚才保存的MDI文件,选择“工具→将文本
发送到Word”菜单,在弹出的窗口中选中“在输出时保持图片版式不变”,确认后系统会提示“必须在执行此操作前重
新运行OCR。这可能需要一些时间”,不管它,确认即可。
以上仅在word2003中可用,其他版本没有Microsoft Office Document Image Writer。
转载请注明出处51数据库 » phpword行合并