我的代码是
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格式 就可以了