PHP头条
热点:

phpexcel的getSheet(i)只能读取一页,如何获取一个excel有多少分页


phpexcel的getSheet(i)只能读取一页,怎么获取一个excel有多少分页?
phpexcel的getSheet只能读取一页,怎么获取一个excel有多少分页?

------解决方案--------------------
count?
------解决方案--------------------
//获取工作表的数目
$sheetCount = $PHPExcel->getSheetCount();
PHP code

canRead($filePath))
{                        
    $PHPReader = new PHPExcel_Reader_Excel5();    
    if(!$PHPReader->canRead($filePath))
    {                        
        echo '未发现Excel文件!';
        return;
    }
}
 
//不需要读取整个Excel文件而获取所有工作表数组的函数,感觉这个函数很有用,找了半天才找到
$sheetNames  = $PHPReader->listWorksheetNames($filePath);
 
//读取Excel文件
$PHPExcel = $PHPReader->load($filePath);
 
//获取工作表的数目
$sheetCount = $PHPExcel->getSheetCount();
 
//选择第一个工作表
$currentSheet = $PHPExcel->getSheet(0);
 
//取得一共有多少列
$allColumn = $currentSheet->getHighestColumn();   
 
//取得一共有多少行
$allRow = $currentSheet->getHighestRow();  
 
//循环读取数据,默认编码是utf8,这里转换成gbk输出
for($currentRow = 1;$currentRow<=$allRow;$currentRow++)
{
    for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++)
    {
        $address = $currentColumn.$currentRow;
        echo iconv( 'utf-8','gbk', $currentSheet->getCell($address)->getValue() )."\t";
    }
    echo "
"; } ?>

www.phpzy.comtrue/phprm/49663.htmlTechArticlephpexcel的getSheet(i)只能读取一页,如何获取一个excel有多少分页 phpexcel的getSheet(i)只能读取一页,怎么获取一个excel有多少分页? phpexcel的getSheet只能读取一页,怎么获取一个excel有多少分...

相关文章

PHP之友评论

今天推荐