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


PHP Excel::top方法代码示例

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


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

示例1: write_excel1

function write_excel1($quarter, $dept)
{
    $xls = new Excel('TAData');
    $xls->home();
    $xls->top();
    $xls->label("Name");
    $xls->right();
    $xls->label("Likes");
    $xls->right();
    $xls->label("Hates");
    $xls->right();
    $xls->label("Conflicts");
    $xls->right();
    $xls->label("# Classes Taught");
    $xls->right();
    $xls->label("Ranking");
    $xls->right();
    $xls->label("Units");
    $xls->right();
    $xls->label("%");
    $xls->home();
    $xls->down();
    $db = new PDO(DB_PATH, DB_LOGIN, DB_PW);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    try {
        //for each TA we need to gather the prefs and blacklist not given in the input file.
        $sql = "SELECT * from ta WHERE department = \"{$dept}\";";
        $results = $db->query($sql);
        foreach ($results as $re) {
            //The headers are as seen above. We tackle each in turn.
            $xls->label($re['name_full']);
            $xls->right();
            $prefs = get_prefs($re['sid'], $quarter);
            $likes = array();
            $dislikes = array();
            for ($i = 0; $i < count($prefs); $i++) {
                if ($prefs[$i]->value > 50) {
                    array_push($likes, $prefs[$i]);
                } else {
                    if ($prefs[$i]->value < 50) {
                        array_push($dislikes, $prefs[$i]);
                    }
                }
                usort($likes, prefcmp);
                usort($dislikes, prefcmpr);
            }
            $likes_full = "";
            for ($i = 0; $i < count($likes) - 1; $i++) {
                $likes_full .= $likes[$i]->section;
                $likes_full .= ", ";
            }
            $likes_full .= $likes[count($likes) - 1]->section;
            //   if($re['sid'] == 6260) puts($likes_full);
            $dislikes_full = "";
            for ($i = 0; $i < count($dislikes) - 1; $i++) {
                $dislikes_full .= $dislikes[$i]->section;
                $dislikes_full .= ", ";
            }
            $dislikes_full .= $dislikes[count($dislikes) - 1]->section;
            //   if($re['sid'] == 6260) puts($dislikes_full);
            $xls->label($likes_full);
            $xls->right();
            $xls->label($dislikes_full);
            $xls->right();
            //Now conflicts. This should be as simple as adding together all the events of TA.
            $sql2 = 'SELECT e.start, e.end, e.day FROM event e, calendar c WHERE c.id_event=e.id
               AND c.id_ta = ' . $re['sid'] . ' AND e.id_quarter = ' . $quarter . ';';
            $result2 = $db->query($sql2);
            $conflict_full = "";
            foreach ($result2 as $r2) {
                $conflict_full .= $r2['day'] . ' ' . round($r2['start'] / 100) . '-' . round($r2['end'] / 100) . ', ';
            }
            $conflict_full = substr($conflict_full, 0, -2);
            //   if($re['sid'] == 6260) puts($conflict_full);
            $xls->label($conflict_full);
            $xls->right();
            $u = $re['units'];
            $xls->label((int) ($u / 2));
            $xls->right();
            $xls->label($re['rank']);
            $xls->right();
            $xls->label((int) $u);
            $xls->right();
            $xls->label((int) ($u * 12.5));
            $xls->down();
            $xls->home();
            //  puts($re['name_full']."|".$likes_full);
            //  print_r($likes);
            //  print_r($dislikes);
        }
        $xls->send();
    } catch (PDOException $e) {
        echo $e->getMessage();
    }
}
开发者ID:Quiksilver626,项目名称:tamatch,代码行数:95,代码来源:functions.php


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