Home > php教程 > php手册 > body text

PHP学习笔记:COM应用

WBOY
Release: 2016-06-21 09:05:37
Original
801 people have browsed it

笔记

ADODB应用:

$conn = new COM("ADODB.Connection");
$conn->Open("Provider = Microsoft.JET.OLEDB.4.0;Data source=D:\usr\www\html\data.mdb");  //ACCESS
//$conn->Open("Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=database;User ID=user;Password=password:)";  //SQL
$rs = $conn->Execute("select * from Spzs");

$num_columns = $rs->Fields->Count();
echo $num_columns . "\n条记录
";
for ($i = 0;$i  $fld[$i] = $rs->Fields($i);
}
$rowcount = 0;
while (!$rs->EOF){
 for ($i=0;$i  echo $fld[$i]->value . "\t";  //\t为TAB键
 }
 echo "

";
 $rowcount++;   //rowcount递增
 $rs->MoveNext();
}
$rs->Close();
$conn->Close();

$rs->Release();
$conn->Release();

$rs = null;
$conn = null;
?>

调用WORD对象:

$word = new COM("word.application") or die ("Canot start Microsoft Word");
print "Loaded Word version ($word->Version)\n";
$word->visible = 1;  //将其置前
$word->Documents->Add(); //打开一个新文档

//随便做些事情
$word->Selection->Typetext("This is a test");
$word->Documents[1]->SaveAs("Useless test.doc");
$word->Quit(); //关闭WORD
//释放对象
$word->Release();
$word = null ;
?>



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template