I have outputting basic data well. Right now it gets up to ~65k rows of output. What I need now is to be able to embed images into these Excel files. I've been searching since yesterday morning and have yet to find anything all that useful.
Here is the code:
(A part of the top has been omitted, it's just the database information)
Expand|Select|Wrap|Line Numbers
- <?php
- $filename = 'Dump_For_Table_'. $tblname;
- $title = '';
- $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
- $sql = 'SELECT * FROM ' . $tblname;
- $result = mysqli_query($mysqli, $sql);
- header('Content-Type: application/vnd.ms-excel');
- header('Content-Disposition: attachment; filename='. $filename .'.xls');
- header('Pragma: no-cache');
- header('Expires: 0');
- echo($title."\n");
- $sep = "\t";
- //column names
- while($row = mysqli_fetch_field($result))
- {
- echo $row->name . $sep;
- }
- echo("\n");
- //end column names
- while($row = mysqli_fetch_array($result))
- {
- //set_time_limit(60); // HaRa
- $schema_insert = "";
- for($i=0; $i<mysqli_num_fields($result);$i++)
- {
- if(!isset($row[$i]))
- $schema_insert .= " ".$sep;
- elseif ($row[$i] != "")
- $schema_insert .= "$row[$i]".$sep;
- else
- $schema_insert .= "".$sep;
- }
- $schema_insert = str_replace($sep."$", "", $schema_insert);
- $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
- $schema_insert .= "\t";
- echo(trim($schema_insert));
- echo "\n";
- }
- ?>