Anil Labs

Friday, March 5, 2010

How to create excel file with mysql data using php code

23 comments:

  1. [...] How to create excel file with mysql data using php code « ANIL … Posted in Uncategorized | Tags: connect, data, excel-file, follow-the-below, [...]

    ReplyDelete
  2. You could always explain how to create a real Excel file rather than a simple tab-separated file. Yes, Excel can read tab- or comma-separated value files, as can many applications... giving that file an extension of .xls does not make it an Excel file.

    And if you do create a tab-separated file, don't make it such complex code, with all kinds of unnecessary overhead: use PHP's fputcsv() function which does the hard work for you. This has the advantage of escaping quotes and other special characters in your data, which your code doesn't.

    If you want to create a real Excel file, which has the benefits of cell formatting, frozen heading rows, filter headings, and all the other features of Excel itself, then it can be done (using less code than your example) with one of the myriad of free PHP libraries such as PHPExcel.

    ReplyDelete
  3. it is good .but not working online .please suggest something

    ReplyDelete
  4. It could be not the ideal solutions but it works very good and it's simple to understand.. I have been more than 2 hours reading other codes and they all included to download api and were more complicated when you use a shared hosting... so, this is short code, easy to understand and use, just copy and paste and it works... anyway when you download the file, Microsft Excel ask you to convert it to a good xls format, you say yes and your file is converted to a legitime excel without any problem.... I think this code is very practical.

    thanks to Anil..
    leo.

    ReplyDelete
  5. Hey all this code sure is great for a simple excel file creation and has worked for me , having said that is there any way we can format the output??? more precisely can i oput in bold text ... please help if if u can ... thank you!!

    ReplyDelete
  6. It is hot cake .helped me very well .Thank you anil

    ReplyDelete
  7. plz tell me how to apply bold to text in excelsheet generated by above code.
    Thank you in Advance

    ReplyDelete
  8. i want code for opening existing excel file....code for updating excel file...

    ReplyDelete
  9. how to do database field name, Excel File title name bold

    ReplyDelete
  10. All this did for me is display in the web page the column names in the database. No excel file and no content from the database other than the headings?

    What am I missing here?

    ReplyDelete
  11. [...] 2)How to create excel file with mysql data using php code [...]

    ReplyDelete
  12. Thank You . i found the first field not appear to modfiy that you must make first $i value in loop is 0 instead of one so it should be like that for ($i = 0; $i < mysql_num_fields($result); $i++)

    ReplyDelete
  13. how to store data in a xml file through php ?

    ReplyDelete
  14. hi...
    i want know the ...........
    how to create .xls file or software ....
    but step by step means which software or etc and another thing also 1 by 1 ok
    plz any1 spcly anil plz help yar plz...........

    ReplyDelete
  15. i want to put headers/title in my generated excel report. how can i customize the title/header like centering the title with bold text and underline? thanks in advance.

    ReplyDelete
  16. It is a nice tutorial. I just want to make the excel file stored in a different location other than the project folder . Can you please suggest the code for that also?
    Thanks in advance

    ReplyDelete
  17. Dude this is great
    But im getting duplicate values and also im using odbc connection instead of mysql_connect
    everything is working fine except for the duplicate values can u tell me how can i omit duplicate values thankx..

    ReplyDelete
  18. Can u tell me now how to bold the values
    Will be much help
    Thankx

    ReplyDelete
  19. Thanks for help, really nice post it's useful for me...

    ReplyDelete
  20. hay this generates the excel sheet but not showing me any of data..just shows the column name..
    i have just copy paste your code...should i have to do modification inside it???

    ReplyDelete
  21. i think it's not going inside the while loop

    ReplyDelete