[PHP-users 31946] COM�Ǥ�ʸ������

Satto satoru_kumagai �� mjs.co.jp
2007ǯ 4�� 17�� (��) 09:33:32 JST


COM�����Ѥ���Word��ɽ���ʸ����򥻥åȤ�����Ȥߤ�
�ͤ��Ƥ��ޤ���

��
SV -> Windows2000
Apache -> 1.3.26
PHP -> 4.3.9

UTF-8�ǵ��Ҥ��Ƥ��ޤ���
<?php
class setWord {
 var $Word;
 var $doc;
 var $fname;
 
 function setWord(){
  
  $this->Word = new COM('Word.Application');
  $this->Word -> Visible = false;
  $this->Word -> DisplayAlerts = 0;
 }
 
 function documentOpen(){
  $this->doc = $this->Word->Documents->Open('d:/temp/hoge.doc');
  $this->doc -> Activate;
 }
 
 function setParam($param){
  $tbl = $this -> doc->Tables(1);
  $cell = $tbl -> Cell(1,1);
  $cell -> Range -> Text = mb_convert_encoding($param, 'SJIS', 'UTF-8');
 }
 
 function SaveAs(){
  mt_srand();
  $this->fname = mt_rand(1000000000, 2147483647);
  $this->Word -> Documents[1] -> SaveAs("d:/temp/{$this->fname}.doc");
 }
 
 function unsetObj(){
  $this->Word -> Documents[1] -> Close();
  $this->Word -> Quit();
  $this->Word = null;
 }
 
 function returnWord($param){
  $this->documentOpen();
  $this->setParam($param);
  $this->SaveAs();
  $this->unsetObj();
 }
}

$cls = new setWord();
$cls -> returnWord('���ܸ�');
?>

hoge.doc�򥪡��ץ󤷡�ɽ��ʸ����򥻥åȡ��������̾����¸��
��̡�������ư��ե����뤬���������ΤǤ��������Υե������
�����ȡ����åȤ��줿ʸ��������ܸ�פθ���ˡֵѡפΤ褦��ʸ����
�����ƤĤ��Ƥ��ޤ��ޤ���
���ܸ�ѵѵѡ��Τ褦�ʴ����Ǥ���
�֤����������פξ��ϡ������������ѵѵѵѵѡ��Ȥʤ�ޤ���

ʸ����ʬ����������ʸ�����Ĥ��Ƥ��ޤ�������Ĵ�����Ƥ���ΤǤ�����
���Ǥ��ޤ���

�����������ꤤ���ޤ���


PHP-users �᡼��󥰥ꥹ�Ȥΰ���