salemme Posted April 17, 2007 Share Posted April 17, 2007 Hello. I have .xls files that I want to be able to export MySQL data into. Is there a straightforward way to do this...I'll really only be inputing 2-3 values. So pretend I have: $test1 $test2 $test3 And I want to export them into test.xls in cells A1, A2, A3. Can someone provide the method for doing this? Thanks tons in advance! Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/ Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 use phpMyAdmin to export to Excel Or create a CSV file then open with Excel! CSV = comma delimted file Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231592 Share on other sites More sharing options...
salemme Posted April 17, 2007 Author Share Posted April 17, 2007 Will phpMyadmin allow me to specify certain cell fields? Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231599 Share on other sites More sharing options...
Psycho Posted April 17, 2007 Share Posted April 17, 2007 I think you need to provide more information on how this feature will be implemented. Is it something that you need to do on a repeated basis, is it client facing, etc. Also, does the file have to be an xls file or can it be csv? Csv files can be opened with Excel as well. There are a few different avenues. Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231605 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 Erm.. yes and kinda more detail will help Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231608 Share on other sites More sharing options...
KrisNz Posted April 17, 2007 Share Posted April 17, 2007 (to expand on whats already been pointed out)Do it as a csv (comma separated values) . A very basic php5 example would be $my_csv_data = "$value1,$value2,$value3"; file_put_contents("example.csv",$my_csv_data); You should find when you open that file in excel, the values in $value1 etc are in a1,a2,a3 respectively. You can then save that file as an xls if you want. Actually working with an excel object isn't a really realistic option in a web server environment, and in your case not necessary. you could also check out http://www.php.net/manual/en/function.fputcsv.php http://www.php.net/manual/en/function.fgetcsv.php Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231613 Share on other sites More sharing options...
salemme Posted April 17, 2007 Author Share Posted April 17, 2007 Ok heres what I need...sorry for the lack of info. This if for a Golf League I run where I have 3 scorecard .xls files I made. These are basically just template files for each course we play in the league. So as of now, once a week I manually enter 2 player names, and 2 handicap values into the scorecard for that weeks course. I'd like to automate this so that someone can click on a link, and that link will activate the sql query/ excel export function. So everytime its going to be the same cell on the .xls that is written to. .cvs is fine if you think that will work. The source file can be changed to whatever. Thanks guys! I really appreciate this. Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231621 Share on other sites More sharing options...
salemme Posted April 17, 2007 Author Share Posted April 17, 2007 A1,A2,A3 were just made up values. The actual cells will be different. Quote Link to comment https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/#findComment-231622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.