Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/47459-export-mysql-to-certain-excel-cells/
Share on other sites

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.

(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

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.