Heim  >  Artikel  >  Backend-Entwicklung  >  请问用phpExcelReader方式,excel文件名字可以是中文吗?

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

WBOY
WBOYOriginal
2016-06-23 13:51:181260Durchsuche

我的代码是

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编码的)如何能找得到呢?

简体中文 windows 系统的字符集是 gbk 的
而你的程序使用的是 utf-8 字符集,那么中文文件名(utf-8编码的)如何能找得到呢?



嗯 谢谢版主 我把php文件保存成ansi格式 就可以了
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn