jsonList = parseJSON($json); } /** * Export results to Excel 5 spreadsheet * requires PEAR modules OLE and Spreadsheet_Excel_Writer */ function export_excel() { require_once 'Spreadsheet/Excel/Writer.php'; $groups = $this->jsonList[0]; $workbook = new Spreadsheet_Excel_Writer(); $format_bold =& $workbook->addFormat(); $format_bold->setBold(); $format_title =& $workbook->addFormat(); $format_title->setBold(); $format_title->setColor('blue'); $worksheet =& $workbook->addWorksheet(); $r = 0; foreach ($groups as $grp) { //echo $grp->name . "\n"; $worksheet->write($r, 0, $grp->description, $format_title); $r++; $headerList = $grp->header; $hL = count($headerList); $col = 0; for ($hi=0; $hi < $hL; $hi++) { $headline = $headerList[$hi]; if ($headline == "@") { //$col--; } else { $worksheet->write($r, $col, $headline, $format_bold); $col++; } } $r++; $values = $grp->values; foreach ($values as $vList) { $vcol = 0; foreach ($vList as $v) { if (is_object($v)) { $shplink = $v->shplink; if ($shplink) { } $hyperlink = $v->hyperlink; if ($hyperlink) { $worksheet->write($r, $vcol, $hyperlink[3]); $vcol++; } } else { //error_log(" $v, "); $worksheet->write($r, $vcol, $v); $vcol++; } } $r++; } $r++; } $workbook->send('test.xls'); $workbook->close(); } } $json = file("testresult.txt"); require_once("../common.php"); //print_r(parseJSON($json[0])); $export = new ExportQuery($json[0]); $export->export_excel(); ?>