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. 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 Link to comment https://forums.phpfreaks.com/topic/64042-advanced-email-excel-spreadsheet-writer/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.