Home > Backend Development > PHP Tutorial > 请问用phpExcelReader方式,excel文件名字可以是中文吗?

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

WBOY
Release: 2016-06-23 13:51:18
Original
1300 people have browsed it

我的代码是

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];
Copy after login


现在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格式 就可以了
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template