Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifiyng & Saving Excel File (from a form)

Status
Not open for further replies.

Palmke

Programmer
May 12, 2004
16
IT
hi all,

I have a php form and I want to save these data automatically in an excel file;

I found information on the net about how to :
read info from and excel file,
create an excel file
but I need to :

1) copy data from the php-form-fields in some fields in a pre-existing excel file,

2) save this excel file with a new name,

3) get the new values from the saved excel file (which will have calculated once I made point and 2)

I can't manage how to!

any help is highly appreciated ;)

Kind regards,
Palmke
 
I recently had a project where I needed to create Excel spredsheets for an accounting department, and I found the PEAR package Spreadsheet_Excel_Writer, to be an excellent tool, and the learning curve isn't bad. You may also want to checkout this slide-show which reads like a tutrial: Making Spreadsheets with Spreadsheet_Excel_Writer

HTH,
Itshim
 
hi all,

my excel source file is full of formulas and I can't find a way to keep them in the new file I create (even just to merely copy it!).

Please help! ;)

Palmke
 
In my project I did not have an existing file that I opened and edited, new files were generated on every call. The user downloaded the files and then the files were deleted off the server. In my case I wrote a class to build a template excel file, and then plug in the necessary data. So I cannot give you an exact answer, but...

If you are using the Spreadsheet_Excel_Writer class then to place a formula in a cell you can use the method:
writeFormula()
such as:
Code:
<?php
require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Excel_Writer('formula.xls');
$worksheet =& $workbook->addWorksheet();

$worksheet->write(0, 0, 2);
$worksheet->write(0, 1, "and");
$worksheet->write(0, 2, 2);
$worksheet->write(0, 3, "makes");
$worksheet->writeFormula(0, 4, "=SUM(A1,C1)");

$workbook->close();
?>
The line:
Code:
$worksheet->writeFormula(0, 4, "=SUM(A1,C1)");
Adds the formula "=SUM(A1,C1)" to row 0 column 4.

Sorry I cannot be of more help.

Itshim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top