title: Working with moodle excellib
body: <p>Can anyone provide me with a working example of moodle excellib library. Currently I am unable to use it since it writes the xls file with all the html tags of current page instead of what I really want to write in it. I need to create custom tables using this library. Currently I created an experiment page in /local just to play with it. But had no luck. The code is as follows:</p>
  
  <pre><code>&lt;?php
  
  /* 
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  
   //The number of lines in front of config file determine the // hierarchy of files.
    require_once(dirname(dirname(__FILE__)).'/config.php');
  
  
    $PAGE-&gt;set_context(context_system::instance());
    $PAGE-&gt;set_pagelayout('admin');
    $PAGE-&gt;set_title("Experiment Page");
    $PAGE-&gt;set_heading("Blank page");
    $PAGE-&gt;set_url($CFG-&gt;wwwroot.'/blank_page.php');
  
  
    echo $OUTPUT-&gt;header();
  
    $filename = 'report_'.(time());
  
    $downloadfilename = clean_filename($filename);
    /// Creating a workbook
    $workbook = new MoodleExcelWorkbook("-");
    /// Sending HTTP headers
    $workbook-&gt;send($downloadfilename);
    /// Adding the worksheet
    $myxls = $workbook-&gt;add_worksheet($filename);
  
    $workbook-&gt;close();
    exit;
  
    echo $OUTPUT-&gt;footer();
  </code></pre>