开发者

How to create xls file after success to generate to excel file

I have the code like this :

<?php
include "ExcelUtil.php";
include "admin/doconnect.php";

class ExcelGenerator {
    var $xls;

    function ExcelGenerator() 
    {
        $this->xls = new ExcelUtil();
    }
function saveToExcel($pageFunction, $searchdate1, $searchdate2, $person, $type, $ewonumber, $device1, $device2, $subjectx) 

    {     开发者_如何学JAVA   
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/vnd.ms-excel");
    header("Content-type: application/x-msexcel");
        header ("Content-Description: PHP/INTERBASE Generated Data");
        header("Content-Disposition: attachment;filename=Reportxls");
        header("Content-Transfer-Encoding: binary ");

$query = "select * from activity WHERE actiondate BETWEEN '$tanggal' AND '$now' order by actiondate DESC";
    $hasil = mssql_query($query);

    echo "<table width=\"97%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">";
    echo "<tr>";
    echo "<th>Action Date</th>";
    echo "<th>Person</th>";
    echo "<th>Subject</th>";
    echo "<th>EWO Number / TR Number</th>";
    echo "<th>Category</th>";
    echo "<th>Device</th>";
    echo "<th>Status</th>";
    echo "</tr>";
    while ($data = mssql_fetch_array($hasil))
    {
        echo "<tr valign='top'>";
        echo "<td class=\"isitabel\" align='center'>$data[actiondate]</td>";
        echo "<td class=\"isitabel\" align='left'>$data[person]</td>";
        echo "<td class=\"isitabel\" align='left'>$data[subject]</td>";
            if ($data[tr_number]=="" || $data[tr_number]=="-") {
            $data[tr_number] = "";
            }else if ($data[ewo_number]=="" || $data[ewo_number]=="-") {
                $data[ewo_number] = "";
                    }
        echo "<td class=\"isitabel\"align='center'>$data[ewo_number]$data[tr_number]</td>";
        echo "<td class=\"isitabel\" align='center'>$data[category]</td>";
        echo "<td class=\"isitabel\" align='center'>$data[device]</td>";
        echo "<td class=\"isitabel\" align='center'>$data[status]</td>";
        echo "</tr>";
        }
    echo "</table>";
    }
}

$generator = new ExcelGenerator();
$generator->saveToExcel();
?>

From that code, I have successfully convert to xls file with the name = Report.xls when download prompt appear.

In my case, I want to give some code to write its xls file to my directory (C:/) automatically without user must click "Save" on download prompt.

Can someone help me, please?


No, you can't do this of course.

Can you imagine the security flaw in that idea?


It is not possible to do that. The user must confirm the file download.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜