Jump to content


Photo

Excel w/ PHP


  • Please log in to reply
7 replies to this topic

#1 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 25 May 2006 - 01:33 PM

I've looked through the manual and on other places on the web including searching these forums. The only thing I've found about Excel is how to open a file and push it to the user via a header call.

Is there a way to create a new document... and to just save that document to a folder so I can provide a link to it where they can do a "right-click->save as..." type of deal?

Any help would be appreciated.

Info: PHP Manual


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 25 May 2006 - 01:55 PM

Not sure if this is helpful enough, but I have a working application where data are abstracted from a MySQL database and a CSV file is written (with column headings) that can be downloaded and imports into Excel.

No fancy formatting, no formulae, no macros - just the plain data.
Legend has it that reading the manual never killed anyone.
My site

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 25 May 2006 - 02:01 PM

are you looking for something like this?

[a href=\"http://www.sitepoint.com/article/pear-spreadsheet_excel_writer\" target=\"_blank\"]http://www.sitepoint.com/article/pear-spre...et_excel_writer[/a]

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 25 May 2006 - 02:02 PM

I have a script which will extract data from mySQL database, and then by simply using a basic table layout, and then saving the HTML output into a file with a .xls extension, the resulting database data is stored as a microsoft excel document.

wisewood: proven fact, I am both wise, and wooden.

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 25 May 2006 - 02:19 PM

here's another linkie:

[a href=\"http://www.tutorialized.com/tutorial/Create-excel-files-with-php/11042\" target=\"_blank\"]http://www.tutorialized.com/tutorial/Creat...-with-php/11042[/a]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 25 May 2006 - 02:31 PM

Alright... thanks for the replies all. Just to answer a few of the questions:

1) I'm not looking for a CSV format. I already create that for one of my apps and that works fine.

2) I'm also not looking for an export from an HTML table to Excel.

I'm looking to create a new document, play with it, format it, do whatever I'd do manually with Excel, and do it all with PHP and possibly Pear.

Thanks for the links CV... I'll check those out ;)

Info: PHP Manual


#7 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 25 May 2006 - 06:28 PM

I did something like this long time ago, but I am not sure how flexiable it can be. Excel support .slk files. These files are text so you can write them in php no problem. Usually there is a head with the document format, then the rows with their data (like C;X4;K"test" or C;Y7;K6;ESUM(R[-3]C:R[-1]C) )

The easiest way to make it is to create the form in excel and save it as .slk once you get this, you can play with it to create you file.

NoGray.com


#8 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 25 May 2006 - 11:45 PM

hmmmm...

Is this any help?

[a href=\"http://www.sitepoint.com/article/pear-spreadsheet_excel_writer\" target=\"_blank\"]http://www.sitepoint.com/article/pear-spre...et_excel_writer[/a]

Lite...
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
For example, if we wanted to save the same spreadsheet we created in our first example to a file named 'test.xls', we would do it like so:

Example 2:

addWorksheet('test worksheet');

$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 10);

// We still need to explicitly close the workbook
$workbook->close();
?>[/quote]

from [a href=\"http://blinduser.blogspot.com/2006/03/excel-and-php-without-com.html\" target=\"_blank\"]http://blinduser.blogspot.com/2006/03/exce...ithout-com.html[/a]


all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users