php 读取excel表格中的内容
<?php /** * excel表格内容在网页中显示 * * 首先需要下载PHPExcel 工具包 * 网址: http://phpexcel.codeplex.com/releases/view/119187 * * @copyright 2007-2012 Xiaoqiang. * @author Xiaoqiang.Wu <jamblues@gmail.com> * @version 1.01 */ header("Content-type: text/html; charset=utf-8"); error_reporting(E_ALL); set_time_limit(0);//设置不超时 @ini_set('memory_limit', '512M');//设置PHP能使用的内存大小 date_default_timezone_set('Asia/ShangHai'); /** PHPExcel_IOFactory */ require_once './PHPExcel/IOFactory.php'; $filename = 'test2.xls'; // Check prerequisites if (!file_exists($filename)) { exit("not found 31excel5.xls.\n"); } $reader = PHPExcel_IOFactory::createReader('Excel5'); //设置以Excel5格式(Excel97-2003工作簿) $PHPExcel = $reader->load($filename); // 载入excel文件 $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表 $highestRow = $sheet->getHighestRow(); // 取得总行数 $highestColumm = $sheet->getHighestColumn(); // 取得总列数 $str = ''; $str .= '<table border="1" cellspacing="0" bordercolor="#eeeeee" cellpadding="5" width="100%">'; //按照excel表格格式输出A-Z列 $str .= '<tr>'; $str .= '<td></td>'; for($column = 'A'; $column <= $highestColumm; $column++) { $str .= '<td>' .$column. '</td>'; } $str .= '</tr>'; //按照excel表格的格式从1开始累计 for ($row = 1; $row <= $highestRow; $row++){//行数是以第1行开始 $str .= '<tr>'; $str .= '<td>' .$row. '</td>'; //输出excel表格的内容 for($column = 'A'; $column <= $highestColumm; $column++){ $str .= '<td>' .$sheet->getCell($column.$row)->getValue(). '</td>'; } $str .= '</tr>'; } $str .= '<table>'; echo $str; ?>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤