How to connect Excel with PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smchauhan
    New Member
    • Jul 2007
    • 1

    How to connect Excel with PHP

    I am working as a web developer, I want to know how to connect any excel sheet with php to show records from the spredsheet.
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Moving Thread from PHP Articles – Ajaxrand

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Hi there,

      Welcome to TSDN.

      for now you can refer to these links.
      Class: MS-Excel Stream Handler
      Class: Excel Reader

      If you are not in a rush I might be able to find out more solutions for you.

      Thanks!
      -Ajaxrand

      Comment

      • Rhishabh07
        New Member
        • Jul 2007
        • 21

        #4
        my code

        [code=php]
        <?
        //include("../mysqlconnect.ph p");
        $link = mysql_connect(" localhost","roo t","")
        or die("Could not connect: " . mysql_error());
        mysql_select_db ("suma");

        include("includ e/upload.inc.php" );
        if(isset($_POST['upload']))
        {
        $deli=$_POST['delimeter'];

        $userfile=$_FIL ES['userfile']['name'];
        $userfile_tmp=$ _FILES['userfile']['tmp_name'];
        $userfile_type= $_FILES['userfile']['type'];
        $userfile_size= $_FILES['userfile']['size'];
        $dir="upload";
        $filename=basen ame($userfile);
        move_uploaded_f ile("$userfile_ tmp","$dir/$filename");
        $row= 1;
        $fp = fopen("$dir/$userfile", "r");
        $s="";
        $s1="";
        $s2="";

        while (($data = fgetcsv($fp, 100000, "$deli")) !== FALSE)
        {
        $num = count($data);
        $row++;
        if($row==2)
        {
        for ($c=0; $c < $num; $c++)
        {
        $s.=$data[$c]." VARCHAR (200) not null,";
        $s2.=$data[$c].",";
        $s1.="'$data[$c]',";
        }
        echo $sql="create table temp1(id int(20) not null auto_increment, ".$s."extra varchar(200) not null, primary key(id))";
        mysql_query($sq l)or die("could not create");

        $sql1="insert into temp1 (".$s2."extr a) values (".$s1."'choose ')";
        mysql_query($sq l1)or die("could not insert");
        }

        if($row > 2)
        {
        $s1="";
        for ($c=0; $c < $num; $c++)
        {
        $s1.="'$data[$c]',";
        }
        $sql2="insert into temp1 (".$s2."extr a) values (".$s1."'choose ')";
        mysql_query($sq l2)or die("could not insert");
        }
        }

        fclose($fp);
        }

        ?>

        <table>

        <form action="" method="post" enctype="multip art/form-data" name="form3" id="manu">

        <tr class="greyBG">
        <td width="60%" height="33"> <div align="left">Pl ease Enter the delimeter
        </div></td>
        <td width="40%"><in put type="text" name="delimeter "> </td>
        </tr>
        <tr><td>Uploa d CSV file</td><td><input name="userfile" type="file"></td>




        </tr>
        <tr><td colspan="2"> <input type="submit" name="upload" value="upload"> </td></tr>
        </form>
        </table>
        [/code]
        Last edited by ak1dnar; Jul 11 '07, 11:27 AM. Reason: Added [CODE] Tags

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          Hi,
          from your Original post you have asked about "showing records from Spreadsheets".

          I am working as a web developer, I want to know how to connect any excel sheet with php to show records from the spredsheet.
          Now What is this php script?

          Comment

          Working...