Hello friends, I want to fetch data from MySQL. I found a code online that suits my needs perfectly; it can input data into separate sheets in Excel. My issue is that I can't seem to write the data I fetch from MySQL. I would appreciate it if you could write a suitable code for this purpose. Thanks in advance.
```php
/**
* Excel_XML
*
* A simple export library for dumping array data into an Excel-readable format. Supports OpenOffice Calc as well.
*
* @author Oliver Schwarz
*/
class Excel_XML {
const sHeader = "\n";
const sFooter = "";
private $aWorksheetData;
private $sOutput;
private $sEncoding;
public function __construct($sEncoding = 'UTF-8') {
$this->sEncoding = $sEncoding;
$this->sOutput = '';
}
public function addWorksheet($title, $data) {
$this->aWorksheetData[] = array(
'title' => $this->getWorksheetTitle($title),
'data' => $data
);
}
public function sendWorkbook($filename) {
// Code for sending workbook to the browser
}
// Other methods...
}
// Your relevant code snippet here...
require dirname(__FILE__) . '/php-excel.class.php';
$data = array(
0 => array('product_id', 'name(tr-tr)', 'categories'),
array(10, 'DENEME', 'DENEME2')
);
$data2 = array(
0 => array('Nr.', 'Name', 'E-Mail'),
array(1, 'Oliver Schwarz', '[email protected]'),
array(2, 'Hasematzel', '[email protected]')
);
$xls = new Excel_XML;
$xls->addWorksheet('products', $data);
$xls->addWorksheet('image', $data2);
$xls->sendWorkbook('urunler.xls');
?>
```
```php
/**
* Excel_XML
*
* A simple export library for dumping array data into an Excel-readable format. Supports OpenOffice Calc as well.
*
* @author Oliver Schwarz
*/
class Excel_XML {
const sHeader = "\n";
const sFooter = "";
private $aWorksheetData;
private $sOutput;
private $sEncoding;
public function __construct($sEncoding = 'UTF-8') {
$this->sEncoding = $sEncoding;
$this->sOutput = '';
}
public function addWorksheet($title, $data) {
$this->aWorksheetData[] = array(
'title' => $this->getWorksheetTitle($title),
'data' => $data
);
}
public function sendWorkbook($filename) {
// Code for sending workbook to the browser
}
// Other methods...
}
// Your relevant code snippet here...
require dirname(__FILE__) . '/php-excel.class.php';
$data = array(
0 => array('product_id', 'name(tr-tr)', 'categories'),
array(10, 'DENEME', 'DENEME2')
);
$data2 = array(
0 => array('Nr.', 'Name', 'E-Mail'),
array(1, 'Oliver Schwarz', '[email protected]'),
array(2, 'Hasematzel', '[email protected]')
);
$xls = new Excel_XML;
$xls->addWorksheet('products', $data);
$xls->addWorksheet('image', $data2);
$xls->sendWorkbook('urunler.xls');
?>
```