Help Needed to Send Online Form Results to Excel File.

Topics: Developer Forum, Project Management Forum, User Forum
Dec 9, 2009 at 4:06 AM

I have an excel file that i built (.xls). I also have an online HTML form that I built. My problem is I would like to send the form results to particular cells within the prebuilt excel file saved on my server somewhere. Then mail this form as an attachment to the user. How do i do this?

Here is an example of how i would like this to work...

HTML Form Fields --> EXCEL File
First Name --> Cell A2
Last Name --> Cell B2
Email --> Cell A3
Phone --> Cell C1

Also the individual cells (A2, B2, A3, C1) in the EXCEL Attachment needs to be "locked" when it is sent so that the user cannot modify the data.

Here is some information about my current server...

Operating System: Windows
.Net Runtime Version: ASP.Net 2.0/3.0/3.5
PHP Version: PHP 5.x
IIS Version: IIS 7.0
SQL Server Databases: 1 Available
MySQL Databases: 1 Setup of 10 Available

Jan 20, 2010 at 12:45 PM

So you want to email the final Excel file to the user?

Jan 20, 2010 at 5:55 PM

Yes i would like to email the final excel sheet to the user.

Jan 21, 2010 at 5:08 AM

Create in e.g. Microsoft Office Excel or Calc the final Excel file as you want it to look. Leave cells A2, B2 etc. blank where "First Name", "Last Name" should go.

Collect the data from the user submitted via the HTML form in some variables, $firstName, $lastName, etc.

Fill in the collected data like this:

require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';

$excel = PHPExcel_IOFactory::load('template.xls');

$worksheet = $excel->getActiveSheet();

$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5');

You should be able to send the generated Excel file as attachment in an email using some other classes.