473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Jul 10 '07 #1
4 7480
ak1dnar
1,584 Expert 1GB
Moving Thread from PHP Articles – Ajaxrand
Jul 10 '07 #2
ak1dnar
1,584 Expert 1GB
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
Jul 10 '07 #3
my code

Expand|Select|Wrap|Line Numbers
  1. <?
  2. //include("../mysqlconnect.php");
  3. $link = mysql_connect("localhost","root","")
  4. or die("Could not connect: " . mysql_error());
  5. mysql_select_db("suma");
  6.  
  7. include("include/upload.inc.php");
  8. if(isset($_POST['upload']))
  9. {
  10. $deli=$_POST['delimeter'];
  11.  
  12. $userfile=$_FILES['userfile']['name'];
  13. $userfile_tmp=$_FILES['userfile']['tmp_name'];
  14. $userfile_type=$_FILES['userfile']['type'];
  15. $userfile_size=$_FILES['userfile']['size'];
  16. $dir="upload";
  17. $filename=basename($userfile);
  18. move_uploaded_file("$userfile_tmp","$dir/$filename");
  19. $row= 1;
  20. $fp = fopen("$dir/$userfile", "r");
  21. $s="";
  22. $s1="";
  23. $s2="";
  24.  
  25. while (($data = fgetcsv($fp, 100000, "$deli")) !== FALSE) 
  26. {
  27. $num = count($data);
  28. $row++;
  29. if($row==2)
  30. {
  31. for ($c=0; $c < $num; $c++) 
  32. {
  33. $s.=$data[$c]." VARCHAR (200) not null,";
  34. $s2.=$data[$c].",";
  35. $s1.="'$data[$c]',";
  36. }
  37. echo $sql="create table temp1(id int(20) not null auto_increment,".$s."extra varchar(200) not null, primary key(id))";
  38. mysql_query($sql)or die("could not create");
  39.  
  40. $sql1="insert into temp1 (".$s2."extra) values (".$s1."'choose')";
  41. mysql_query($sql1)or die("could not insert");
  42. }
  43.  
  44. if($row > 2)
  45. {
  46. $s1="";
  47. for ($c=0; $c < $num; $c++) 
  48. {
  49. $s1.="'$data[$c]',";
  50. }
  51. $sql2="insert into temp1 (".$s2."extra) values (".$s1."'choose')";
  52. mysql_query($sql2)or die("could not insert");
  53. }
  54.  
  55. fclose($fp);
  56. }
  57.  
  58. ?>
  59.  
  60. <table>
  61.  
  62. <form action="" method="post" enctype="multipart/form-data" name="form3" id="manu">
  63.  
  64. <tr class="greyBG"> 
  65. <td width="60%" height="33"> <div align="left">Please Enter the delimeter 
  66. </div></td>
  67. <td width="40%"><input type="text" name="delimeter"> </td>
  68. </tr>
  69. <tr><td>Upload CSV file</td><td><input name="userfile" type="file"></td>
  70.  
  71.  
  72.  
  73.  
  74. </tr>
  75. <tr><td colspan="2"> <input type="submit" name="upload" value="upload"></td></tr>
  76. </form>
  77. </table>
  78.  
Jul 11 '07 #4
ak1dnar
1,584 Expert 1GB
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?
Jul 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " ....
2
by: John J. Lee | last post by:
Dear, I have problems when I get the IDispatch with pythoncom.connect(). When I called the 'Excel.Application' with it, it worked. (At least I can see the pythoncom.connect() is working for the...
1
by: cybertof | last post by:
Hello, Is there a way to connect (through automation) a c# application to a running Excel 2003 instance on a specific workbook ? In the past, i used to use GetObject(...) function in VB6. ...
3
by: hkappleorange | last post by:
I connect to mdb file using the following codes. How should I modify it if I want to connect to Excel instead ? <%@ Import Namespace="System.Data.OleDb" %> <% Dim conAuthors As...
2
by: | last post by:
Greets, How does one connect to a local excel file using data wizard is it possible? I'm trying to connect to an excel file and populate a dataset and combo box with the data from excel TIA
8
by: danbredy | last post by:
Hi, I'm attempting to connect to an Oracle database using SQL Server 2005 Express (OS is Windows XP Professional) and having absolutely no luck. Here is the information SQL Plus gives me about...
2
by: Brian Parker | last post by:
I need to format text in cell in an Excel worksheet and I need to do this using C#. I've seen code that will set the format for the whole cell, but I just need to format one character in that...
1
by: kannabiran | last post by:
Hi everyone, Im using the C# asp.net as the front end and i need to use the Excel sheet as the back end.i want to select the records which is available in the excel sheet using query and...
0
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am learning how to use Excel to connect to other external data source (like database). What I want to do is to develop a plug-in for Excel and automatically access external...
1
by: greggui9029 | last post by:
Hi, I have some querytables using OLE DB provider in Excel workbook. Is there any way to connect to the external data programmly without refreshing querytables? i.e. I don't want to refresh Excel...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.