473,769 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php code "export table to excel"

22 New Member
Hello Guys,....!
Can you help me how to export my table to excell using php code ..?
thanks alot
Feb 13 '07 #1
2 11926
aniltc
17 New Member
You should use pear spread sheet
download pear spread sheet and use the below code
[PHP]
<?php
/*
$Id: report_all.php, v 1.1 2004/08/30 16:03:40 chris Exp $
generate a spreadsheed from and addressbook in mysql database.
*/

include "dblib.php" ;
DBConnect();

require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Exc el_Writer();
$format_bold =& $workbook->addFormat();
$format_bold->setBold();

$worksheet =& $workbook->addWorksheet() ;
$worksheet->write(0, 0, "name", $format_bold);
$worksheet->write(0, 1, "address", $format_bold);
$worksheet->write(0, 2, "phone", $format_bold);
$worksheet->write(0, 3, "email", $format_bold);
$worksheet->write(0, 4, "comments", $format_bold);

# start by opening a query string
$fullquery="sel ect * from smslog";

$result=mysql_d b_query($db_nam e,$fullquery);

$i=1;
while($row=mysq l_fetch_assoc($ result)){
$worksheet->write($i, 0, "$row[name]");
$worksheet->write($i, 1, "$row[address]");
$worksheet->write($i, 2, "$row[phone]");
$worksheet->write($i, 3, "$row[email]");
$worksheet->write($i, 4, "$row[comments]");
$i++;
}
$workbook->send('test.xls ');
$workbook->close();
?>[/PHP]
I hope this will solve your problem
Feb 13 '07 #2
amrhi
22 New Member
thanks alot you're amazing.
regards
Feb 13 '07 #3

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

Similar topics

13
29518
by: DarkSpy | last post by:
many c++ compilers including "gcc" have not implemented the "export" keyword, but the comeau compilers made it (just i knew). i want to know about: is it too difficult to implement "export" keyword? if it is, i know the history that is without "export" keyword of C++ compilers with five years (sorry about my poor english :-) ), in five years still have no some idea to implement it ? my project and many C++ programmers need this important...
205
10700
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
3
11932
by: John | last post by:
Is there a way to code the button that's available in the query window--microsoft excel icon that exports to excel. I know transferspreadsheet will do this---but I want the query, which is in a pivot table view, to be exported as a pivot, not just a data list. Does this code exist? Is it transferspreadsheet but with a twist?
2
15506
by: CVerma | last post by:
I'm using an html input control (System.web.UI.HTMLControls.HTMLInputFile) to upload files such as msword, excel, jpg, and pdf. I have the encType property set in the form: encType="multipart/form-data" <INPUT id="UploadFile" type="file" name="UploadFile" runat="server"> Private Sub btnUploadFile_Click(ByVal sender As System.Object, ByVal e
5
1840
by: kiask2343 | last post by:
Ok before I get started let it be known I am the definition of a newbie when it comes to access and VBA. I know very little about access and nothing about VBA. I am in the Army and am tasked with making a maintenance program for medical equipment. I have the database, the query, the forms, and the reports. I was able to figure those out, but there is one thing that is beyond me. Ok I have three tables call them table "A" table "B" and...
2
2077
by: Radu | last post by:
Hi. I have an Access application which does lots of things by going through some PINS in some large tables. This application is installed on multiple computers, and works fine, with one exception: For reporting purposes, I need to keep a "central" table where each application would save some data. Currently I'm using a LINKED excel file named "SharedAccumulator" and after each PIN successfully processed a record is added in the...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.