WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

Pulling data from MYSQL to EXCEL

ItwasLuck

New member

0

0%

Status

Offline

Posts

29

Likes

0

Rep

0

Bits

155

8

Months of Service

0%
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');
?>
```
 

254

6,645

6,665

Top