本文目录一览:
- 1、php读取excel,excel下多个个工作表,该怎么读取
- 2、怎么用PHPexcel读取excel数据
- 3、PHPexcel 读取excel中的值是空的
- 4、PHPExcel读取Excel并用Excel中的公式获取需要的计算结果,效率如何,可行不可行?
- 5、如何用PHPExcel读取超大excel文件
- 6、关于phpexcel读取excel表的问题,如下
php读取excel,excel下多个个工作表,该怎么读取
php读取excel,excel下多个个工作表的方法:
1、利用PHPExcelReader来完成多个excel的读取。
2、PHPExcel比较强大,能够将内存中的数据输出成Excel文件,同时还能够对Excel做各种操作,下面主要介绍下如何使用PHPExcel进行Excel 2007格式(.xlsx)文件的读取。
3、下载PHPExcel后保存到自己的类文件目录中,然后使用以下代码可以打开Excel 2007(xlsx)格式的文件:
require_once '/libs/PHPExcel-1.8.0/Classes/PHPExcel.php'; //修改为自己的目录
echo 'pTEST PHPExcel 1.8.0: read xlsx file/p';
$objReader = PHPExcel_IOFactory::createReaderForFile($filename);
$objPHPExcel = $objReader-load($filename);
$objPHPExcel-setActiveSheetIndex(1);
$date = $objPHPExcel-getActiveSheet()-getCell('A16')-getValue();
输出$date变量就能够看到文件中的内容了。
怎么用PHPexcel读取excel数据
?php
header("Content-Type: text/html; charset=utf-8");
require_once 'db.class.php';
require_once 'Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$filePath = "email.xlsx";
$arr = array();
$temparr = array();
$PHPExcel = new PHPExcel();
$PHPReader = new PHPExcel_Reader_Excel2007();
$PHPExcel = $PHPReader-load($filePath);
$currentSheet = $PHPExcel-getSheet(0);
/*取得一共有多少列*/
$allColumn = $currentSheet-getHighestColumn();
/*取得一共有多少行*/
$allRow = $currentSheet-getHighestRow();
echo $allColumn;
echo 'hr';
echo $allRow;
echo 'hr';
for($currentRow = 2;$currentRow=$allRow;$currentRow++){
$temparr['usernum'] = $currentSheet-getCell('A'.$currentRow)-getValue();
$temparr['price'] = $currentSheet-getCell('B'.$currentRow)-getValue();
$temparr['rongliang'] = $currentSheet-getCell('C'.$currentRow)-getValue();
$temparr['fujian'] = $currentSheet-getCell('D'.$currentRow)-getValue();
$temparr['gerenwangpan'] = $currentSheet-getCell('E'.$currentRow)-getValue();
$temparr['chaodafujian'] = $currentSheet-getCell('F'.$currentRow)-getValue();
$temparr['suishenyou'] = $currentSheet-getCell('G'.$currentRow)-getValue();
$temparr['chuanzhen'] = $currentSheet-getCell('H'.$currentRow)-getValue();
$temparr['qiyewangpan'] = $currentSheet-getCell('I'.$currentRow)-getValue();
//$arr[$currentRow-1] = $temparr;
$sql = "INSERT INTO `netease_price` (`usernum`, `price`, `rongliang`, `fujian`, `gerenwangpan`, `chaodafujian`,`suishenyou`, `chuanzhen`, `qiyewangpan`) VALUES (
'".$temparr['usernum']."',
'".$temparr['price']."',
'".$temparr['rongliang']."',
'".$temparr['fujian']."',
'".$temparr['gerenwangpan']."',
'".$temparr['chaodafujian']."',
'".$temparr['suishenyou']."',
'".$temparr['chuanzhen']."',
'".$temparr['qiyewangpan']."'
)";
mysql_query($sql);
/*
自动读取
for($currentColumn='A';$currentColumn=$allColumn;$currentColumn++){
$address = $currentColumn.$currentRow;
echo $currentSheet-getCell($address)-getValue()."/t";
}
echo "br /";
*/
}
PHPexcel 读取excel中的值是空的
你的代码: $strs[0] =$objWorksheet-getCellByColumnAndRow($col,$row)-getValue();
数据需要强制类型转换,改成: $strs[0] =(string)$objWorksheet-getCellByColumnAndRow($col,$row)-getValue();
PHPExcel读取Excel并用Excel中的公式获取需要的计算结果,效率如何,可行不可行?
你好,我现在也是想通过PHPExcel重新给表格内赋值,然后公式计算后再重新取值供使用,想问一下你做成功了吗?赋值后是否会计算出新的结果
如何用PHPExcel读取超大excel文件
excel文件不能读取且无法修复的解决办法如下
1.将此文件复制一份并重命名为.zip的文件。
然后打开此文件,再打开xl的文件夹。
会看到有一个文件名为sharedStrings.xml的文件。
将此文件sharedStrings.xml,拖到桌面上。
2.双击打开此文件,拉动滚动条到最下方,有下图提示,说明表中的si/si有异常,一般是少了si(本人的个人经验)偶尔是缺少t。
3.使用EmEditor打开sharedStrings.xml。
4.会看到如下图,红色标注说明si/si是成对出现的,少一个就会出错,他们是一个整体。
5.搜索si,有多少个,有161个。
6.搜索/si,有多少个,有162个。
7.si,少一个,在下图位置(这是从下由上找出来的),不要忘记si/si是成对出现的,选中一个,这一个整体显示灰色。
8.将缺失的si添加进去。
9.将更改过的sharedStrings.xml,替换原来的sharedStrings.xml。
10.将下图此文件重命名成为原来.xlsx格式。
关于phpexcel读取excel表的问题,如下
?
$sheet_i = 2;//行
$sheet_j = 1;//列
for($currentRow = 2;$currentRow = $allRow;$currentRow++){
/**从第A列开始输出*/
for($currentColumn= 'A';$currentColumn= $allColumn; $currentColumn++){
$val = $currentSheet-getCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)-getValue();/**ord()将字符转为十进制数*/
if($sheet_i = 2$sheet_j = 1)//自己算好输出第几行第几列
{
if($currentColumn == 'A')
{
echo GetData($val)."/t";
}else{
//echo $val;
/**如果输出汉字有乱码,则需将输出内容用iconv函数进行编码转换,如下将gb2312编码转为utf-8编码输出*/
echo iconv('utf-8','gb2312', $val)."/t";
}
}
$sheet_j ++;
}
$sheet_i++;
$sheet_j = 0;//重置列数
echo "/br";
}
echo "/n";
?