jake2891 Posted August 9, 2007 Share Posted August 9, 2007 Hi guys can anyone please help me? I have to run a script that generates a report into an excel document then emails the document simultaneous to the user with the spreadsheet attached! Although it needs to write a document for each users specific details in the database and mail that user his specific spreadsheet with his details in! Heres a sample of what im trying to do. Sorry forgot to mention in the previous post that the part that i cant get working at all is how to mail the document while the scripts runs all that happens now is it open an asks whether i want to save the document. If im going about this all wrong an there is an easier or better way please advise. require_once 'Spreadsheet/Excel/Writer.php'; $sql = "select distinct agent from leads"; $qry = mysql_query($sql, $conn); $workbook = new Spreadsheet_Excel_Writer(); $workbook->send('liveleads.xls'); $worksheet =& $workbook->addWorksheet(liveleads); $worksheet->write(0, 0, 'agent'); $worksheet->write(0, 1, 'leadID'); // all leads for that agent $worksheet->write(0, 2, 'contactperson'); // all contacts that agent has while($array = mysql_fetch_array($qry)) { $i = 1; $sql2 = "select * from leads where agent = $array[agent]"; $qry2 = mysql_query($sql2, $conn); while($array2 = mysql_fetch_array($qry2)){ $worksheet->write($i, 0, $array[agent]); $worksheet->write($i, 1, $array[leadID]); $worksheet->write($i, 2, $array[contactperson]); $i++; } mail($array,"subject"etc......."); } $workbook->close(); #so basically i need to loop through the agents get the leads that belong to the specific agent #then write an excel document for each agent listing his specific leads #then mail each agent with his specific document attached containing his leads while the script runs #Any help will be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/64053-email-excel-spreadsheet-writer-part-of-previous/ Share on other sites More sharing options...
MadTechie Posted August 9, 2007 Share Posted August 9, 2007 DON'T DOUBLE POST! also whats the "problem" Quote Link to comment https://forums.phpfreaks.com/topic/64053-email-excel-spreadsheet-writer-part-of-previous/#findComment-319267 Share on other sites More sharing options...
jake2891 Posted August 10, 2007 Author Share Posted August 10, 2007 Hi sorry about that did not know. The problem is im not sure on how to email the workbook to the end user while the script runs. basically this script is set to run once a week on a monday write up a spreadsheet of data and mail each user his specific speadsheet? Quote Link to comment https://forums.phpfreaks.com/topic/64053-email-excel-spreadsheet-writer-part-of-previous/#findComment-320132 Share on other sites More sharing options...
jake2891 Posted August 10, 2007 Author Share Posted August 10, 2007 Hi sorry about that did not know. The problem is im not sure on how to email the workbook to the end user while the script runs. basically this script is set to run once a week on a monday write up a spreadsheet of data and mail each user his specific speadsheet? Quote Link to comment https://forums.phpfreaks.com/topic/64053-email-excel-spreadsheet-writer-part-of-previous/#findComment-320134 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.