Note that there are some explanatory texts on larger screens.

plurals
  1. POOutput issues with PHPExcel
    primarykey
    data
    text
    <p>I have a web page where a user selects the amount of rows to be displayed followed by a button within a form that exports the data to excel.</p> <pre><code>&lt;form method="post" action=""&gt; &lt;input type="Submit" name="excel" value="Export" class="button"&gt; &lt;/form&gt; </code></pre> <p>I am able to get the data and put it into the excel file with the follwoing</p> <pre><code>if($_POST['excel']){ $phpExcel = new PHPExcel(); $styleArray = array( 'font' =&gt; array( 'bold' =&gt; true, ) ); //Get the active sheet and assign to a variable $foo = $phpExcel-&gt;getActiveSheet(); //add column headers, set the title and make the text bold $foo-&gt;setCellValue("A1", "Nombre") -&gt;setCellValue("B1", "Paterno") -&gt;setCellValue("C1", "Pkey") -&gt;setCellValue("D1", "Telefono") -&gt;setCellValue("E1", "Ciudad") -&gt;setCellValue("F1", "Used") -&gt;setTitle("Contactos Encuestas") -&gt;getStyle("A1:F1")-&gt;applyFromArray($styleArray); $xlsRow = 1; foreach ($rows as $column) { $foo-&gt;setCellValue("A".$xlsRow++, $column[2]) -&gt;setCellValue("B".$xlsRow++, $column[3]) -&gt;setCellValue("C".$xlsRow++, $column[0]) -&gt;setCellValue("D".$xlsRow++, $column[1]) -&gt;setCellValue("E".$xlsRow++, $column[5]) -&gt;setCellValue("F".$xlsRow++, $column[4]); } header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"ENcuestas_Contactos.xls\""); header("Cache-Control: max-age=0"); $objWriter = PHPExcel_IOFactory::createWriter($phpExcel, "Excel5"); $objWriter-&gt;save("php://output"); $phpExcel-&gt;disconnectWorksheets(); unset($phpExcel); } </code></pre> <p>This kinda works, the issue is that weird text allong with the webpage elements such as buttons and images get put onto the excel file.</p> <p>What could be the issue?</p> <p>is there a setting i'm missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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