Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I send a file as an email attachment?
    text
    copied!<p>Spreadsheet WriteExce of John McNamara working ok to downloading the excel file.</p> <p>currently use this function to export data from mysql and generate the excel. working properly to perform action download, but I would like to create action emailing. I have everything set up but I just need to change the action download to save to tmp, for example</p> <p>But how I can generate the Excel tmp and send it by email?</p> <pre><code> &lt;?php include("include/conexion.php"); // CONECT TO BBDD require_once('include/write_excel/Worksheet.php'); // CLASS EXCEL require_once('include/write_excel/Workbook.php'); // CLASS EXCEL include_once("include/Classes/class.phpmailer.php"); // CLASS EMAIL header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: inline; filename=$filename" ); $filename = "Listado.xls"; // Creating a workbook $workbook = new Workbook("-"); $worksheet1 =&amp; $workbook-&gt;add_worksheet('Listado'); $formato_texto_negrita =&amp; $workbook-&gt;add_format(); $formato_texto_negrita-&gt;set_bold(0x2BC); $formato_texto_negrita-&gt;set_align('left'); $formato_texto_negrita-&gt;set_size(8); $formato_texto =&amp; $workbook-&gt;add_format(); $formato_texto-&gt;set_align('left'); $formato_texto-&gt;set_size(8); $formatot2 =&amp; $workbook-&gt;add_format(); $formatot2-&gt;set_align('right'); $formatot2-&gt;set_size(8); $formato_numero =&amp; $workbook-&gt;add_format(); $formato_numero-&gt;set_align('right'); $formato_numero-&gt;set_num_format('0.000,00;[Red]-0.000,00'); $formato_numero-&gt;set_size(8); $i=3; $j=0; $k=0; $opcionListado = $_POST['opcionListado']; $worksheet1-&gt;set_column($k,$k++,10); // CLAVE $worksheet1-&gt;set_column($k,$k++,10); // Recepcion $worksheet1-&gt;set_column($k,$k++,15); // Ubicacion // NAME OF COLUMNS….. $res = mysql_query($query, $conexion); for($l=0;$row=mysql_fetch_array($res);$l++) { // DATE ROWS……. } file_put_contents($filename, $workbook-&gt;close()); ?&gt; </code></pre> <p>and the email code include in other php.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload