Example #1
0
     * @see pack()
     * @param integer $value The value to write out
     * @return nothing
     */
    function number($value)
    {
        $this->data .= pack("sssss", 0x203, 14, $this->row, $this->col, 0x0);
        $this->data .= pack("d", $value);
    }
    /**
     * Writes a string (or label) to the Excel Spreadsheet
     * @see pack()
     * @param string $value The value to write out
     * @return nothing
     */
    function label($value)
    {
        $length = strlen($value);
        $this->data .= pack("ssssss", 0x204, 8 + $length, $this->row, $this->col, 0x0, $length);
        $this->data .= $value;
    }
}
$filename = 'testcreate';
$excel = new Excel($filename);
$excel->label('hello');
$excel->right();
$excel->label('helloasdasd');
$excel->send();
echo '<pre>';
print_r($excel);
echo '</pre>';
 public function exportIt($return)
 {
     return parent::exportIt($return);
     $filename = $return['classname'] . "_" . date('Ymd');
     $xls = new Excel($filename);
     //$filename = $return['classname'] . "_" . date('Ymd') . ".xls";
     //header("Content-Disposition: attachment; filename=\"$filename\"");
     //header("Content-Type: application/vnd.ms-excel");
     //$flag = false;
     $xls->home();
     foreach ($return['objs'] as $key => $obj) {
         foreach ($obj as $name => $value) {
             $xls->label(Lang::t($name));
             $xls->right();
         }
         break;
     }
     $xls->down();
     //print("\n");
     foreach ($return['objs'] as $key => $obj) {
         $xls->home();
         foreach ($obj as $name => $value) {
             $xls->label($value);
             $xls->right();
         }
         $xls->down();
     }
     $xls->send();
     exit;
 }
function excel_encode($response)
{
    $xls = new Excel('verifier-search');
    $xls->home();
    $xls->label('state fips');
    $xls->right();
    $xls->label('state');
    $xls->right();
    $xls->label('precincts');
    $xls->down();
    foreach ($response['codes'] as $row) {
        $xls->home();
        $xls->label($row['state_fips']);
        $xls->right();
        $xls->label($row['name']);
        $xls->right();
        $xls->label($row['precincts']);
        $xls->down();
    }
    $xls->send();
}
 public function exportIt()
 {
     $data = isset($_SESSION["data"]) ? addslashes($_SESSION['data']) : "";
     //        $dec = json_decode($data);
     $arrData = $_SESSION['data'];
     unset($_SESSION['data']);
     $filename = date('Ymd') . ".xls";
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     header("Content-Type: application/vnd.ms-excel");
     $xls = new Excel($filename);
     $xls->home();
     //        pr($arrData);
     foreach ($arrData as $key => $obj) {
         foreach ($obj as $name => $value) {
             $xls->label(Lang::t($name));
             $xls->right();
         }
         break;
     }
     $xls->down();
     foreach ($arrData as $key => $obj) {
         $xls->home();
         foreach ($obj as $name => $value) {
             if ($name == "dateOrder") {
                 $date = new DateTime($value);
                 $xls->label($date->format('d.m.Y'));
             } elseif ($name == "timeOrder") {
                 $date = new DateTime($value);
                 $xls->label($date->format('H:i:s'));
             } else {
                 $xls->label($value);
             }
             $xls->right();
         }
         $xls->down();
     }
     $xls->send();
     exit;
 }
Example #5
0
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();
    }
}
Example #6
0
 public function send()
 {
     $this->writer->send();
 }