本文整理汇总了PHP中COM::Quit方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::Quit方法的具体用法?PHP COM::Quit怎么用?PHP COM::Quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::Quit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
public function convert()
{
$excel = new COM('excel.application') or die('Unable to instantiate Excel');
$excel->Visible = false;
$excel->WorkBooks->Open($this->source_file);
$excel->WorkBooks[1]->SaveAs($this->destination_file, $this->_file_type_codes[$this->convert_to]);
$excel->Quit();
unset($excel);
$result = Ak::file_get_contents($this->destination_file);
$this->delete_source_file ? @Ak::file_delete($this->source_file) : null;
$this->keep_destination_file ? null : Ak::file_delete($this->destination_file);
return $result;
}
示例2: convert
public function convert()
{
$word = new COM('word.application') or die('Unable to instantiate Word');
$word->Visible = false;
$word->Documents->Open($this->source_file);
$word->Documents[1]->SaveAs($this->destination_file, $this->_file_type_codes[$this->convert_to]);
$word->Quit();
$word = null;
$result = Ak::file_get_contents($this->destination_file);
$this->delete_source_file ? Ak::file_delete($this->source_file) : null;
$this->keep_destination_file ? null : Ak::file_delete($this->destination_file);
return $result;
}
示例3: php_Word1
function php_Word1($wordname, $htmlname, $content)
{
//获取链接地址
$url = $_SERVER['HTTP_HOST'];
$url = '';
$url = $url . $_SERVER['PHP_SELF'];
$url = dirname($url) . "/";
//建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Unable to instanciate Word");
//显示目前正在使用的Word的版本号
echo "Loading Word, v. {$word->Version}";
//把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
$word->Visible = 1;
//---------------------------------读取Word内容操作 START-----------------------------------------
//打开一个word文档
$word->Documents->Open($url . $wordname);
//将filename.doc转换为html格式,并保存为html文件
$word->Documents[1]->SaveAs(dirname(__FILE__) . "/" . $htmlname, 8);
//获取htm文件内容并输出到页面 (文本的样式不会丢失)
$content = file_get_contents($url . $htmlname);
echo $content;
//获取word文档内容并输出到页面(文本的原样式已丢失)
$content = $word->ActiveDocument->content->Text;
echo $content;
//关闭与COM组件之间的连接
$word->Documents->close(true);
$word->Quit();
$word = null;
unset($word);
//---------------------------------新建立Word文档操作 START--------------------------------------
//建立一个空的word文档
$word->Documents->Add();
//写入内容到新建word
$word->Selection->TypeText("{$content}");
//保存新建的word文档
$word->Documents[1]->SaveAs(dirname(__FILE__) . "/" . $wordname);
//关闭与COM组件之间的连接
$word->Quit();
}
示例4: outputImage
private function outputImage($domain)
{
var_dump('start:' . memory_get_usage());
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$url = "http://www." . $domain;
$file = "../metadata/screen/3000/" . $domain . ".png";
echo $url . "\n";
$browser->Navigate($url);
while ($browser->Busy) {
com_message_pump(1000);
}
if (!file_exists($file)) {
$im = imagegrabwindow($handle, 0);
imagepng($im, $file);
imagedestroy($im);
}
$fp = fopen($file, 'rb');
fpassthru($fp);
$browser->Quit();
var_dump('free:' . memory_get_usage());
}
示例5: doc2pdf
public function doc2pdf($sid)
{
$file = D('file')->where("`sid` = '" . $sid . "'")->find();
$path = get_save_url() . $file['savename'];
$real_path = dirname($_SERVER['DOCUMENT_ROOT'] . $path);
$save_name = end(explode(dirname($_SERVER['DOCUMENT_ROOT'] . $path), $_SERVER['DOCUMENT_ROOT'] . $path));
$save_file_info = $this->path_info(end(explode(dirname($_SERVER['DOCUMENT_ROOT'] . $path), $_SERVER['DOCUMENT_ROOT'] . $path)));
$upload_file_info = $this->path_info($file['name']);
$word = new COM("word.application");
$word->Visible = 0;
$docs = $word->Documents;
$doc = $docs->Open($_SERVER['DOCUMENT_ROOT'] . $path);
$doc->SaveAs($real_path . "/" . $save_file_info['filename'] . ".pdf", 17);
$word->Quit();
$this->pdfImg($real_path . "/" . $save_file_info['filename'] . ".pdf");
$data['name'] = $upload_file_info['filename'] . ".pdf";
$data['savename'] = dirname($file['savename']) . "/" . $save_file_info['filename'] . ".pdf";
$data['extension'] = "pdf";
$data['size'] = filesize($real_path . "/" . $save_file_info['filename'] . ".pdf");
D('file')->where("`sid` = '" . $sid . "'")->save($data);
}
示例6: date
// Заставляем его отобразиться
$xls->Workbooks->Add();
// Добавляем новый документ
$xlsRow = 1;
for ($j = 0; $j < count($data); $j++) {
$range = $xls->Cells($xlsRow, 1);
$range->Value = $data[$j]['Date'];
$range = $xls->Cells($xlsRow, 2);
$range->Value = $data[$j]['Client'];
$range = $xls->Cells($xlsRow, 3);
$range->Value = $data[$j]['Diler'];
$range = $xls->Cells($xlsRow, 4);
$range->Value = $data[$j]['Summ'];
$range = $xls->Cells($xlsRow, 5);
$range->Value = $data[$j]['Network'];
$range = $xls->Cells($xlsRow, 6);
$range->Value = $data[$j]['Num'];
$range = $xls->Cells($xlsRow, 7);
$range->Value = $data[$j]['DocType'];
$range = $xls->Cells($xlsRow, 8);
$range->Value = $data[$j]['DocStatus'];
$xlsRow++;
}
//$range = $xls->Cells($xlsRow,1);
//$range->Value="test";
echo 'INSERT COMPLITE-', date('H:i:s'), ' Current memory usage: ', memory_get_usage(true) / 1024 / 1024, " MB <hr>";
$xls->Workbooks[1]->SaveAs("testCOM.xlsx");
$xls->Quit();
//Закрываем приложение
$xls = Null;
$range = Null;
示例7: COM
//以下为你加载doc模块
// 建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Can't start Word!");
//显示目前正在使用的Word的版本号
echo "Loading Word, v. {$word->Version}<br>";
// 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
// to open the application in the forefront, use 1 (true)
$word->Visible = 0;
//打?一个文档
$word->Documents->OPen($filename);
//读取文档内容
$conetent = $word->ActiveDocument->content->Text;
echo $conetent;
echo "<br>";
// 关闭与COM组件之间的连接
$word->Quit();
} else {
$handle = fopen($filename, "r");
$conetent = fread($handle, filesize($filename));
echo $conetent . "<br>";
}
fclose($handle);
echo "<hr/>";
//以下为取出单词模块
$distinct = true;
/*preg_match_all('/([a-zA-Z]+)/',$conetent,$match);
if($distinct=true)
{
$macth=array_unique($macth);
}
示例8: repStrWORD
/**
* @Title: repStrWORD
* @Description: todo(以字符串方式替换word中的类容,仅适用于win平台)
* @param $docfile 模板文件
* @param $causedir 存放结果文件的文件夹
* @param $bookNamearr 数据数组
* @author jiangx
* @date 2013-10-07 上午11:17:12
* @throws
*/
public function repStrWORD($docfile, $causedir, $bookNamearr)
{
if (!file_exists($docfile)) {
$this->error("模板文件不存在,请检查");
}
if (!file_exists($causedir)) {
$this->createFolders($causedir);
//判断目标文件夹是否存在
}
$filepath = pathinfo($docfile);
$filenameGBK = $causedir . '/' . $bookNamearr['$name'] . '.' . $filepath['extension'];
$filenameUTF8 = iconv("UTF-8", "GBK", $filenameGBK);
copy($docfile, $filenameUTF8);
$office = new COM("word.application", null, CP_UTF8) or die("请安装 office word");
if (!$office) {
$this->error("无法操作office word");
}
//设置Word显示文档是否显示
$office->Visible = 0;
//打开文档
$filenameGBK = iconv("GBK", "UTF-8", $filenameUTF8);
$office->Documents->Open($filenameGBK) or die("无法打开目标文件");
foreach ($bookNamearr as $key => $val) {
if (!$val) {
$val = "";
}
$office->Selection->Find->Execute($key, false, true, false, false, false, true, 1, false, $val, 2);
}
$office->Documents[1]->SaveAs();
//$office->Documents->Close();
$office->Quit();
header("Cache-Control: public");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=" . basename($filenameUTF8));
readfile($filenameUTF8);
}
示例9: COM
<?php
//Create new COM object – excel.application
$xl = new COM("excel.application");
//Hide MS Excel application window
$xl->Visible = 0;
//Create new document
$xlBook = $xl->Workbooks->Add();
//Create Sheet 1
$xlBook->Worksheets(1)->Name = "Worksheet 1";
$xlBook->Worksheets(1)->Select;
//Set Width & Height
$xl->ActiveSheet->Range("A1:A1")->ColumnWidth = 10.0;
$xl->ActiveSheet->Range("B1:B1")->ColumnWidth = 13.0;
//Add text
$xl->ActiveSheet->Cells(1, 1)->Value = "TEXT";
$xl->ActiveSheet->Cells(1, 1)->Font->Bold = True;
//Save document
$filename = tempnam(sys_get_temp_dir(), "excel");
$xlBook->SaveAs($filename);
//Close and quit
unset($xlBook);
$xl->ActiveWorkBook->Close();
$xl->Quit();
unset($xl);
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;Filename=document_name.xls");
// Send file to browser
readfile($filename);
unlink($filename);
示例10: COM
<?php
// starting word
$ms_word = new COM("word.application") or die("Unable to start Word app");
echo "Found and Loaded Word, version {$ms_word->Version}\n";
//open an empty document
$ms_word->Documents->Add();
//do some weird stuff
$ms_word->Selection->TypeText("Hello World");
$ms_word->Documents[1]->SaveAs("c:/php_com_test.doc");
//closing word
$ms_word->Quit();
//free the object
$ms_word = null;
echo "all done !";
?>
示例11: author_change
function author_change($file_path, $author_Name)
{
$oExplorer = new COM("powerpoint.application");
$oExplorer->Visible = true;
$oExplorer->Presentations->Open2007($file_path);
$oExplorer->ActivePresentation->BuiltInDocumentProperties[3] = $author_Name;
$oExplorer->ActivePresentation->save();
$oExplorer->Quit();
$oExplorer = null;
unset($oExplorer);
}
示例12: get_url_pic2
protected function get_url_pic2($url, $file, $scroll = 420)
{
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Width = 2900;
$browser->Height = 9780;
$browser->Left = 2780;
$browser->Top = 2780;
$browser->menubar = 0;
$browser->AddressBar = 0;
$browser->StatusBar = 0;
$browser->Navigate($url);
$browser->ToolBar = 0;
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$browser->document->parentWindow->scrollTo(0, $scroll);
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, ROOT . $file);
imagedestroy($im);
}
示例13: converttoPDF
function converttoPDF($final_doc)
{
$pdf_path = str_replace('.docx', '.pdf', $final_doc);
$outputPDFFileNameAndPath = str_replace("\\", "\\\\", $pdf_path);
$outputWordFileNameAndPath = str_replace("\\", "\\\\", $final_doc);
$word = new COM("Word.Application") or die("Could not initialise Object.");
// set it to 1 to see the MS Word window (the actual opening of the document)
$word->Visible = 0;
// recommend to set to 0, disables alerts like "Do you want MS Word to be the default .. etc"
$word->DisplayAlerts = 0;
// open the word 2007-2013 document
//$word->Documents->Open('D:\\inetpub\\qa\\doctopdf\\d2p\\domdocument.docx');
$word->Documents->Open($outputWordFileNameAndPath);
// save it as word 2003
// $word->ActiveDocument->SaveAs('D:\\inetpub\\qa\\wp-content\\uploads\\templatemerge\\masters\\doc\\newdocument1.doc');
// convert word 2007-2013 to PDF
$word->ActiveDocument->ExportAsFixedFormat($outputPDFFileNameAndPath, 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);
// quit the Word process
$word->Quit(false);
// clean up
unset($word);
$deedPDF = $outputPDFFileNameAndPath;
if (file_exists($deedPDF)) {
return $deedPDF;
}
//unload objects and variables
$docx = null;
return $final_doc;
}
示例14: open_resource
public function open_resource()
{
if (!session('userID')) {
$this->success("请登录", index);
return;
}
$resourceid = $_GET['resourceid'];
$where['resourceID'] = $resourceid;
$resource = M('resource');
$resourceInfo = $resource->where($where)->select();
$fileRoot = "Uploads/";
$filepath = $fileRoot . $resourceInfo[0]['path'];
if (file_exists($filepath)) {
$extension = pathinfo($filepath, PATHINFO_EXTENSION);
$imagetype = 'gif|jpeg|png|jpg|bmp';
if ($extension == "doc" or $extension == "docx") {
header("Content-Type:text/html;charset=GBK");
$word = new \COM("word.application") or die("Could not initialise MS Word object.");
//echo "Loaded Word, version {$word->Version}\n";
$word->Visible = 1;
$word->Documents->Open(realpath($filepath));
//计算机安全性问题
// Extract content.
//$content = (string) $word->ActiveDocument->Content;
$content = $word->ActiveDocument->content->Text;
echo $content;
$word->ActiveDocument->Close(false);
$word->Quit();
$word = null;
unset($word);
} else {
if ($extension == "excel") {
echo "在线阅读excel文件不支持";
} else {
if ($extension == "pdf") {
header("content-type:application/pdf");
$fp = fopen($filepath, "r+");
$content = fread($fp, filesize($filepath));
echo $content;
fclose($fp);
} else {
if (stripos($imagetype, $extension)) {
header("content-type:image");
$fp = fopen($filepath, "r+");
$content = fread($fp, filesize($filepath));
echo $content;
fclose($fp);
} else {
header("Content-Type:text/html;charset=GBK");
$fp = fopen($filepath, "r+");
$content = fread($fp, filesize($filepath));
$content = str_replace("\r\n", "<br />", $content);
echo $content;
fclose($fp);
}
}
}
}
} else {
$this->error("打开失败", Teacher_Resource);
}
}
示例15: getExcelFileContents
function getExcelFileContents($filename, $orig_filename)
{
$tmp_file = realpath($filename) . '.csv';
$title = '';
$content = '';
// http://msdn.microsoft.com/en-us/library/bb978780(office.12).aspx
$xls = new COM("Excel.application") or die("Unable to instantiate Excel");
$xls->DisplayAlerts = false;
$xls->Visible = true;
$xls->Workbooks->Open(realpath($filename)) or die("Could not open file");
$book = $xls->ActiveWorkbook;
$title = $book->Name();
$num_sheets = $book->Sheets->Count();
for ($i = 1; $i <= $num_sheets; $i++) {
$book->Sheets[$i]->SaveAs($tmp_file, 6);
// 6 = csv file
$content .= file_get_contents($tmp_file);
}
$book->Close(false);
$xls->Workbooks->Close();
unset($book);
$xls->Quit();
unset($xls);
unlink($tmp_file);
return array('body' => $content, 'title' => $title);
}