--- excellib.class.php.orig	2006-10-23 11:26:36.000000000 +0100
+++ excellib.class.php	2006-10-23 11:40:58.000000000 +0100
@@ -46,10 +46,13 @@
      * @param string $filename The name of the file
      */
     function MoodleExcelWorkbook($filename) {
+        global $CFG;
     /// Internally, create one PEAR Spreadsheet_Excel_Writer_Workbook class
         $this->pear_excel_workbook = new Spreadsheet_Excel_Writer($filename);
     /// Prepare it to accept UTF-16LE data and to encode it properly
         $this->pear_excel_workbook->setVersion(8);
+    //paulo.matos: MDL-7176: set appropriate temp dir
+        $this->pear_excel_workbook->setTempDir($CFG->dataroot."/temp");
     }
 
     /* Create one Moodle Worksheet
