0

i have been reading around looking for a way to get graphs and so on into my spread sheet i export out of my database and to make it look better for my employee who wants reports of everything in a certain way and so on. I have found PhpExcel.. which seems really good it can do everything i want it to plus more.. but i haven't been able to work out how to use data from my mysql table to fill in the cells since it seems like they all have to be manually set to a value...

i have read over this post How to set cell value Dynamically i have attempted to use the code provided in this page to try and help me out but i havent been able to get it to work for some reason i am always receiving an error.

i am hoping someone may be able to help me out with trying to get this MySQL table data into a spreadsheet using php excel or even if there are any other links i may have missed i would really appreciate it...

Community
  • 1
  • 1
Matthew
  • 195
  • 2
  • 2
  • 18
  • What are the actual problems that you're having with PHPExcel? What does your code look like, and what errors are you getting? – Mark Baker May 24 '12 at 06:22
  • Have a look at the response to this question - http://stackoverflow.com/questions/4748067/problem-with-phpexcel - which populates Excel from a database – Mark Baker May 24 '12 at 06:25

3 Answers3

0

If you install phpmyadmin to connect to your database.

Then you can write SQL queries for whatever reports you need.

And Export (see image 1) the results to CSV or CSV for MS Excel (see image 2).

Export option below the query results enter image description here

Choose export data format enter image description here

Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84
  • i know that i can do complete bulk exports like that as well but that isnt what i am looking to do.. at the moment i am running a php script which does exactly that but.. i cannot use it to generate graphs and other things which my boss wants.. he doesnt want to have to wait for me to give him a report he just wants to hit a button and its done... thanks anyways – Matthew May 24 '12 at 06:13
0

I have done this using the PEAR classes for PHP. You can read the data from the MYSQL database and then write the script using the PHP and PEAR classes to create an excel file for the same.

Here is link to the SpreadSheet Writer

This tutorial will help you to install PEAR and write the data to the excel sheet.

Hope this will solve the problem you are facing.

Akhilesh Sharma
  • 1,580
  • 1
  • 17
  • 29
  • The PEAR writer must have been updated to support charts since I last looked, and I thought it was no longer being actively supported. I'll have to take a look – Mark Baker May 24 '12 at 06:48
  • Mark it might be a possibility because I last used this quite a time ago. – Akhilesh Sharma May 24 '12 at 06:50
  • With the Pear Spreadsheet writer i have found it is easy to read and understnad and shouldnt be to hard to implement into my current system.. is it possible to use it to create graphs off the data that is entered into the spreadsheets without having to manually create each table after the spreadsheet is created? – Matthew May 24 '12 at 22:54
  • Do you want to create graphs in the Excel itself ? – Akhilesh Sharma May 25 '12 at 04:50
0

I'm doing a lot of work with PHPExcel... I wrote a little class to simplify exporting, you can download it here.

You just need to get your data from database into array, pass it to this class and specify the output format. I hope it helps.

verni
  • 41
  • 1