技術討論區 > 網頁技術

請問ExcelWriterXML如何寫入中文

(1/1)

tonyvan123:
經過1個星期的測試,中文問題仍無解

tonyvan123:
<?php
/**
 * Example page for how to use the Excel Writer XML
 * @package ExcelWriterXML
 * @subpackage examples
 * @filesource
 */

/**
 * Include the required Class file
 */
include('ExcelWriterXML.php');

/**
 * @source
 */
$xml = new ExcelWriterXML;
$xml->docAuthor('Robert F Greer');
$xml->overwriteFile(true);

$iHeaderFormat1 = $xml->addStyle('StyleHeader');
$iHeaderFormat1->alignHorizontal("Left");
$iHeaderFormat1->alignVertical("Center");

$iTextFormat1 = $xml->addStyle('Text1');
$iTextFormat1->alignHorizontal("Left");
$iTextFormat1->alignVertical("Center");
 
$iNUMFormat1 = $xml->addStyle('Number1');
$iNUMFormat1->alignHorizontal("Right");
$iNUMFormat1->alignVertical("Center"); 
$iNUMFormat1->numberFormat('#,##0.00'); 


$iDateFormat1 = $xml->addStyle("DateFormat1");
$iDateFormat1->alignHorizontal("Left");
$iDateFormat1->alignVertical("Center");
$iDateFormat1->numberFormatDatetime('yyyy/mm/ddThh:mm:ss');
 
$sheet1 = $xml->addSheet('My Sheet');

$sheet1->writeString(1,1,'標題一','StyleHeader');
$sheet1->writeString(1,2,'Number','StyleHeader');
$sheet1->writeString(1,3,'DateTime','StyleHeader');

$sheet1->writeString(2,1,'Test String','Text1');
$sheet1->writeNumber(2,2,1234.32,'Number1');
$sheet1->writeDateTime(2,3,'2015/10/23 11:52:12','DateFormat1');

$xml->sendHeaders();
$xml->writeData('MyFile1.xml');
?>

tonyvan123:
自己解答
把 ExcelWriterXML.php中的xml head 改掉即可

修改前$xml = '<?xml version="1.0"  ?>'

修改後$xml = '<?xml version="1.0"  encoding="BIG5" ?>'

導覽

[0] 文章列表

前往完整版本