Home  >  Article  >  Backend Development  >  PHP链接excel sql分页有关问题

PHP链接excel sql分页有关问题

WBOY
WBOYOriginal
2016-06-13 13:44:03710browse

PHP链接excel sql分页问题
以下是PHP链接excel程序,如果我想设置分页怎么搞?select top 11 * from [Sheet1$];这样可以是次选择11条记录,但是我要从11条以后读取怎么搞?求高手帮个忙。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
  <?php $conn=new com("adodb.connection");
      $connstr="Driver={Microsoft Excel Driver (*.xls)};DBQ=".realpath("excel/book.xls");
      $conn->open($connstr);
      $sql="select top 11 * from [Sheet1$]";
      $rs=$conn->execute($sql);
      if($rs->eof || $rs->bof)
       {
         echo "<div align="center">暂无图书信息!</div>";
       }
       else
       {
        while(!$rs->eof)
        
         {
      ?>
      <tr>
        <td height="25" align="center" bgcolor="#FFFFFF">
<?php $fields=$rs->fields(number);echo $fields->value;?></td>
        <td height="25" align="center" bgcolor="#FFFFFF">
<?php $fields=$rs->fields(title);echo $fields->value;?></td>
        <td height="25" align="center" bgcolor="#FFFFFF">
<?php $fields=$rs->fields(datetime);echo $fields->value;?></td>
        <td height="25" align="center" bgcolor="#FFFFFF">
<?php $fields=$rs->fields(sale);echo $fields->value;?></td>
        <td height="25" align="center" bgcolor="#FFFFFF"></td>
      </tr>
      <?php $rs->movenext;
         }
        }
      ?>



------解决方案--------------------
$conn=new com("adodb.connection");

你把它当成数据库来操作,为什么不能使用sql语句来操作。

其实你可以用PHPExcel类来进行excel操作效果比较好
Statement:
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