请问用phpExcelReader方式,excel文件名字可以是中文吗?
我的代码是
<br />require_once 'phpExcelReader/Excel/reader.php';<br />$data = new Spreadsheet_Excel_Reader();<br />$data->setOutputEncoding('UTF-8');<br />$data->read('物业.xls'); <br />$db = mysql_connect('localhost', 'root', '123456');<br />@mysql_query("set names 'utf8'"); //输出中文 <br />@mysql_select_db('first'); //选择数据库 <br />echo $data->sheets[0]['cells'][1][1];<br />echo $data->sheets[0]['cells'][3][1];<br />
现在excel的名字是英文的,可以读取excel数据,可“物业.xls”,就会报错:
Fatal error: Uncaught exception ‘Exception’ with message ‘Could not open 物业.xls for reading! File does not exist, or it is not readable.’ in D:\PHP\htdocs\phpMyAdmin\libraries\PHPExcel\PHP本文@来#源gaodai$ma#com搞$$代**码网搞代gaodaima码Excel\Shared\OLERead.php:72 Stack trace: #0 D:\PHP\htdocs\phpExcelReader\Excel\reader.php(389): PHPExcel_Shared_OLERead->read(‘??????.xls’) #1 D:\PHP\htdocs\1.php(5): Spreadsheet_Excel_Reader->read(‘??????.xls’) #2 {main} thrown in D:\PHP\htdocs\phpMyAdmin\libraries\PHPExcel\PHPExcel\Shared\OLERead.php on line 72
网上说修改reader.php文件 我试过了,也没用!请问咋整啊?
——解决方案——————–
简体中文 windows 系统的字符集是 gbk 的
而你的程序使用的是 utf-8 字符集,那么中文文件名(utf-8编码的)如何能找得到呢?