当前位置: 代码迷 >> PHP >> 请教用phpExcelReader方式,excel文件名字可以是中文吗
  详细解决方案

请教用phpExcelReader方式,excel文件名字可以是中文吗

热度:37   发布时间:2016-04-28 18:39:23.0
请问用phpExcelReader方式,excel文件名字可以是中文吗?
我的代码是

require_once 'phpExcelReader/Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('UTF-8');
$data->read('物业.xls'); 
$db = mysql_connect('localhost', 'root', '123456');
@mysql_query("set names 'utf8'");    //输出中文 
@mysql_select_db('first');           //选择数据库 
echo $data->sheets[0]['cells'][1][1];
echo $data->sheets[0]['cells'][3][1];


现在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\PHPExcel\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编码的)如何能找得到呢?
  相关解决方案