当前位置: 首页>>代码示例>>PHP>>正文


PHP Spreadsheet_Excel_Writer::setTempDir方法代码示例

本文整理汇总了PHP中Spreadsheet_Excel_Writer::setTempDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Spreadsheet_Excel_Writer::setTempDir方法的具体用法?PHP Spreadsheet_Excel_Writer::setTempDir怎么用?PHP Spreadsheet_Excel_Writer::setTempDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spreadsheet_Excel_Writer的用法示例。


在下文中一共展示了Spreadsheet_Excel_Writer::setTempDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xls

 /**
  * создает файл в формате XLS (Microsoft Excel) на основе переданных данных
  *
  * @param array $data содержимое ячеек таблицы
  * @param string $name имя отчета
  * @return string содержимое файла
  */
 public function xls(&$data, $name)
 {
     $fileName = date("Y-m-d_H-i-s");
     $workBook = new Spreadsheet_Excel_Writer();
     $workBook->setTempDir(BASEPATH . 'cache/');
     $workBook->setVersion(8);
     $workBook->send(__("report") . "_{$fileName}.xls");
     $formatBold =& $workBook->addFormat();
     $formatBold->setBold();
     $formatTitle =& $workBook->addFormat();
     $formatTitle->setBold();
     $formatTitle->setColor('black');
     $formatTitle->setPattern(1);
     $formatTitle->setFgColor('gray');
     $formatTitle->setAlign('merge');
     $workSheet =& $workBook->addWorksheet('Report');
     $workSheet->setInputEncoding('utf-8');
     $row_count = 0;
     foreach ($data as $row) {
         $col_count = 0;
         foreach ($row as $column) {
             $workSheet->write($row_count, $col_count, $column, $row_count ? $formatBold : $formatTitle);
             $col_count++;
         }
         $row_count++;
     }
     //      ширина столбцов
     //      $workSheet->setColumn(0, 0, 30);
     //      $workSheet->setColumn(2, 2, 30);
     $workBook->close();
 }
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:38,代码来源:make_file.php

示例2: OutputExcel

 public function OutputExcel()
 {
     // Creating a workbook
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setTempDir(_DIR_CACHE);
     $workbook->setVersion(8);
     // sending HTTP headers
     $workbook->send('products.xls');
     // Let's create catalogue worksheet:
     $this->addWorksheet($workbook);
     // Let's send the file
     $workbook->close();
     // After file has been sent, just exit:
     exit;
 }
开发者ID:foobar64,项目名称:spip-ecatalogue,代码行数:15,代码来源:class.ProductExcel.php

示例3: export_complete_report_xls

function export_complete_report_xls($filename, $array)
{
    global $charset, $global, $filter_score;
    $workbook = new Spreadsheet_Excel_Writer();
    $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
    $workbook->send($filename);
    $workbook->setVersion(8);
    // BIFF8
    $worksheet =& $workbook->addWorksheet('Report');
    //$worksheet->setInputEncoding(api_get_system_encoding());
    $worksheet->setInputEncoding($charset);
    $line = 0;
    $column = 0;
    //skip the first column (row titles)
    if ($global) {
        $worksheet->write($line, $column, get_lang('Courses'));
        $column++;
        $worksheet->write($line, $column, get_lang('Exercises'));
        $column++;
        $worksheet->write($line, $column, get_lang('ExamTaken'));
        $column++;
        $worksheet->write($line, $column, get_lang('ExamNotTaken'));
        $column++;
        $worksheet->write($line, $column, sprintf(get_lang('ExamPassX'), $filter_score) . '%');
        $column++;
        $worksheet->write($line, $column, get_lang('ExamFail'));
        $column++;
        $worksheet->write($line, $column, get_lang('TotalStudents'));
        $column++;
        $line++;
        foreach ($array as $row) {
            $column = 0;
            foreach ($row as $item) {
                $worksheet->write($line, $column, html_entity_decode(strip_tags($item)));
                $column++;
            }
            $line++;
        }
        $line++;
    } else {
        $worksheet->write($line, $column, get_lang('Exercises'));
        $column++;
        $worksheet->write($line, $column, get_lang('User'));
        $column++;
        $worksheet->write($line, $column, get_lang('Percentage'));
        $column++;
        $worksheet->write($line, $column, get_lang('Status'));
        $column++;
        $worksheet->write($line, $column, get_lang('Attempts'));
        $column++;
        $line++;
        foreach ($array as $row) {
            $column = 0;
            $worksheet->write($line, $column, html_entity_decode(strip_tags($row['exercise'])));
            $column++;
            foreach ($row['users'] as $key => $user) {
                $column = 1;
                $worksheet->write($line, $column, html_entity_decode(strip_tags($user)));
                $column++;
                foreach ($row['results'][$key] as $result_item) {
                    $worksheet->write($line, $column, html_entity_decode(strip_tags($result_item)));
                    $column++;
                }
                $line++;
            }
        }
        $line++;
    }
    $workbook->close();
    exit;
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:71,代码来源:exams.php

示例4: _xls

 private static function _xls()
 {
     $t = $GLOBALS["t"];
     require "lib/spreadsheet/Writer.php";
     $xls = new Spreadsheet_Excel_Writer();
     $xls->setTempDir(SIMPLE_CACHE . "/output/");
     $xls->setVersion(8);
     $sheet = $xls->addWorksheet($t["title"]);
     $sheet->setInputEncoding('utf-8');
     $sheet->freezePanes(array(1, 0, 1, 0));
     $bold = $xls->addFormat();
     $bold->setBold();
     $normal = $xls->addFormat();
     $normal->setVAlign("top");
     $normal->setTextWrap();
     $data = self::_build_data(true);
     $row = 0;
     $col = 0;
     if (count($data) > 0) {
         $col = 0;
         $sheet->setColumn(0, count($data[0]) - 1, 15);
         foreach ($data[0] as $field) {
             if (empty($field["name"])) {
                 continue;
             }
             $sheet->write($row, $col++, $field["displayname"], $bold);
         }
         $row++;
         foreach ($data as $asset) {
             $col = 0;
             foreach ($asset as $aval) {
                 if (!isset($aval["filter"])) {
                     continue;
                 }
                 $sheet->write($row, $col++, trim(strip_tags($aval["filter"])), $normal);
             }
             $row++;
         }
     } else {
         $header = self::_build_fields();
         $col = 0;
         $sheet->setColumn(0, count($header) - 1, 15);
         foreach ($header as $field) {
             $sheet->write($row, $col++, $field, $bold);
         }
     }
     $xls->close();
 }
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:48,代码来源:export.php

示例5: count

 /**
  * Quite similar to display_complete_report(), returns an HTML string
  * that can be used in a csv file
  * @todo consider merging this function with display_complete_report
  * @return    string    The contents of a csv file
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version February 2007
  */
 static function export_complete_report_xls($filename, $user_id = 0)
 {
     require_once api_get_path(LIBRARY_PATH) . 'pear/Spreadsheet_Excel_Writer/Writer.php';
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
     $workbook->send($filename);
     $workbook->setVersion(8);
     // BIFF8
     $worksheet =& $workbook->addWorksheet('Report 1');
     $worksheet->setInputEncoding(api_get_system_encoding());
     $line = 0;
     $column = 1;
     // Skip the first column (row titles)
     // Show extra fields blank space (enough for extra fields on next line)
     $display_extra_user_fields = false;
     //if (!empty($_REQUEST['fields_filter'])) {
     // Show user fields section with a big th colspan that spans over all fields
     $extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true);
     $num = count($extra_user_fields);
     for ($i = 0; $i < $num; $i++) {
         $worksheet->write($line, $column, '');
         $column++;
     }
     $display_extra_user_fields = true;
     //}
     // Database table definitions
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
     $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
     $course_id = api_get_course_int_id();
     // First line (questions)
     $sql = "SELECT questions.question_id, questions.type, questions.survey_question, count(options.question_option_id) as number_of_options\n\t\t\t\tFROM {$table_survey_question} questions LEFT JOIN {$table_survey_question_option} options\n\t\t\t\t     ON questions.question_id = options.question_id AND options.c_id = {$course_id}\n\t\t\t\tWHERE questions.survey_id = '" . Database::escape_string($_GET['survey_id']) . "' AND\n\t\t\t\tquestions.c_id = {$course_id}\n\t\t\t\tGROUP BY questions.question_id\n\t\t\t\tORDER BY questions.sort ASC";
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         // We show the questions if
         // 1. there is no question filter and the export button has not been clicked
         // 2. there is a quesiton filter but the question is selected for display
         if (!$_POST['submit_question_filter'] || is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) {
             // We do not show comment and pagebreak question types
             if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
                 if ($row['number_of_options'] == 0 && $row['type'] == 'open') {
                     $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES));
                     $column++;
                 } else {
                     for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
                         $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES));
                         $column++;
                     }
                 }
             }
         }
     }
     $line++;
     $column = 1;
     // Show extra field values
     if ($display_extra_user_fields) {
         // Show the fields names for user fields
         foreach ($extra_user_fields as &$field) {
             $worksheet->write($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES));
             $column++;
         }
     }
     // Getting all the questions and options (second line)
     $sql = "SELECT \tsurvey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type,\n\t\t\t\t\t\tsurvey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort\n\t\t\t\tFROM {$table_survey_question} survey_question\n\t\t\t\tLEFT JOIN {$table_survey_question_option} survey_question_option\n\t\t\t\tON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = {$course_id}\n\t\t\t\tWHERE survey_question.survey_id = '" . Database::escape_string($_GET['survey_id']) . "' AND\n\t\t\t\tsurvey_question.c_id = {$course_id}\n\t\t\t\tORDER BY survey_question.sort ASC, survey_question_option.sort ASC";
     $result = Database::query($sql);
     $possible_answers = array();
     $possible_answers_type = array();
     while ($row = Database::fetch_array($result)) {
         // We show the options if
         // 1. there is no question filter and the export button has not been clicked
         // 2. there is a quesiton filter but the question is selected for display
         if (!$_POST['submit_question_filter'] || is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) {
             // We do not show comment and pagebreak question types
             if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES));
                 $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
                 $possible_answers_type[$row['question_id']] = $row['type'];
                 $column++;
             }
         }
     }
     // Getting all the answers of the users
     $line++;
     $column = 0;
     $old_user = '';
     $answers_of_user = array();
     $sql = "SELECT * FROM {$table_survey_answer} WHERE c_id = {$course_id} AND survey_id='" . Database::escape_string($_GET['survey_id']) . "' ";
     if ($user_id != 0) {
         $sql .= "AND user='" . Database::escape_string($user_id) . "' ";
     }
     $sql .= "ORDER BY user ASC";
     $open_question_iterator = 1;
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:survey.lib.php

示例6: if

    $sort_element_id = $temp[1];
    if ($sort_radio_has_other) {
        //if this is radio button field with 'other' enabled
        $sorting_query = ",(\t\r\n\t\t\t\t\t\t\t\t\tselect if(A.{$sort_element}=0,A.{$sort_element}_other,\r\n\t\t\t\t\t\t\t\t\t\t\t\t(select \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`option` \r\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom " . MF_TABLE_PREFIX . "element_options \r\n\t\t\t\t\t\t\t\t\t\t\t\t   where \r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\tform_id='{$form_id}' and \r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\telement_id='{$sort_element_id}' and \r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\toption_id=A.{$sort_element} and \r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\tlive=1)\r\n\t\t\t\t\t\t\t\t   \t)\r\n\t\t\t\t\t\t\t   ) {$sort_element}_key";
    } else {
        $sorting_query = ",(\r\n\t\t\t\t\t\t\t\tselect \r\n\t\t\t\t\t\t\t\t\t\t`option` \r\n\t\t\t\t\t\t\t\t\tfrom " . MF_TABLE_PREFIX . "element_options \r\n\t\t\t\t\t\t\t\t   where \r\n\t\t\t\t\t\t\t\t   \t\tform_id='{$form_id}' and \r\n\t\t\t\t\t\t\t\t   \t\telement_id='{$sort_element_id}' and \r\n\t\t\t\t\t\t\t\t   \t\toption_id=A.{$sort_element} and \r\n\t\t\t\t\t\t\t\t   \t\tlive=1\r\n\t\t\t\t\t\t\t ) {$sort_element}_key";
    }
    //override the $sort_element
    $sort_element .= '_key';
}
//prepare the header response, based on the export type
if ($export_type == 'xls') {
    require 'Spreadsheet/Excel/Writer.php';
    // Creating a workbook
    $workbook = new Spreadsheet_Excel_Writer();
    $workbook->setTempDir($mf_settings['upload_dir']);
    // sending HTTP headers
    $workbook->send("{$clean_form_name}.xls");
    if (function_exists('iconv')) {
        $workbook->setVersion(8);
    }
    // Creating a worksheet
    $clean_form_name = substr($clean_form_name, 0, 30);
    //must be less than 31 characters
    $worksheet =& $workbook->addWorksheet($clean_form_name);
    $format_bold =& $workbook->addFormat();
    $format_bold->setBold();
    $format_bold->setFgColor(22);
    $format_bold->setPattern(1);
    $format_bold->setBorder(1);
    if (function_exists('iconv')) {
开发者ID:janssit,项目名称:machform.janss.be,代码行数:31,代码来源:export_entries.php

示例7: date

    logging::write_log(LOG_DEBUGLOG, "units_pointlist_excel:\t " . $login . "\t" . $unit->get_display_name() . "\t" . $participant_group->get_identifier() . "\t" . $participant_group->count_members() . "\t" . date("d.m.y G:i:s", time()) . "... ");
}
$members = $cache->call("lms_steam::group_get_members", $participant_group->get_id(), TRUE);
// INITIALIZATION
$course_id = $course->get_course_id();
$course_name = $course->get_course_name();
$semester = $course->get_semester();
$proxy_data = $proxy->get_all_attributes();
$points = units_pointlist::extract_pointlist($proxy_data);
$maxpoints = $proxy_data["UNIT_POINTLIST_MAXPOINTS"];
$count = $unit->get_attribute("UNIT_POINTLIST_COUNT");
$bonus_1 = $unit->get_attribute("UNIT_POINTLIST_BONUS_1");
$bonus_2 = $unit->get_attribute("UNIT_POINTLIST_BONUS_2");
$unit_name = $unit->get_display_name();
$excel = new Spreadsheet_Excel_Writer();
$excel->setTempDir(PATH_TEMP);
$format_table_header =& $excel->addFormat(array('Size' => 12, 'Align' => 'left', 'Bold' => 1));
$format_table_header_number =& $excel->addFormat(array('Size' => 12, 'Align' => 'right', 'Bold' => 1));
$sheet_table_header =& $excel->addFormat(array('Size' => 14, 'Align' => 'left'));
$format_table_header =& $excel->addFormat(array('Size' => 12, 'Align' => 'left', 'Bold' => 1));
$format_table_header_faded =& $excel->addFormat(array('Size' => 12, 'Align' => 'left', 'Color' => 'grey'));
$format_cell =& $excel->addFormat(array('Size' => 9, 'Align' => 'left', 'Bold' => 1));
$format_cell->setAlign('vcenter');
$format_cell->setTextWrap(1);
$excel->send($unit_name . "_" . str_replace(".", "-", $course_id) . "_" . $semester->get_name() . ".xls");
$sheet =& $excel->addWorksheet(gettext("Pointlist"));
// WRITE EXCEL SHEET
$sheet->writeString(0, 0, gettext("Course") . ":", $sheet_table_header);
$sheet->writeString(0, 1, $course_id . " - " . $course_name, $sheet_table_header);
$sheet->writeString(1, 0, gettext("Semester") . ":", $sheet_table_header);
$sheet->writeString(1, 1, $semester->get_name(), $sheet_table_header);
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:units_pointlist_excel.php

示例8: generate_statistics


//.........这里部分代码省略.........

        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

        //set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

        //set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

        //set some language-dependent strings
        $pdf->setLanguageArray($l);
    }
    if($outputType=='xls')
    {
        /**
         * Initiate the Spreadsheet_Excel_Writer
         */
        include_once(dirname(__FILE__)."/classes/pear/Spreadsheet/Excel/Writer.php");
        if($pdfOutput=='F')
        $workbook = new Spreadsheet_Excel_Writer($tempdir.'/statistic-survey'.$surveyid.'.xls');
        else
        $workbook = new Spreadsheet_Excel_Writer();

        $workbook->setVersion(8);
        // Inform the module that our data will arrive as UTF-8.
        // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...)
        if (!empty($tempdir)) {
            $workbook->setTempDir($tempdir);
        }
        if ($pdfOutput!='F')
        $workbook->send('statistic-survey'.$surveyid.'.xls');

        // Creating the first worksheet
        $sheet =& $workbook->addWorksheet(utf8_decode('results-survey'.$surveyid));
        $sheet->setInputEncoding('utf-8');
        $sheet->setColumn(0,20,20);
        $separator="~|";
    }
    /**
     * Start generating
     */

    // creates array of post variable names
    for (reset($_POST); $key=key($_POST); next($_POST)) { $postvars[]=$key;}

    $aQuestionMap=array();
    foreach ($fieldmap as $field)
    {
        if(isset($field['qid']) && $field['qid']!='')
        $aQuestionMap[]=$field['sid'].'X'.$field['gid'].'X'.$field['qid'];
    }

    /*
     * Iterate through postvars to create "nice" data for SQL later.
     *
     * Remember there might be some filters applied which have to be put into an SQL statement
     */
    if(isset($postvars))

    foreach ($postvars as $pv)
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:67,代码来源:statistics_function.php

示例9: openWithFilename

 function openWithFilename($filename)
 {
     require_once 'Spreadsheet/Excel/Writer.php';
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setVersion(8, 'UTF-8');
     $workbook->setTempDir(MAX_PATH . '/var/cache');
     $this->_setExcelWriter($workbook);
     $workbook->send($filename);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:9,代码来源:ExcelWriter.php

示例10: exportCompleteReportXLS

 /**
  * Exports the complete report as an XLS file
  * @return	boolean		False on error
  */
 public function exportCompleteReportXLS($data)
 {
     $filename = 'gradebook-results-' . date('Y-m-d-h:i:s') . '.xls';
     include api_get_path(LIBRARY_PATH) . 'pear/Spreadsheet_Excel_Writer/Writer.php';
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setVersion(8);
     // BIFF8
     $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
     $workbook->send($filename);
     $worksheet =& $workbook->addWorksheet('Report');
     $worksheet->setInputEncoding(api_get_system_encoding());
     $line = 0;
     $column = 0;
     //skip the first column (row titles)
     //headers
     foreach ($data[0] as $header_col) {
         $worksheet->write($line, $column, $header_col);
         $column++;
     }
     $line++;
     $cant_students = count($data[1]);
     for ($i = 0; $i < $cant_students; $i++) {
         $column = 0;
         foreach ($data[1][$i] as $col_name) {
             $worksheet->write($line, $column, html_entity_decode(strip_tags($col_name)));
             $column++;
         }
         $line++;
     }
     $workbook->close();
     exit;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:36,代码来源:gradebook_result.class.php

示例11: array

                    if (!empty($total_time_spent)) {
                        $array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
                        $array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
                    }
                    //$array[$i]['tools_used'] = $total_tools;
                }
                $i++;
            }
        }
    }
}
$headers = array(get_lang('LearningPath'), get_lang('Teachers'), get_lang('Courses'), get_lang('NumberOfStudents'), get_lang('NumberStudentsAccessingCourse'), get_lang('PercentageStudentsAccessingCourse'), get_lang('NumberStudentsCompleteAllActivities'), get_lang('PercentageStudentsCompleteAllActivities'), get_lang('AverageOfActivitiesCompletedPerStudent'), get_lang('TotalTimeSpentInTheCourse'), get_lang('AverageTimePerStudentInCourse'), get_lang('NumberOfDocumentsInLearnpath'), get_lang('NumberOfExercisesInLearnpath'), get_lang('NumberOfLinksInLearnpath'), get_lang('NumberOfForumsInLearnpath'), get_lang('NumberOfAssignmentsInLearnpath'), get_lang('NumberOfAnnouncementsInCourse'));
if (isset($_GET['export'])) {
    global $charset;
    $workbook = new Spreadsheet_Excel_Writer();
    $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
    $workbook->send($filename);
    $workbook->setVersion(8);
    // BIFF8
    $worksheet =& $workbook->addWorksheet('Report');
    //$worksheet->setInputEncoding(api_get_system_encoding());
    $worksheet->setInputEncoding($charset);
    $line = 0;
    $column = 0;
    //skip the first column (row titles)
    foreach ($headers as $header) {
        $worksheet->write($line, $column, $header);
        $column++;
    }
    $line++;
    foreach ($array as $row) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:current_courses.php

示例12: getSmartyTpl

 public function getSmartyTpl()
 {
     $currentUser = $this->getCurrentUser();
     $smarty = $this->getSmartyVar();
     $ranges = $this->getRanges();
     $smarty->assign("T_GRADEBOOK_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_GRADEBOOK_BASELINK", $this->moduleBaseLink);
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
         $currentLesson = $this->getCurrentLesson();
         $currentLessonID = $currentLesson->lesson['id'];
         $lessonUsers = $currentLesson->getUsers('student');
         // get all students that have this lesson
         $lessonColumns = $this->getLessonColumns($currentLessonID);
         $allUsers = $this->getLessonUsers($currentLessonID, $lessonColumns);
         $gradeBookLessons = $this->getGradebookLessons($currentUser->getLessons(false, 'professor'), $currentLessonID);
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $currentLesson = $this->getCurrentLesson();
             $currentLessonID = $currentLesson->lesson['id'];
         }
     }
     if (isset($_GET['import_grades']) && eF_checkParameter($_GET['import_grades'], 'id') && in_array($_GET['import_grades'], array_keys($lessonColumns))) {
         $object = eF_getTableData("module_gradebook_objects", "creator", "id=" . $_GET['import_grades']);
         //if($object[0]['creator'] != $_SESSION['s_login']){
         if ($currentUser->getRole($this->getCurrentLesson()) != 'professor') {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_GRADEBOOK_NOACCESS));
             exit;
         }
         $result = eF_getTableData("module_gradebook_objects", "refers_to_type, refers_to_id", "id=" . $_GET['import_grades']);
         $type = $result[0]['refers_to_type'];
         $id = $result[0]['refers_to_id'];
         $oid = $_GET['import_grades'];
         foreach ($lessonUsers as $userLogin => $value) {
             $this->importGrades($type, $id, $oid, $userLogin);
         }
     } else {
         if (isset($_GET['delete_column']) && eF_checkParameter($_GET['delete_column'], 'id') && in_array($_GET['delete_column'], array_keys($lessonColumns))) {
             $object = eF_getTableData("module_gradebook_objects", "creator", "id=" . $_GET['delete_column']);
             //if($object[0]['creator'] != $_SESSION['s_login']){
             if ($currentUser->getRole($this->getCurrentLesson()) != 'professor') {
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_GRADEBOOK_NOACCESS));
                 exit;
             }
             eF_deleteTableData("module_gradebook_objects", "id=" . $_GET['delete_column']);
             eF_deleteTableData("module_gradebook_grades", "oid=" . $_GET['delete_column']);
         } else {
             if (isset($_GET['compute_score_grade']) && $_GET['compute_score_grade'] == '1') {
                 foreach ($allUsers as $uid => $student) {
                     $this->computeScoreGrade($lessonColumns, $ranges, $student['users_LOGIN'], $uid);
                 }
             } else {
                 if (isset($_GET['export_excel']) && ($_GET['export_excel'] == 'one' || $_GET['export_excel'] == 'all')) {
                     require_once 'Spreadsheet/Excel/Writer.php';
                     $workBook = new Spreadsheet_Excel_Writer();
                     $workBook->setTempDir(G_UPLOADPATH);
                     $workBook->setVersion(8);
                     $workBook->send('GradeBook.xls');
                     if ($_GET['export_excel'] == 'one') {
                         $workSheet =& $workBook->addWorksheet($currentLesson->lesson['name']);
                         $this->professorLessonToExcel($currentLessonID, $currentLesson->lesson['name'], $workBook, $workSheet);
                     } else {
                         if ($_GET['export_excel'] == 'all') {
                             $professorLessons = $currentUser->getLessons(false, 'professor');
                             foreach ($professorLessons as $key => $value) {
                                 $subLesson = new EfrontLesson($key);
                                 $subLessonUsers = $subLesson->getUsers('student');
                                 // get all students that have this lesson
                                 $result = eF_getTableData("module_gradebook_users", "count(uid) as total_users", "lessons_ID=" . $key);
                                 if ($result[0]['total_users'] != 0) {
                                     // module installed for this lesson
                                     $workSheet =& $workBook->addWorksheet($subLesson->lesson['name']);
                                     $this->professorLessonToExcel($key, $subLesson->lesson['name'], $workBook, $workSheet);
                                 }
                             }
                         }
                     }
                     $workBook->close();
                     exit;
                 } else {
                     if (isset($_GET['export_student_excel']) && ($_GET['export_student_excel'] == 'current' || $_GET['export_student_excel'] == 'all')) {
                         require_once 'Spreadsheet/Excel/Writer.php';
                         $workBook = new Spreadsheet_Excel_Writer();
                         $workBook->setTempDir(G_UPLOADPATH);
                         $workBook->setVersion(8);
                         $workBook->send('GradeBook.xls');
                         if ($_GET['export_student_excel'] == 'current') {
                             $workSheet =& $workBook->addWorksheet($currentLesson->lesson['name']);
                             $this->studentLessonToExcel($currentLessonID, $currentLesson->lesson['name'], $currentUser, $workBook, $workSheet);
                         } else {
                             if ($_GET['export_student_excel'] == 'all') {
                                 $studentLessons = $currentUser->getLessons(false, 'student');
                                 foreach ($studentLessons as $key => $value) {
                                     // Is GradeBook installed for this lesson ?
                                     $installed = eF_getTableData("module_gradebook_users", "*", "lessons_ID=" . $key . " and users_LOGIN='" . $currentUser->user['login'] . "'");
                                     if (sizeof($installed) != 0) {
                                         $subLesson = new EfrontLesson($key);
                                         $workSheet =& $workBook->addWorksheet($subLesson->lesson['name']);
                                         $this->studentLessonToExcel($key, $subLesson->lesson['name'], $currentUser, $workBook, $workSheet);
                                     }
                                 }
//.........这里部分代码省略.........
开发者ID:kaseya-university,项目名称:efront,代码行数:101,代码来源:module_gradebook.class.php

示例13: createXLS

    function createXLS($result) {

        ob_clean();
        ob_start();
        set_time_limit(0);
        error_reporting(0);
        require_once JPATH_COMPONENT_SITE . '/libraries/pear/PEAR.php';
        require_once (JPATH_ROOT . '/components/com_bids/libraries/Excel/Writer.php');
        // Creating a workbook
        $workbook = new Spreadsheet_Excel_Writer();
        $workbook->setTempDir(JPATH_ROOT.DS.'tmp');
        $worksheet = $workbook->addWorksheet('Exported Auctions');
        $BIFF = new Spreadsheet_Excel_Writer_BIFFwriter();
        $format = new Spreadsheet_Excel_Writer_Format($BIFF);
        $format->setBold(1);
        $format->setAlign('center');

        $colNr = 0;

        $worksheet->write(0, $colNr++, "User", $format);
        $worksheet->write(0, $colNr++, "Title", $format);
        $worksheet->write(0, $colNr++, "Short description");
        $worksheet->write(0, $colNr++, "Description");
        $worksheet->write(0, $colNr++, "Initial price");
        $worksheet->write(0, $colNr++, "Currency");
        $worksheet->write(0, $colNr++, "BIN price");
        $worksheet->write(0, $colNr++, "Auction type");
        $worksheet->write(0, $colNr++, "Automatic");
        $worksheet->write(0, $colNr++, "Payment");
        $worksheet->write(0, $colNr++, "Shipment Info");
        $worksheet->write(0, $colNr++, "Start date");
        $worksheet->write(0, $colNr++, "End date");
        $worksheet->write(0, $colNr++, "Param: picture");
        $worksheet->write(0, $colNr++, "Param: add_picture");
        $worksheet->write(0, $colNr++, "Param: auto_accept_bin");
        $worksheet->write(0, $colNr++, "Param: bid_counts");
        $worksheet->write(0, $colNr++, "Param: max_price");
        $worksheet->write(0, $colNr++, "Published");
        $worksheet->write(0, $colNr++, "Category");
        $worksheet->write(0, $colNr++, "Highest Bid");
        for ($i = 0; $i < count($result); $i++) {
            $colNr = 0;
            $worksheet->write($i + 1, $colNr++, $result[$i]->username);
            $worksheet->write($i + 1, $colNr++, $result[$i]->title);
            $worksheet->write($i + 1, $colNr++, $result[$i]->shortdescription);
            $worksheet->write($i + 1, $colNr++, $result[$i]->description);
            $worksheet->write($i + 1, $colNr++, $result[$i]->initial_price);
            $worksheet->write($i + 1, $colNr++, $result[$i]->currency);
            $worksheet->write($i + 1, $colNr++, $result[$i]->BIN_price);
            switch ($result[$i]->auction_type) {
                case 1:
                    $worksheet->write($i + 1, $colNr++, 'public');
                    break;
                case 2:
                    $worksheet->write($i + 1, $colNr++, 'private');
                    break;
                case 3:
                    $worksheet->write($i + 1, $colNr++, 'BIN only');
                    break;
            }
            $worksheet->write($i + 1, $colNr++, $result[$i]->automatic);
            $worksheet->write($i + 1, $colNr++, $result[$i]->payment_method);
            $worksheet->write($i + 1, $colNr++, $result[$i]->shipment_info);
            $worksheet->write($i + 1, $colNr++, $result[$i]->start_date);
            $worksheet->write($i + 1, $colNr++, $result[$i]->end_date);
            $params = explode("\n", $result[$i]->params);
            $tmp = explode("=", $params[0]); // picture param
            $worksheet->write($i + 1, $colNr++, $tmp[1]);
            $tmp = explode("=", $params[1]); // add_picture
            $worksheet->write($i + 1, $colNr++, $tmp[1]);
            $tmp = explode("=", $params[2]); // auto_accept_bin
            $worksheet->write($i + 1, $colNr++, $tmp[1]);
            $tmp = explode("=", $params[3]); // bid_counts
            $worksheet->write($i + 1, $colNr++, $tmp[1]);
            $tmp = explode("=", $params[4]); // max_price
            $worksheet->write($i + 1, $colNr++, $tmp[1]);

            $worksheet->write($i + 1, $colNr++, $result[$i]->published);
            $worksheet->write($i + 1, $colNr++, $result[$i]->catname);
            $worksheet->write($i + 1, $colNr++, $result[$i]->highest_bid);

            $worksheet->setColumn(0, 0, 9);
            $worksheet->setColumn(1, 12, 25);
        }
        $workbook->close();
        $attachment = ob_get_clean();

        return $attachment;
    }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:89,代码来源:tools.php

示例14: export

 public function export($mode = null)
 {
     if ($this->survey->isDeleted()) {
         return null;
     }
     $exportResult = array('headers' => array(), 'content' => "");
     ob_start();
     $exportoutput = "";
     $tokenTableExists = $this->survey->getDbConnection()->schema->getTable('tokens_' . $this->survey->sid) !== null;
     $aTokenFieldNames = array();
     if ($tokenTableExists) {
         $aTokenFieldNames = static::getTokenFieldsAndNames($this->survey);
         $attributeFieldAndNames = static::getTokenFieldsAndNames($this->survey, true);
         $attributeFields = array_keys($attributeFieldAndNames);
     }
     require_once Yii::getPathOfAlias('ext.excelWriter') . "/Writer.php";
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setVersion(8);
     // Inform the module that our data will arrive as UTF-8.
     // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...)
     if (!empty($tempdir)) {
         $workbook->setTempDir($tempdir);
     }
     $exportResult['headers'][] = "Content-type: application/vnd.ms-excel";
     $exportResult['headers'][] = "Content-Disposition: attachment; filename=\"results-survey" . $this->survey->sid . ".xls\"";
     $exportResult['headers'][] = "Expires: 0";
     $exportResult['headers'][] = "Cache-Control: must-revalidate, post-check=0,pre-check=0";
     $exportResult['headers'][] = "Pragma: public";
     //        $workbook->send('results-survey'.$this->survey->sid.'.xls');
     // Creating the first worksheet
     $query = "SELECT * FROM lime_surveys_languagesettings WHERE surveyls_survey_id=" . $this->survey->sid;
     //        $result = db_execute_assoc($query) or safe_die("Couldn't get privacy data<br />$query<br />".$connect->ErrorMsg());
     //        $row = $result->FetchRow();
     $row = $this->survey->getDbConnection()->createCommand($query)->queryRow();
     $row['surveyls_title'] = substr(str_replace(array('*', ':', '/', '\\', '?', '[', ']'), array(' '), $row['surveyls_title']), 0, 31);
     // Remove invalid characters
     $sheet =& $workbook->addWorksheet($row['surveyls_title']);
     // do not translate/change this - the library does not support any special chars in sheet name
     $sheet->setInputEncoding('utf-8');
     $separator = "~|";
     $exportResult['headers'][] = "Cache-Control: must-revalidate, post-check=0, pre-check=0";
     $exportResult['headers'][] = "Pragma: public";
     // Export Language is set by default to surveybaselang
     // * the explang language code is used in SQL queries
     // * the alang object is used to translate headers and hardcoded answers
     // In the future it might be possible to 'post' the 'export language' from
     // the exportresults form
     //        $explang = 'ru';
     //        $elang=new limesurvey_lang($explang);
     //STEP 1: First line is column headings
     $fieldmap = static::createFieldMap($this->survey, 'full');
     if ($this->survey->savetimings === "Y") {
         //Append survey timings to the fieldmap array
         $fieldmap = $fieldmap + static::createTimingsFieldMap($this->survey, 'full');
     }
     //Get the fieldnames from the survey table for column headings
     $surveytable = "lime_survey_{$this->survey->sid}";
     //        if (isset($_POST['colselect']))
     //        {
     //            $selectfields="";
     //            foreach($_POST['colselect'] as $cs)
     //            {
     //                if (!isset($fieldmap[$cs]) && !isset($aTokenFieldNames[$cs]) && $cs != 'completed') continue; // skip invalid field names to prevent SQL injection
     //                if ($tokenTableExists && $cs == 'token')
     //                {
     //                    // We shouldnt include the token field when we are joining with the token field
     //                }
     //                elseif ($cs === 'id')
     //                {
     //                    $selectfields.= db_quote_id($surveytable) . '.' . db_quote_id($cs) . ", ";
     //                }
     //                elseif ($cs != 'completed')
     //                {
     //                    $selectfields.= db_quote_id($cs).", ";
     //                }
     //                else
     //                {
     //                    $selectfields.= "CASE WHEN $surveytable.submitdate IS NULL THEN 'N' ELSE 'Y' END AS completed, ";
     //                }
     //            }
     //            $selectfields = mb_substr($selectfields, 0, strlen($selectfields)-2);
     //        }
     //        else
     //        {
     $selectfields = "{$surveytable}.*, CASE WHEN {$surveytable}.submitdate IS NULL THEN 'N' ELSE 'Y' END AS completed";
     //        }
     $dquery = "SELECT {$selectfields}";
     /*if ($tokenTableExists && $this->survey->anonymized =='N' && isset($_POST['attribute_select']) && is_array($_POST['attribute_select']))
             {
                 if (in_array('first_name',$_POST['attribute_select']))
                 {
                     $dquery .= ", lime_tokens_$surveyid.firstname";
                 }
                 if (in_array('last_name',$_POST['attribute_select']))
                 {
                     $dquery .= ", lime_tokens_$surveyid.lastname";
                 }
                 if (in_array('email_address',$_POST['attribute_select']))
                 {
                     $dquery .= ", lime_tokens_$surveyid.email";
//.........这里部分代码省略.........
开发者ID:shnellpavel,项目名称:bcgroup_lk,代码行数:101,代码来源:ExcelExportSurveyHelper.php

示例15: exportToXls

 public static function exportToXls($data, $file = false, $alignments = array())
 {
     require_once 'Spreadsheet/Excel/Writer.php';
     $workBook = new Spreadsheet_Excel_Writer($file);
     $workBook->setTempDir(G_UPLOADPATH);
     $workBook->setVersion(8);
     $workSheet =& $workBook->addWorksheet('info');
     $workSheet->setInputEncoding('utf-8');
     $columnIndex = 0;
     foreach (current($data) as $key => $value) {
         $maxColumnWidths[$columnIndex][] = mb_strlen($key);
         $alignments[$columnIndex] ? $align = $alignments[$columnIndex] : ($align = 'left');
         $workSheet->write(0, $columnIndex++, $key, $workBook->addFormat(array('HAlign' => $align, 'Size' => 11, 'Bold' => 1)));
     }
     $rowIndex = 1;
     foreach ($data as $rowData) {
         $columnIndex = 0;
         foreach ($rowData as $cell) {
             $maxColumnWidths[$columnIndex][] = mb_strlen($cell);
             if ($alignments[$columnIndex]) {
                 $align = $alignments[$columnIndex];
                 $workSheet->write($rowIndex, $columnIndex++, $cell, $workBook->addFormat(array('HAlign' => $align)));
             } else {
                 $workSheet->write($rowIndex, $columnIndex++, $cell);
             }
         }
         $rowIndex++;
     }
     foreach ($maxColumnWidths as $columnIndex => $widths) {
         $workSheet->setColumn($columnIndex, $columnIndex, max($widths) + 2);
     }
     $workBook->close();
     if (!$file) {
         $workBook->send('export.xls');
     }
 }
开发者ID:bqq1986,项目名称:efront,代码行数:36,代码来源:system.class.php


注:本文中的Spreadsheet_Excel_Writer::setTempDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。