成都公司:成都市成華區(qū)建設(shè)南路160號(hào)1層9號(hào)
重慶公司:重慶市江北區(qū)紅旗河溝華創(chuàng)商務(wù)大廈18樓
當(dāng)前位置:工程項(xiàng)目OA系統(tǒng) > 泛普各地 > 江西OA系統(tǒng) > 南昌OA系統(tǒng) > 南昌網(wǎng)站建設(shè)公司
PHP設(shè)計(jì)模式介紹值對(duì)象模式
申請(qǐng)免費(fèi)試用、咨詢電話:400-8352-114
南昌網(wǎng)站建設(shè)www.diyphp.net
PHP操作word文檔的二種辦法
辦法一:應(yīng)用php com模塊 。也即應(yīng)用word供應(yīng)的當(dāng)?shù)豠pi,一切只合用于windows系統(tǒng)上。

	view plaincopy to clipboardprint?
	<?php  
	$word = new com('word.application') or die('無法翻開word');  
	$word->Visiable = false;  
	$doc_file = '/path/to/doc';  
	$word->Open($doc_file);  
	$text = '這段文字將被寫到word文檔中去';  
	$word->Selection->TypeText($text);  
	//保管  
	$word->ActiveDocument->Save();  
	//讀取內(nèi)容  
	$doc_file_contents = $word->ActiveDocument->Content->Text;  
	//輸出word內(nèi)容  
	$word->PrintOut();  
	$word->Close();  
	?> 
	<?php
	$word = new com('word.application') or die('無法翻開word');
	$word->Visiable = false;
	$doc_file = '/path/to/doc';
	$word->Open($doc_file);
	$text = '這段文字將被寫到word文檔中去';
	$word->Selection->TypeText($text);
	//保管
	$word->ActiveDocument->Save();
	//讀取內(nèi)容
	$doc_file_contents = $word->ActiveDocument->Content->Text;
	//輸出word內(nèi)容
	$word->PrintOut();
	$word->Close();
	?>
	
	應(yīng)用com銜接word,常常無法預(yù)期運(yùn)轉(zhuǎn)成功,不不變當(dāng)前也不曉得是什么緣由,臨時(shí)靠命運(yùn)運(yùn)限吧。
辦法二:應(yīng)用catdoc。catdoc是linux上的東西,需求自行裝置裝備。
	view plaincopy to clipboardprint?
	<?php  
	//catdoc地位  
	$cat_doc = '/usr/local/bin/catdoc';  
	$doc_file = 'this is a doc file';  
	//讀取word文件內(nèi)容  
	$doc_file_contents = shell_exec($cat_doc . ' ' . $doc_file);   
	echo nl2br($doc_file_contents);  
	?> 
	<?php
	//catdoc地位
	$cat_doc = '/usr/local/bin/catdoc';
	$doc_file = 'this is a doc file';
	//讀取word文件內(nèi)容
	$doc_file_contents = shell_exec($cat_doc . ' ' . $doc_file);
	echo nl2br($doc_file_contents);
	?>
	
	關(guān)于更多catdoc的相關(guān)功用,請(qǐng)查閱catdoc文檔。
	因?yàn)閏atdoc是linux的東西,所以上面的這段代碼只能運(yùn)轉(zhuǎn)在linux效勞器上,罷了必需裝置了catdoc。
	
	 
本站推薦
- 1php材料管理軟件,高效實(shí)現(xiàn)材料信息管理與流程自動(dòng)化
 - 2合同管理軟件php,助力企業(yè)高效管理合同,提升合同處理效率
 - 3php建筑材料管理系統(tǒng),高效實(shí)現(xiàn)建筑材料出入庫(kù)、庫(kù)存及采購(gòu)管理
 - 4PHP系統(tǒng)加持,項(xiàng)目進(jìn)度管理更順手
 - 5PHP項(xiàng)目進(jìn)度寶,管理難題輕松解
 - 6告別進(jìn)度混亂,PHP系統(tǒng)來搞定!
 - 7PHP系統(tǒng)在手,項(xiàng)目進(jìn)度無憂!
 - 8工程項(xiàng)目進(jìn)度慢?PHP系統(tǒng)提速快
 - 9PHP項(xiàng)目進(jìn)度神器,工程企業(yè)必備
 

