writeExcel($Test_name, $dictionary, $dataDir); //MRI data construction //Using CouchDBMRIImporter since same data is imported to DQT. $Test_name = "MRI_Data"; $mriData = new CouchDBMRIImporter(); $scanTypes = $mriData->getScanTypes(); $candidateData = $mriData->getCandidateData($scanTypes); $mriDataDictionary = $mriData->getDataDictionary($scanTypes); //add all dictionary names as excel column headings foreach ($mriDataDictionary as $dicKey => $dicVal) { //if column not already present if (!array_key_exists($dicKey, $candidateData[0])) { $candidateData[0][$dicKey] = NULL; } } writeExcel($Test_name, $candidateData, $dataDir); // Clean up // tar and gzip the product $tarFile = $dumpName . ".tgz"; // produced dump file name and extension $tar = new Archive_Tar($tarFile, "gz"); $tar->add("./{$dumpName}/") or die("Could not add files!"); // mv (or as php calls it, 'rename') to a web-accessible pickup directory rename("./{$tarFile}", "{$destinationDir}/{$tarFile}"); //change, if not a subdirectory // rm left-over junk, from all that excel file generation. delTree($dataDir); // Announce completion echo "{$tarFile} ready in {$destinationDir}\n"; /** * Takes a 2D array and saves it as a nicely formatted Excel spreadsheet.
public function ajax_export_user_() { eval(ADMIN); try { $data = $_POST['data']; $data = json_decode($data, true); $title = array("ID", "用户名", "实名", "性别", "城市", "大学", "学院", "专业", "邮箱", "手机", "毕业年份", "学历"); $_title = array("id", "username", "name", "gender", "cityname", "universityname", "college", "majorname", "email", "mobile", "admittedyear", "degreename"); $content = array(); foreach ($data as $d) { $temp = array(); foreach ($_title as $k => $v) { $temp[$v] = $d[$v]; } array_push($content, $temp); } $info["id"] = 'IBM_Power'; $info["title"] = "IBM Power大赛信息汇总"; $fn = writeExcel($info, $title, $content); echo '{"success":"success","filename":"' . base64_encode($fn) . '"}'; } catch (Exception $e) { echo $e->getMessage(); } }