Tuesday, 15 February 2011

php - Working with moodle excellib -



php - Working with moodle excellib -

can provide me working illustration of moodle excellib library. unable utilize since writes xls file html tags of current page instead of want write in it. need create custom tables using library. created experiment page in /local play it. had no luck. code follows:

<?php /* * alter license header, take license headers in project properties. * alter template file, take tools | templates * , open template in editor. */ //the number of lines in front end of config file determine // hierarchy of files. require_once(dirname(dirname(__file__)).'/config.php'); $page->set_context(context_system::instance()); $page->set_pagelayout('admin'); $page->set_title("experiment page"); $page->set_heading("blank page"); $page->set_url($cfg->wwwroot.'/blank_page.php'); echo $output->header(); $filename = 'report_'.(time()); $downloadfilename = clean_filename($filename); /// creating workbook $workbook = new moodleexcelworkbook("-"); /// sending http headers $workbook->send($downloadfilename); /// adding worksheet $myxls = $workbook->add_worksheet($filename); $workbook->close(); exit; echo $output->footer();

the problem outputting page header user's browser, starting generate excel file. remove $page lines , (most importantly) echo $output->header(); line , work much better.

php excel moodle

No comments:

Post a Comment