技巧|脚本
PHP和COM
如果你是一名冒险份子,而且你正在使用CGI、ISAPI或Apache模块版本的Windows系统上运行着PHP,那么你也可以获得系统的COM功能。现在,解释COM(微软的组件对象模型)的工作留给了微软和那些大部头的图书来完成。然而,知道点COM也没什么错,下面有一个普通的(没有双关语,针对很普通)代码小片断。
这代码小片断使用PHP在后台启动Microsoft Word、打开一个新文件、键入一些文本、保存该文件然后关闭应用程序:
// create a reference to a new COM component (Word)
$word = new COM("word.application") or die("Can't start Word!");
// print the version of Word that's now in use
echo "Loading Word, v. {$word->Version}
";
// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
$word->Visible = 0;
// create a new document in Word
$word->Documents->Add();
// add text to the new document
$word->Selection->TypeText("Testing 1-2-3...");
//save the document in the Windows temp directory
$word->Documents[1]->SaveAs("/Windows/temp/comtest.doc");
// close the connection to the COM component
$word->Quit();
// print another message to the screen
echo "Check for the file...";
?>
假设你正在运行一个内联网Web站点,该站点把数据存放在Microsoft SQL Server数据库内,你的用户需要Excel格式的数据。那么,你可以让PHP执行必要的SQL查询并且格式化输出结果,然后使用COM启动Excel,把数据传输给它,最后再把文件存储到用户的桌面系统内。

在之前的文章《实用Word技巧分享:详解怎么更改图片颜色和形状》中,我们了解了更改图片颜色和图片形状的方法。而今天我们来聊一聊word表格,讲解美化表格--自定义表格样式的方法,快来看看吧!

在之前的文章《实用Word技巧分享:聊聊你没用过的“行号”功能》中,我们了解了Word中你肯定没用过的"行号”功能。今天继续实用Word技巧分享,看看Excel表格怎么借用Word进行分栏打印,快来收藏使用吧!

在之前的文章《实用Word技巧分享:设置页码的终极方法!》中,我们学习了Word页码的设置方法。而今天我们来一起聊聊Word文本间距设置的几个技巧,快来收藏使用吧!

在之前的文章《实用Word技巧分享:隐藏图片,提升文档浏览和编辑效率!》中,我们学习了隐藏图片的技巧,可提升文档浏览和编辑效率。下面本篇文章再给大家分享一个实用Word技巧,看看怎么让页面自动滚动,快来收藏使用吧!

在之前的文章《实用Word技巧分享:表格自定义样式,美化表格!》中,我们了解了自定义表格样式的方法。而今天我们来聊一聊word脚注和尾注,介绍一下脚注和尾注的设置使用方法,快来看看吧!

在之前的文章《实用Word技巧分享:怎么跨文档快速复制样式》中,我们了解了在文档间快速复制样式的方法。今天我们聊聊Word快捷键,聊聊【F4】键快速统一图片大小,快来看看吧!

在之前的文章《实用Word技巧分享:如何一键删除所有数字》中,我们学习了Word中一键删除所有数字的方法。而今天我们来聊聊Word表格中如何自动添加编号,简单却很实用!

在之前的文章《实用Word技巧分享:图、表如何自动编号?》中,我们了解了Word排版-让图、表自动编号的方法。而今天聊聊Word精确控制页面“行数”和“字符个数”的方法,快来看看吧!


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
