Jump to content

Embed excel file into PHP page


never_rain

Recommended Posts

  • 1 year later...

try this, but u should use .csv format instead of excel format

 

<?php 
      $cnx = fopen("example.csv", "r"); //open example.csv 
      echo("<table style='border:1px solid #ddd;'>"); // echo the table 
      while (!feof ($cnx)) { // while not end of file 
      $buffer = fgets($cnx); // get contents of file (name) as variable 
      $values = explode(",", $buffer); //explode "," between the values within the  contents 
      echo "<tr >"; 
      for ( $j = 0; $j < count($values); $j++ ) {  // 
      echo("<td style='border:1px solid #ddd;'>$values[$j]</td>"); 
      } 
      echo"</tr>"; 
      }; 
      echo("</table>"); 
      fclose($cnx); //close filename variable 
      ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.