- 註冊時間
- 2002-8-8
- 線上時間
- 3361 小時
- 閱讀權限
- 200
- 積分
- 1429
- 主題
- 104
- 精華
- 1
- 文章
- 1533
該用戶從未簽到 - 文章
- 1533
|
最近工作要解決一個問題:
使用 PHP 輸出 .doc 跟 .xls 報表。
網路上有找到一些資訊,例如:
- <?php
- // Some servers may have an auto timeout, so take as long as you want.
- set_time_limit(0);
- // Show all errors, warnings and notices whilst developing.
- error_reporting(E_ALL);
- // Used as a placeholder in certain COM functions where no parameter is required.
- $empty = new VARIANT();
- // Load the appropriate type library.
- com_load_typelib('Word.Application');
- // Create an object to use.
- $word = new COM('word.application') or die('Unable to load Word');
- print "Loaded Word, version {$word->Version}\n";
- // Open a new document with bookmarks of YourName and YourAge.
- $word->Documents->Open('D:/apache/Projects/ham/ham_file/Unfilled1.DOC');
- // Fill in the information from the form.
- // Note use of wdGoToBookmark, from the typelibrary and the use of $empty.
- $word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'YourName');
- $word->Selection->TypeText($_GET['YourName']);
- $word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'YourAge');
- $word->Selection->TypeText($_GET['YourAge']);
- // Save it, close word and finish.
- $word->Documents[1]->SaveAs("D:/apache/Projects/ham/ham_file/" . $_GET['YourName'] . ".doc");
- $word->Quit();
- $word->Release();
- $word = null;
- print "Word closed.\n";
- ?>
複製代碼
這樣的程式碼對 PHP 中如何應用 COM 是有相當的幫助,但是,這些操作 Word 跟 Excel 的 method 要去哪找呢? google 跟微軟的站台內輸入 COM Word Excel 都找不到高相關的資料,驢子找 com 給一些 computer component comXXX 的結果也不太有用,讓對微軟相當不熟悉的我實在很傷腦筋。
請教對微軟熟的朋友,這個資訊要去哪找?找書的話要往哪個類別去看?
(VB?)
順道晚安~
[ Last edited by Dragoon on 2004-11-12 at 03:02 ] |
|