Jump to content

Recommended Posts

Posted

My Requirement is to export my database table data into an excel format.

What is the easiest way to convert selected table data into excel format using PHP ?

Is there a php function or a library or something like that?

Posted

The abosulote easiet.. well that would be via phpMyAdmin -> Export -> [Then choose either CVS for excel or excel file]

And that should fix it, as it's easier to use that than coding it from scratch that's for sure.

Posted

What I meant was from the user's point of view.

 

For the project I am working on, one of my requirements is to save selected data in excel format.

The end-user selects the data to be printed or saved.

And I need the code for the same.

 

 

It is not from the admin's point of view.

 

Sorry if I didn't mention it.

  • 2 weeks later...
Posted (edited)

You can do this a number of ways using PHP...

 

Look at fwrite

 

[example]...

$f = fopen('/tmp/data.csv', 'a'); //<< in 'a' append mode
fwrite($f, 'line of data 1'); //<< you will have to loop through this line
fclose($f); // close handle

 

Or using a MYSQL query...

 

[example]...

SELECT field1,field2,field3
FROM table
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

Edited by is_numeric
Posted

There is a set of PHP classes called PHPExcel for my purpose.

 

But I have difficulty using the same.I think I have some errors in including some extensions.

 

If anybody has used PHPExcel please respond.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...