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


PHP MoodleExcelWorkbook::add_format方法代码示例

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


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

示例1: export

 /**
  * Export a report in this format
  *
  * @param  string  $query         Final form of the main report query
  * @param  string  $storage_path  Path on the file system to save the output to,
  *                                or NULL if sending to browser
  * @param  $filename              Filename to use when sending to browser
  */
 function export($query, $storage_path, $filename)
 {
     global $CFG;
     require_once $CFG->libdir . '/excellib.class.php';
     $filename .= '.xls';
     /// Creating a workbook
     $workbook = new MoodleExcelWorkbook('-');
     /// Sending HTTP headers
     $workbook->send($filename);
     /// Creating the first worksheet
     $sheettitle = get_string('studentprogress', 'reportstudentprogress');
     $myxls =& $workbook->add_worksheet($sheettitle);
     /// Format types
     $format =& $workbook->add_format();
     $format->set_bold(0);
     $formatbc =& $workbook->add_format();
     $formatbc->set_bold(1);
     $formatbc->set_align('center');
     $formatb =& $workbook->add_format();
     $formatb->set_bold(1);
     $formaty =& $workbook->add_format();
     $formaty->set_bg_color('yellow');
     $formatc =& $workbook->add_format();
     $formatc->set_align('center');
     $formatr =& $workbook->add_format();
     $formatr->set_bold(1);
     $formatr->set_color('red');
     $formatr->set_align('center');
     $formatg =& $workbook->add_format();
     $formatg->set_bold(1);
     $formatg->set_color('green');
     $formatg->set_align('center');
     $rownum = 0;
     $colnum = 0;
     foreach ($this->report->headers as $header) {
         $myxls->write($rownum, $colnum++, $header, $formatbc);
     }
     foreach ($this->report->data as $datum) {
         if (!is_object($datum)) {
             continue;
         }
         $rownum++;
         $colnum = 0;
         foreach ($this->headers as $id => $header) {
             if (isset($datum->{$id})) {
                 $myxls->write($rownum, $colnum++, $datum->{$id}, $format);
             } else {
                 $myxls->write($rownum, $colnum++, '', $format);
             }
         }
     }
     $workbook->close();
 }
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:61,代码来源:php_report_export_excel.class.php

示例2: stdClass

        }
        $attempt = new stdClass();
        $attempt->passed = $passed;
        $attempt->persent = $newpoint;
        $attempt->id = $ida->id;
        $DB->update_record('reader_attempts', $attempt);
    }
    $adjustscorestext = get_string('done', 'reader');
}
/*
* EXCEL
*/
if ($excel) {
    $workbook = new MoodleExcelWorkbook("-");
    $myxls =& $workbook->add_worksheet('report');
    $format =& $workbook->add_format();
    $format->set_bold(0);
    $formatbc =& $workbook->add_format();
    $formatbc->set_bold(1);
    if (!empty($grid)) {
        $grname = groups_get_group_name($grid);
    } else {
        $grname = "all";
    }
    $exceldata['time'] = date("d.M.Y");
    $exceldata['course_shotname'] = str_replace(" ", "-", $course->shortname);
    $exceldata['groupname'] = str_replace(" ", "-", $grname);
    if ($act != "exportstudentrecords") {
        $workbook->send('report_' . $exceldata['time'] . '_' . $exceldata['course_shotname'] . '_' . $exceldata['groupname'] . '.xls');
    } else {
        header("Content-Type: text/plain; filename=\"{$COURSE->shortname}_attempts.txt\"");
开发者ID:e-rasvet,项目名称:reader,代码行数:31,代码来源:admin.php

示例3: facetoface_download_xls

/** Download data in XLS format
  *
  * @param array $fields Array of column headings
  * @param string $datarows Array of data to populate table with
  * @param string $file Name of file for exportig
  * @return Returns the Excel file
  */
function facetoface_download_xls($fields, $datarows, $file=null) {
    global $CFG, $DB;

    require_once($CFG->libdir . '/excellib.class.php');

    $filename = clean_filename($file . '.xls');

    header("Content-Type: application/download\n");
    header("Content-Disposition: attachment; filename=$filename");
    header("Expires: 0");
    header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
    header("Pragma: public");

    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);

    $worksheet = array();

    $worksheet[0] = $workbook->add_worksheet('');
    $row = 0;
    $col = 0;
    $dateformat = $workbook->add_format();
    $dateformat->set_num_format('dd mmm yyyy');
    $datetimeformat = $workbook->add_format();
    $datetimeformat->set_num_format('dd mmm yyyy h:mm');

    foreach ($fields as $field) {
        $worksheet[0]->write($row, $col, strip_tags($field));
        $col++;
    }
    $row++;

    $numfields = count($fields);

    foreach ($datarows as $record) {
        for ($col=0; $col<$numfields; $col++) {
            $worksheet[0]->write($row, $col, html_entity_decode($record[$col], ENT_COMPAT, 'UTF-8'));
        }
        $row++;
    }

    $workbook->close();
    die;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:51,代码来源:lib.php

示例4: MoodleExcelWorkbook

         $colnum++;
     }
     $rownum = 1;
 } else {
     if ($download == 'Excel') {
         require_once "{$CFG->libdir}/excellib.class.php";
         $filename .= ".xls";
         // Creating a workbook
         $workbook = new MoodleExcelWorkbook("-");
         // Sending HTTP headers
         $workbook->send($filename);
         // Creating the first worksheet
         $sheettitle = get_string('report', 'scorm');
         $myxls =& $workbook->add_worksheet($sheettitle);
         // format types
         $format =& $workbook->add_format();
         $format->set_bold(0);
         $formatbc =& $workbook->add_format();
         $formatbc->set_bold(1);
         $formatbc->set_align('center');
         $formatb =& $workbook->add_format();
         $formatb->set_bold(1);
         $formaty =& $workbook->add_format();
         $formaty->set_bg_color('yellow');
         $formatc =& $workbook->add_format();
         $formatc->set_align('center');
         $formatr =& $workbook->add_format();
         $formatr->set_bold(1);
         $formatr->set_color('red');
         $formatr->set_align('center');
         $formatg =& $workbook->add_format();
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:report.php

示例5: display


//.........这里部分代码省略.........
         $table = new offlinequiz_results_table('mod-offlinequiz-report-overview-report', $params);
         $table->define_columns($tablecolumns);
         $table->define_headers($tableheaders);
         $table->define_baseurl($CFG->wwwroot . '/mod/offlinequiz/report.php?mode=overview&amp;id=' . $cm->id . '&amp;noresults=' . $noresults . '&amp;pagesize=' . $pagesize);
         $table->sortable(true);
         $table->no_sorting('checkbox');
         if ($withparticipants) {
             $table->no_sorting('checked');
         }
         $table->column_suppress('picture');
         $table->column_suppress('fullname');
         $table->column_class('picture', 'picture');
         $table->column_class($offlinequizconfig->ID_field, 'userkey');
         $table->column_class('timestart', 'timestart');
         $table->column_class('offlinegroupid', 'offlinegroupid');
         $table->column_class('sumgrades', 'sumgrades');
         $table->set_attribute('cellpadding', '2');
         $table->set_attribute('id', 'attempts');
         $table->set_attribute('class', 'generaltable generalbox');
         // Start working -- this is necessary as soon as the niceties are over.
         $table->setup();
     } else {
         if ($download == 'ODS') {
             require_once "{$CFG->libdir}/odslib.class.php";
             $filename .= ".ods";
             // Creating a workbook.
             $workbook = new MoodleODSWorkbook("-");
             // Sending HTTP headers.
             $workbook->send($filename);
             // Creating the first worksheet.
             $sheettitle = get_string('reportoverview', 'offlinequiz');
             $myxls = $workbook->add_worksheet($sheettitle);
             // Format types.
             $format = $workbook->add_format();
             $format->set_bold(0);
             $formatbc = $workbook->add_format();
             $formatbc->set_bold(1);
             $formatbc->set_align('center');
             $formatb = $workbook->add_format();
             $formatb->set_bold(1);
             $formaty = $workbook->add_format();
             $formaty->set_bg_color('yellow');
             $formatc = $workbook->add_format();
             $formatc->set_align('center');
             $formatr = $workbook->add_format();
             $formatr->set_bold(1);
             $formatr->set_color('red');
             $formatr->set_align('center');
             $formatg = $workbook->add_format();
             $formatg->set_bold(1);
             $formatg->set_color('green');
             $formatg->set_align('center');
             // Here starts workshhet headers.
             $headers = array(get_string($offlinequizconfig->ID_field), get_string('firstname'), get_string('lastname'), get_string('importedon', 'offlinequiz'), get_string('group'), get_string('grade', 'offlinequiz'));
             if (!empty($withparticipants)) {
                 $headers[] = get_string('present', 'offlinequiz');
             }
             $colnum = 0;
             foreach ($headers as $item) {
                 $myxls->write(0, $colnum, $item, $formatbc);
                 $colnum++;
             }
             $rownum = 1;
         } else {
             if ($download == 'Excel') {
                 require_once "{$CFG->libdir}/excellib.class.php";
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:67,代码来源:report.php

示例6: array

} else {
    $filename .= "AllPartners_";
}
if ($shid != 0) {
    $scheduler = $DB->get_record("scheduler", array("id" => $shid));
    $filename .= $scheduler->name . "_";
}
$filename .= date("Ymd", time());
$filename .= ".xls";
$workbook = new MoodleExcelWorkbook("-");
/// Sending HTTP headers
$workbook->send($filename);
/// Creating the first worksheet
$myxls =& $workbook->add_worksheet('Show appointments');
/// format types
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$myxls->write(0, 0, 'Group', $formatbc);
$myxls->write(0, 1, 'Partner', $formatbc);
$myxls->write(0, 2, 'Given name', $formatbc);
$myxls->write(0, 3, 'Family name', $formatbc);
$myxls->write(0, 4, 'Username', $formatbc);
$myxls->write(0, 5, 'Date/Time (partner)', $formatbc);
$myxls->write(0, 6, 'Date/Time (student)', $formatbc);
$myxls->write(0, 7, 'Scheduler', $formatbc);
$myxls->write(0, 8, 'Comment', $formatbc);
$data = array();
$datareport = array();
$datareport2 = array();
$users = array();
$appointmentarray = array();
开发者ID:e-rasvet,项目名称:showappts,代码行数:31,代码来源:export.old.php

示例7: display


//.........这里部分代码省略.........
             foreach ($nosort as $field) {
                 $table->no_sorting($field);
             }
             $table->no_sorting('start');
             $table->no_sorting('finish');
             $table->no_sorting('score');
             $table->no_sorting('checkbox');
             $table->no_sorting('picture');
             foreach ($scoes as $sco) {
                 if ($sco->launch != '') {
                     $table->no_sorting('scograde' . $sco->id);
                 }
             }
             $table->column_class('picture', 'picture');
             $table->column_class('fullname', 'bold');
             $table->column_class('score', 'bold');
             $table->set_attribute('cellspacing', '0');
             $table->set_attribute('id', 'attempts');
             $table->set_attribute('class', 'generaltable generalbox');
             // Start working -- this is necessary as soon as the niceties are over.
             $table->setup();
         } else {
             if ($download == 'ODS') {
                 require_once "{$CFG->libdir}/odslib.class.php";
                 $filename .= ".ods";
                 // Creating a workbook.
                 $workbook = new \MoodleODSWorkbook("-");
                 // Sending HTTP headers.
                 $workbook->send($filename);
                 // Creating the first worksheet.
                 $sheettitle = get_string('report', 'scorm');
                 $myxls = $workbook->add_worksheet($sheettitle);
                 // Format types.
                 $format = $workbook->add_format();
                 $format->set_bold(0);
                 $formatbc = $workbook->add_format();
                 $formatbc->set_bold(1);
                 $formatbc->set_align('center');
                 $formatb = $workbook->add_format();
                 $formatb->set_bold(1);
                 $formaty = $workbook->add_format();
                 $formaty->set_bg_color('yellow');
                 $formatc = $workbook->add_format();
                 $formatc->set_align('center');
                 $formatr = $workbook->add_format();
                 $formatr->set_bold(1);
                 $formatr->set_color('red');
                 $formatr->set_align('center');
                 $formatg = $workbook->add_format();
                 $formatg->set_bold(1);
                 $formatg->set_color('green');
                 $formatg->set_align('center');
                 // Here starts workshhet headers.
                 $colnum = 0;
                 foreach ($headers as $item) {
                     $myxls->write(0, $colnum, $item, $formatbc);
                     $colnum++;
                 }
                 $rownum = 1;
             } else {
                 if ($download == 'Excel') {
                     require_once "{$CFG->libdir}/excellib.class.php";
                     $filename .= ".xls";
                     // Creating a workbook.
                     $workbook = new \MoodleExcelWorkbook("-");
                     // Sending HTTP headers.
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:report.php

示例8: display


//.........这里部分代码省略.........
         }
         if (!$download) {
             // Set up the table
             $table = new flexible_table('mod-quiz-report-overview-report');
             $table->define_columns($columns);
             $table->define_headers($headers);
             $table->define_baseurl($reporturlwithdisplayoptions->out());
             $table->sortable(true);
             $table->collapsible(true);
             $table->column_suppress('picture');
             $table->column_suppress('fullname');
             $table->column_suppress('idnumber');
             $table->no_sorting('feedbacktext');
             $table->column_class('picture', 'picture');
             $table->column_class('fullname', 'bold');
             $table->column_class('sumgrades', 'bold');
             $table->set_attribute('cellspacing', '0');
             $table->set_attribute('id', 'attempts');
             $table->set_attribute('class', 'generaltable generalbox');
             // Start working -- this is necessary as soon as the niceties are over
             $table->setup();
         } else {
             if ($download == 'ODS') {
                 require_once "{$CFG->libdir}/odslib.class.php";
                 $filename .= ".ods";
                 // Creating a workbook
                 $workbook = new MoodleODSWorkbook("-");
                 // Sending HTTP headers
                 $workbook->send($filename);
                 // Creating the first worksheet
                 $sheettitle = get_string('reportoverview', 'quiz');
                 $myxls =& $workbook->add_worksheet($sheettitle);
                 // format types
                 $format =& $workbook->add_format();
                 $format->set_bold(0);
                 $formatbc =& $workbook->add_format();
                 $formatbc->set_bold(1);
                 $formatbc->set_align('center');
                 $formatb =& $workbook->add_format();
                 $formatb->set_bold(1);
                 $formaty =& $workbook->add_format();
                 $formaty->set_bg_color('yellow');
                 $formatc =& $workbook->add_format();
                 $formatc->set_align('center');
                 $formatr =& $workbook->add_format();
                 $formatr->set_bold(1);
                 $formatr->set_color('red');
                 $formatr->set_align('center');
                 $formatg =& $workbook->add_format();
                 $formatg->set_bold(1);
                 $formatg->set_color('green');
                 $formatg->set_align('center');
                 // Here starts workshhet headers
                 $colnum = 0;
                 foreach ($headers as $item) {
                     $myxls->write(0, $colnum, $item, $formatbc);
                     $colnum++;
                 }
                 $rownum = 1;
             } else {
                 if ($download == 'Excel') {
                     require_once "{$CFG->libdir}/excellib.class.php";
                     $filename .= ".xls";
                     // Creating a workbook
                     $workbook = new MoodleExcelWorkbook("-");
                     // Sending HTTP headers
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:67,代码来源:report.php

示例9: offlinequiz_download_partlist

/**
 * Serves a list of participants as a file.
 *
 * @param unknown_type $offlinequiz
 * @param unknown_type $fileformat
 * @param unknown_type $coursecontext
 * @param unknown_type $systemcontext
 */
function offlinequiz_download_partlist($offlinequiz, $fileformat, &$coursecontext, &$systemcontext)
{
    global $CFG, $DB, $COURSE;
    offlinequiz_load_useridentification();
    $offlinequizconfig = get_config('offlinequiz');
    $filename = clean_filename(get_string('participants', 'offlinequiz') . $offlinequiz->id);
    // First get roleids for students from leagcy.
    if (!($roles = get_roles_with_capability('mod/offlinequiz:attempt', CAP_ALLOW, $systemcontext))) {
        print_error("No roles with capability 'mod/offlinequiz:attempt' defined in system context");
    }
    $roleids = array();
    foreach ($roles as $role) {
        $roleids[] = $role->id;
    }
    list($csql, $cparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
    list($rsql, $rparams) = $DB->get_in_or_equal($roleids, SQL_PARAMS_NAMED, 'role');
    $params = array_merge($cparams, $rparams);
    $sql = "SELECT p.id, p.userid, p.listid, u." . $offlinequizconfig->ID_field . ", u.firstname, u.lastname,\n                   u.alternatename, u.middlename, u.firstnamephonetic, u.lastnamephonetic,\n                   u.picture, p.checked\n             FROM {offlinequiz_participants} p,\n                  {offlinequiz_p_lists} pl,\n                  {user} u,\n                  {role_assignments} ra\n            WHERE p.listid = pl.id\n              AND p.userid = u.id\n              AND ra.userid=u.id\n              AND pl.offlinequizid = :offlinequizid\n              AND ra.contextid {$csql}\n              AND ra.roleid {$rsql}";
    $params['offlinequizid'] = $offlinequiz->id;
    // Define table headers.
    $tableheaders = array(get_string('fullname'), get_string($offlinequizconfig->ID_field), get_string('participantslist', 'offlinequiz'), get_string('attemptexists', 'offlinequiz'), get_string('present', 'offlinequiz'));
    if ($fileformat == 'ODS') {
        require_once "{$CFG->libdir}/odslib.class.php";
        $filename .= ".ods";
        // Creating a workbook.
        $workbook = new MoodleODSWorkbook("-");
        // Sending HTTP headers.
        $workbook->send($filename);
        // Creating the first worksheet.
        $sheettitle = get_string('participants', 'offlinequiz');
        $myxls = $workbook->add_worksheet($sheettitle);
        // Format types.
        $format = $workbook->add_format();
        $format->set_bold(0);
        $formatbc = $workbook->add_format();
        $formatbc->set_bold(1);
        $formatbc->set_align('center');
        $formatb = $workbook->add_format();
        $formatb->set_bold(1);
        $formaty = $workbook->add_format();
        $formaty->set_bg_color('yellow');
        $formatc = $workbook->add_format();
        $formatc->set_align('center');
        $formatr = $workbook->add_format();
        $formatr->set_bold(1);
        $formatr->set_color('red');
        $formatr->set_align('center');
        $formatg = $workbook->add_format();
        $formatg->set_bold(1);
        $formatg->set_color('green');
        $formatg->set_align('center');
        // Print worksheet headers.
        $colnum = 0;
        foreach ($tableheaders as $item) {
            $myxls->write(0, $colnum, $item, $formatbc);
            $colnum++;
        }
        $rownum = 1;
    } else {
        if ($fileformat == 'Excel') {
            require_once "{$CFG->libdir}/excellib.class.php";
            $filename .= ".xls";
            // Creating a workbook.
            $workbook = new MoodleExcelWorkbook("-");
            // Sending HTTP headers.
            $workbook->send($filename);
            // Creating the first worksheet.
            $sheettitle = get_string('participants', 'offlinequiz');
            $myxls = $workbook->add_worksheet($sheettitle);
            // Format types.
            $format = $workbook->add_format();
            $format->set_bold(0);
            $formatbc = $workbook->add_format();
            $formatbc->set_bold(1);
            $formatbc->set_align('center');
            $formatb = new StdClass();
            $formatb = $workbook->add_format();
            $formatb->set_bold(1);
            $formaty = $workbook->add_format();
            $formaty->set_bg_color('yellow');
            $formatc = $workbook->add_format();
            $formatc->set_align('center');
            $formatr = $workbook->add_format();
            $formatr->set_bold(1);
            $formatr->set_color('red');
            $formatr->set_align('center');
            $formatg = $workbook->add_format();
            $formatg->set_bold(1);
            $formatg->set_color('green');
            $formatg->set_align('center');
            // Print worksheet headers.
            $colnum = 0;
//.........这里部分代码省略.........
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:101,代码来源:locallib.php

示例10: ExportToExcel

function ExportToExcel($data)
{
    global $CFG;
    //require_once("$CFG->libdir/excellib.class.php");/*
    require_once $CFG->dirroot . '/lib/excellib.class.php';
    $filename = "EMBA_students_reg_report:.xls";
    $workbook = new MoodleExcelWorkbook("-");
    /// Sending HTTP headers
    ob_clean();
    $workbook->send($filename);
    /// Creating the first worksheet
    $myxls =& $workbook->add_worksheet('EMBA_reg_report');
    /// format types
    $formatbc =& $workbook->add_format();
    $formatbc->set_bold(1);
    $header1 =& $workbook->add_format();
    $header1->set_bold(1);
    // Make it bold
    $header1->set_align('center');
    // Align text to center
    $header1->set_size(14);
    //$header1->set_fg_color(22);
    $header2 =& $workbook->add_format();
    $header2->set_bold(1);
    // Make it bold
    $header2->set_align('center');
    // Align text to center
    $header2->set_size(12);
    //$header2->set_fg_color(23);
    $normal =& $workbook->add_format();
    $normal->set_bold(0);
    $normal->set_align('center');
    $normal->set_size(10);
    $name =& $workbook->add_format();
    $name->set_bold(0);
    $name->set_size(10);
    $grey_code_f =& $workbook->add_format();
    $grey_code_f->set_bold(0);
    // Make it bold
    $grey_code_f->set_size(12);
    $grey_code_f->set_fg_color(22);
    $grey_code_f->set_align('center');
    //$formatbc->set_size(14);
    $myxls->write(1, 0, "EMBA Students Registration Report", $header1);
    $myxls->write(4, 0, 'Duration');
    $myxls->write(4, 1, $data->duration, $formatbc);
    $i = 6;
    $j = 0;
    foreach ($data->head as $heading) {
        $heading = str_replace('<br/>', '', $heading);
        $heading = trim($heading);
        $myxls->write_string($i, $j, $heading, $header2);
        // $myxls->set_column($pos,$pos,(strlen($grade_item->get_name()))+4);
        $col_size = strlen($heading);
        $col_size += 6;
        if (preg_match('/^NAME/i', $heading)) {
            $col_size = 20;
        }
        $myxls->set_column($j, $j, $col_size);
        $j++;
    }
    $myxls->merge_cells(1, 0, 1, $j - 1);
    $myxls->merge_cells(2, 0, 2, $j - 1);
    $myxls->merge_cells(4, 1, 4, 3);
    $myxls->set_row(1, 25);
    $i = 7;
    $j = 0;
    foreach ($data->data as $row) {
        foreach ($row as $cell) {
            //$myxls->write($i, $j++, $cell);
            if (is_numeric($cell)) {
                //if($cell>25.99){
                //	$myxls->write_number($i, $j++, $cell,$grey_code_f);
                //}
                //else{
                $myxls->write_number($i, $j++, $cell, $normal);
                //}
            } else {
                if (preg_match('/^!!/', $cell)) {
                    $cell = str_replace("!!", '', $cell);
                    $myxls->write_string($i, $j++, $cell, $grey_code_f);
                } else {
                    if ($j == 2) {
                        $myxls->write_string($i, $j++, $cell, $name);
                    } else {
                        $myxls->write_string($i, $j++, $cell, $normal);
                    }
                }
            }
        }
        $i++;
        $j = 0;
    }
    $workbook->close();
    exit;
}
开发者ID:nustlms,项目名称:moodle-block_custom_reports,代码行数:96,代码来源:std_reg_report.php

示例11: fill_workbook

 /**
  * fills workbook (either XLS or ODS) with data
  *
  * @param MoodleExcelWorkbook $workbook workbook to put data into
  */
 public function fill_workbook(&$workbook)
 {
     global $DB;
     $time = time();
     $time = userdate($time);
     $worksheet = $workbook->add_worksheet($time);
     $headline_prop = array('size' => 12, 'bold' => 1, 'HAlign' => 'center', 'bottom' => 1, 'VAlign' => 'vcenter');
     $headline_format = $workbook->add_format($headline_prop);
     $headline_format->set_left(1);
     $headline_format->set_align('center');
     $headline_format->set_align('vcenter');
     $headline_first = $workbook->add_format($headline_prop);
     $headline_first->set_align('center');
     $headline_first->set_align('vcenter');
     unset($headline_prop['bottom']);
     $hdrleft = $workbook->add_format($headline_prop);
     $hdrleft->set_align('right');
     $hdrleft->set_align('vcenter');
     unset($headline_prop['bold']);
     $hdrright = $workbook->add_format($headline_prop);
     $hdrright->set_align('left');
     $hdrright->set_align('vcenter');
     $text_prop = array('size' => 10, 'align' => 'left');
     $text = $workbook->add_format($text_prop);
     $text->set_left(1);
     $text->set_align('vcenter');
     $text_first = $workbook->add_format($text_prop);
     $text_first->set_align('vcenter');
     $line = 0;
     //write header
     for ($i = 0; $i < count($this->header); $i += 2) {
         $worksheet->write_string($line, 0, $this->header[$i], $hdrleft);
         $worksheet->write_string($line, 1, $this->header[$i + 1], $hdrright);
         $line++;
     }
     $line++;
     // table header
     $i = 0;
     $first = true;
     foreach ($this->titles as $key => $header) {
         if ($first) {
             $worksheet->write_string($line, $i, $header, $headline_first);
             $first = false;
         } else {
             $worksheet->write_string($line, $i, $header, $headline_format);
             $first = false;
         }
         $i++;
     }
     // data
     $prev = $this->data[0];
     foreach ($this->data as $row) {
         $first = true;
         $line++;
         $i = 0;
         foreach ($row as $idx => $cell) {
             if (is_null($cell['data'])) {
                 $cell['data'] = $prev[$idx]['data'];
             }
             if ($first) {
                 $worksheet->write_string($line, $i, $cell['data'], $text_first);
                 $first = false;
             } else {
                 $worksheet->write_string($line, $i, $cell['data'], $text);
             }
             $prev[$idx] = $cell;
             $i++;
         }
     }
 }
开发者ID:miotto,项目名称:moodle-mod_organizer,代码行数:75,代码来源:mtablepdf.php

示例12: download

 /**
  * Get the data needed for a downloadable version of the report (all data,
  * no paging necessary) and format it accordingly for the download file
  * type.
  *
  * NOTE: It is expected that the valid format types will be overridden in
  * an extended report class as the array is empty by default.
  *
  * @param string $format A valid format type.
  */
 function download($format)
 {
     global $CFG;
     $output = '';
     if (empty($this->data)) {
         return $output;
     }
     $filename = !empty($this->title) ? $this->title : 'report_download';
     switch ($format) {
         case 'csv':
             $filename .= '.csv';
             header("Content-Transfer-Encoding: ascii");
             header("Content-Disposition: attachment; filename={$filename}");
             header("Content-Type: text/comma-separated-values");
             $row = array();
             foreach ($this->headers as $header) {
                 $row[] = $this->csv_escape_string(strip_tags($header));
             }
             echo implode(',', $row) . "\n";
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $row = array();
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $row[] = $this->csv_escape_string($datum->{$id});
                     } else {
                         $row[] = '""';
                     }
                 }
                 echo implode(',', $row) . "\n";
             }
             break;
         case 'excel':
             require_once $CFG->libdir . '/excellib.class.php';
             $filename .= '.xls';
             /// Creating a workbook
             $workbook = new MoodleExcelWorkbook('-');
             /// Sending HTTP headers
             $workbook->send($filename);
             /// Creating the first worksheet
             $sheettitle = get_string('studentprogress', 'reportstudentprogress');
             $myxls =& $workbook->add_worksheet($sheettitle);
             /// Format types
             $format =& $workbook->add_format();
             $format->set_bold(0);
             $formatbc =& $workbook->add_format();
             $formatbc->set_bold(1);
             $formatbc->set_align('center');
             $formatb =& $workbook->add_format();
             $formatb->set_bold(1);
             $formaty =& $workbook->add_format();
             $formaty->set_bg_color('yellow');
             $formatc =& $workbook->add_format();
             $formatc->set_align('center');
             $formatr =& $workbook->add_format();
             $formatr->set_bold(1);
             $formatr->set_color('red');
             $formatr->set_align('center');
             $formatg =& $workbook->add_format();
             $formatg->set_bold(1);
             $formatg->set_color('green');
             $formatg->set_align('center');
             $rownum = 0;
             $colnum = 0;
             foreach ($this->headers as $header) {
                 $myxls->write($rownum, $colnum++, $header, $formatbc);
             }
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $rownum++;
                 $colnum = 0;
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $myxls->write($rownum, $colnum++, $datum->{$id}, $format);
                     } else {
                         $myxls->write($rownum, $colnum++, '', $format);
                     }
                 }
             }
             $workbook->close();
             break;
         case 'pdf':
             require_once $CFG->libdir . '/fpdf/fpdf.php';
             $filename .= '.pdf';
             $newpdf = new FPDF('L', 'in', 'letter');
             $marginx = 0.75;
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:report.class.php

示例13: ExportToExcel

function ExportToExcel($data)
{
    global $CFG;
    global $modules;
    //require_once("$CFG->libdir/excellib.class.php");/*
    require_once $CFG->dirroot . '/lib/excellib.class.php';
    $filename = "Course_audit_report.xls";
    $workbook = new MoodleExcelWorkbook("-");
    /// Sending HTTP headers
    ob_clean();
    $workbook->send($filename);
    /// Creating the first worksheet
    $myxls =& $workbook->add_worksheet('Autid Report');
    /// format types
    $formatbc =& $workbook->add_format();
    $formatbc->set_bold(1);
    //$formatbc->set_size(14);
    $myxls->write(0, 3, "Audit SUMMARY", $formatbc);
    $myxls->write(1, 3, "ACTIVITIES RECORD", $formatbc);
    //	$myxls->write(3, 0, "Duration", $formatbc);
    $myxls->write(3, 1, $data->duration, $formatbc);
    $myxls->write_string(5, 0, "S.No", $formatbc);
    $myxls->write_string(5, 1, "Period", $formatbc);
    $myxls->write_string(5, 2, "Course Name", $formatbc);
    $myxls->write_string(5, 3, "Teacher Name", $formatbc);
    $myxls->write_string(5, 4, "Actitivties", $formatbc);
    $j = 5;
    foreach ($modules as $module) {
        if ($module == "attforblock") {
            $myxls->write_string(5, $j++, "Attendance", $formatbc);
        } else {
            $myxls->write_string(5, $j++, strtoupper($module), $formatbc);
        }
    }
    $i = 6;
    $j = 0;
    foreach ($data->data as $row) {
        foreach ($row as $cell) {
            //$myxls->write($i, $j++, $cell);
            if (is_numeric($cell)) {
                $myxls->write_number($i, $j++, strip_tags($cell));
            } else {
                $myxls->write_string($i, $j++, strip_tags($cell));
            }
        }
        $i++;
        $j = 0;
    }
    $workbook->close();
    exit;
}
开发者ID:nustlms,项目名称:moodle-block_custom_reports,代码行数:51,代码来源:audit.php

示例14: ExportToExcel

function ExportToExcel($data, $uname, $uidnumber)
{
    global $CFG, $USER;
    global $modules;
    //require_once("$CFG->libdir/excellib.class.php");/*
    require_once $CFG->dirroot . '/lib/excellib.class.php';
    $filename = "Student Semester Record.xls";
    $workbook = new MoodleExcelWorkbook("-");
    /// Sending HTTP headers
    ob_clean();
    $workbook->send($filename);
    /// Creating the first worksheet
    $myxls =& $workbook->add_worksheet('Students');
    /// format types
    $normal =& $workbook->add_format();
    $normal->set_bold(0);
    // Make it bold
    $normal->set_size(10);
    $normal->set_align('center');
    $formatbc =& $workbook->add_format();
    $formatbc->set_bold(1);
    $formatbc->set_align('center');
    $formatbc1 =& $workbook->add_format();
    $formatbc1->set_align('center');
    //$formatbc->set_size(14);
    $myxls->write(0, 3, "Student's Semester Record", $formatbc);
    $myxls->write(1, 3, "Name:" . $uname, $formatbc);
    $myxls->write(2, 3, "Registration Number:" . $uidnumber, $formatbc);
    $i = 4;
    $j = 0;
    $a = 0;
    foreach ($data->data as $row) {
        foreach ($row as $cell) {
            //$myxls->write($i, $j++, $cell);
            if (is_numeric($cell)) {
                if (preg_match('/^<b>/', $cell)) {
                    $myxls->write_number($i, $j++, strip_tags($cell), $formatbc);
                } else {
                    $myxls->write_number($i, $j++, strip_tags($cell), $formatbc1);
                }
            } else {
                if (preg_match('/^<b>/', $cell)) {
                    $myxls->write_string($i, $j++, strip_tags($cell), $formatbc);
                } else {
                    $myxls->write_string($i, $j++, strip_tags($cell), $formatbc1);
                }
            }
        }
        $i++;
        $j = 0;
    }
    $workbook->close();
    exit;
}
开发者ID:nustlms,项目名称:moodle-block_custom_reports,代码行数:54,代码来源:std_semestereport.php

示例15: generate_xls

function generate_xls($month, $year, $userid, $courseid, $method = 'I', $base = '')
{
    global $CFG, $DB;
    $monthinfo = get_month_info($month, $year);
    $workerrecord = $DB->get_record('block_timetracker_workerinfo', array('id' => $userid, 'courseid' => $courseid));
    if (!$workerrecord) {
        print_error('usernotexist', 'block_timetracker', $CFG->wwwroot . '/blocks/timetracker/index.php?id=' . $courseid);
    }
    //TODO -- change this to a filename, comment out 'send' function
    $fn = $year . '_' . ($month < 10 ? '0' . $month : $month) . 'Timesheet_' . substr($workerrecord->firstname, 0, 1) . $workerrecord->lastname . '_' . $workerrecord->mdluserid . '.xls';
    if ($method == 'F') {
        $workbook = new MoodleExcelWorkbook($base . '/' . $fn);
    } else {
        $workbook = new MoodleExcelWorkbook('-');
        $workbook->send($fn);
    }
    // Formatting
    $format_bold =& $workbook->add_format();
    $format_bold->set_bold();
    $format_cal_block =& $workbook->add_format();
    $format_cal_block->set_left(1);
    $format_cal_block->set_right(1);
    $format_cal_block->set_bottom(1);
    $format_cal_block->set_text_wrap();
    $format_cal_block->set_v_align('Top');
    $format_cal_block->set_size(8);
    $format_cal_total =& $workbook->add_format();
    $format_cal_total->set_align('center');
    $format_cal_total->set_bold();
    $format_cal_total->set_size(12);
    $format_cal_total->set_left(1);
    $format_cal_total->set_right(1);
    $format_cal_total->set_bottom(1);
    $format_calendar_dates =& $workbook->add_format();
    $format_calendar_dates->set_bold();
    $format_calendar_dates->set_align('center');
    $format_calendar_dates->set_size(8);
    $format_calendar_dates->set_left(1);
    $format_calendar_dates->set_right(1);
    $format_calendar_days =& $workbook->add_format();
    $format_calendar_days->set_bold();
    $format_calendar_days->set_align('center');
    $format_calendar_days->set_size(8);
    $format_calendar_days->set_fg_color(22);
    $format_calendar_days->set_border(1);
    $format_center =& $workbook->add_format();
    $format_center->set_align('center');
    $format_footer =& $workbook->add_format();
    $format_footer->set_bold();
    $format_footer->set_bottom(1);
    $format_footer->set_v_align('Top');
    $format_footer->set_text_wrap();
    $format_footer_block =& $workbook->add_format();
    $format_footer_block->set_bottom(1);
    $format_footer_block->set_top(1);
    $format_footer_block->set_left(1);
    $format_footer_block->set_right(1);
    $format_timesheet_header =& $workbook->add_format();
    $format_timesheet_header->set_bold();
    $format_timesheet_header->set_align('center');
    $format_timesheet_header->set_size(12);
    $format_timesheet_header->set_bottom(1);
    $format_title =& $workbook->add_format();
    $format_title->set_bold();
    $format_title->set_align('center');
    $format_title->set_size(12);
    $format_week_header =& $workbook->add_format();
    $format_week_header->set_bold();
    $format_week_header->set_align('center');
    $format_week_header->set_size(8);
    // Collect Data
    $mdluser = $DB->get_record('user', array('id' => $workerrecord->mdluserid));
    $conf = get_timetracker_config($courseid);
    $worksheet = array();
    $worksheet[1] =& $workbook->add_worksheet('First worksheet');
    // Set column widths
    $worksheet[1]->set_column(0, 8, 10.57);
    // Write data to spreadsheet
    $worksheet[1]->write_string(0, 0, 'Mars Hill College', $format_title);
    $worksheet[1]->merge_cells(0, 0, 0, 7);
    $worksheet[1]->write_string(1, 0, 'Timesheet - ' . $monthinfo['monthname'] . ', ' . $year, $format_timesheet_header);
    $worksheet[1]->merge_cells(1, 0, 1, 7);
    // Creates separator line under 'Timesheet'
    foreach (range(1, 7) as $i) {
        $worksheet[1]->write_blank(1, $i, $format_timesheet_header);
    }
    // Header Data
    $worksheet[1]->write_string(2, 0, 'WORKER: ' . strtoupper($workerrecord->lastname) . ', ' . strtoupper($workerrecord->firstname), $format_bold);
    $worksheet[1]->merge_cells(2, 0, 2, 3);
    $worksheet[1]->write_string(3, 0, "ID: {$mdluser->username}", $format_bold);
    $worksheet[1]->merge_cells(3, 0, 3, 3);
    $worksheet[1]->write_string(4, 0, "ADDRESS: {$workerrecord->address}", $format_bold);
    $worksheet[1]->merge_cells(4, 0, 4, 3);
    $worksheet[1]->write_string(5, 0, 'YTD Earnings: $' . number_format(get_earnings_this_year($userid, $courseid), 2), $format_bold);
    $worksheet[1]->merge_cells(5, 0, 5, 3);
    $worksheet[1]->write_string(2, 4, 'SUPERVISOR: ' . $conf['supname'], $format_bold);
    $worksheet[1]->merge_cells(2, 4, 2, 7);
    $worksheet[1]->write_string(3, 4, 'DEPARTMENT: ' . $conf['department'], $format_bold);
    $worksheet[1]->merge_cells(3, 4, 3, 7);
    $worksheet[1]->write_string(4, 4, 'POSITION: ' . $conf['position'], $format_bold);
//.........这里部分代码省略.........
开发者ID:hughesbradc,项目名称:TimeTracker,代码行数:101,代码来源:timesheet_xls.php


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