|
|
|
|
|
для: cheops
(29.09.2009 в 16:53)
| | есть форма с кнопкой
<form name="form1" method="get" action="pdv_xls_11.php" class="style1">
<input type="Submit" name="ok" Value="Excel" ><br><br>
<label>
<textarea name="textarea" cols="100" rows="10" wrap="off" id="textarea"><?php echo $sql ?></textarea>
</label>
<input name="param1" type="hidden" value="<? echo $date_data ?>" >
</form>
|
по которой должен запустится файл XLS,
файл pdv_xls_11.php содержит следующий код:
<?php
require_once "Spreadsheet/Excel/Writer.php";
$xls =& new Spreadsheet_Excel_Writer();
$xls->send("result.xls");
$sheet =& $xls->addWorksheet('Info sheet');
if (isset($_GET['textarea'])) {$textarea=$_GET['textarea'];};
if (!isset($textarea)) {$textarea="";};
if (isset($_GET['param1'])) {$param1=$_GET['param1'];};
if (!isset($param1)) {$param1="";};
$titleText = '³ , '. $param1;
$titleText1 = ' /';
$titleText2 = '';
$titleText3 = '';
$titleText4 = '';
$titleText5 = '³';
$titleText6 = ' ';
$titleText7 = ' ';
$titleText8 = '.';
$titleFormat=& $xls->addFormat(); //
$titleFormat->setBold();
$titleFormat->setSize('13'); //
$titleFormat->setAlign('merge'); //
///$titleFormat->setMerge(1,1,1,5);
$titleFormat->setTextWrap(1);
$titleFormat1=& $xls->addFormat(); //
$titleFormat1->setBold(); //
$titleFormat1->setBorder(1); //
$titleFormat1->setTextWrap(1); //
$titleFormat1->setHAlign('center');
$titleFormat1->setVAlign('vcenter');
$titleFormat2=& $xls->addFormat(); // ()
$titleFormat2->setNumFormat('0.00');
$titleFormat2->setBorder(1);
$titleFormat3=& $xls->addFormat(); //
$titleFormat3->setBorder(1);
$titleFormat3->setHAlign('right');
$titleFormat4=& $xls->addFormat(); //
$titleFormat4->setBold(); //
$titleFormat4->setAlign('center');
$titleFormat5=& $xls->addFormat(); //
$titleFormat5->setTextWrap(1);
$titleFormat5->setBorder(1);
$sheet->write(1,2,'',$titleFormat);
$sheet->write(1,3,'',$titleFormat);
$sheet->write(1,4,'',$titleFormat);
$sheet->write(1,5,'',$titleFormat);
$sheet->write(6,3,'',$titleFormat5);
$sheet->setColumn(0,0,3); //
$sheet->setColumn(0,1,6); //
$sheet->setColumn(0,2,10); //
$sheet->setColumn(0,3,30); //
$sheet->setColumn(0,4,15); //
$sheet->setColumn(0,5,15); //
$sheet->setColumn(0,6,15); //
$sheet->write(1,3,$titleText,$titleFormat);
$sheet->write(5,0,$titleText1,$titleFormat1);
$sheet->write(5,1,$titleText2,$titleFormat1);
$sheet->write(5,2,$titleText3,$titleFormat1);
$sheet->write(5,3,$titleText4,$titleFormat1);
$sheet->write(5,4,$titleText5,$titleFormat1);
$sheet->write(5,5,$titleText6,$titleFormat1);
$sheet->write(5,6,$titleText7,$titleFormat1);
$sheet->write(4,6,$titleText8,$titleFormat4);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
$user="any_user";
$password="anyuserany";
$sid="REGION19";
$host="10.19.19.111";
$port=1521;
$db ="(DESCRIPTION =
(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = $host)(PORT = $port)) )
(CONNECT_DATA = (SID = $sid)) )";
$conn=@oci_connect($user,$password,$db)
or die(" i i Oracle.");
/////////////////////////////////////////////////////////////////////////////////////////////////////////
$format="";
$stmt = oci_parse($conn,$textarea);
$k=oci_execute($stmt, OCI_DEFAULT);
if (!$k) {
$e = oci_error($stmt);
echo htmlentities($e['message']);
echo "<pre>";
printf("\n%".($e['offset']+1)."s", "^");
echo "</pre>";
}
$ncols = oci_num_fields($stmt);
//$r=5;
// for ($i = 1; $i <= $ncols; $i++) {
// $column_name = oci_field_name($stmt, $i);
// $c=0;
// $sheet->write($r,$i-1,$column_name);
// }
$q=5;
while($row=oci_fetch_array($stmt)) {
$q++;
for ($i = 0; $i < $ncols; $i++)
{
$sheet->write($q,$i,$row[$i],$titleFormat3);
///////////////////////////////////////////////////////////////////////////
//
// $start = Spreadsheet_Excel_Writer::rowcolToCell($q, 4);
// $end = Spreadsheet_Excel_Writer::rowcolToCell($q, ($ncols-1));
// AVERAGE()
// ()
// if ($q != 0) {
// $sheet->writeFormula($q, $ncols, "=AVERAGE($start:$end)", $titleFormat3);
// }
///////////////////////////////////////////////////////////////////////////
}
for ($i = 3; $i <= 3; $i++)
{
$sheet->write($q,$i,$row[$i],$titleFormat5); }
}
//
$xls->close();
?>
|
но в Explorer не работает | |
|
|
|
|
|
|
|
для: gudzik
(29.09.2009 в 16:51)
| | Как выдаете файл для загрузки, какие HTTP-заголовки отправляете клиенту? | |
|
|
|
|
|
|
| Привет!!!
У меня на PHP есть кнопка кноторая при нажатии должна средствами Spreadsheet_Excel_Writer содать файл XLS. В FireFox и Opera кнопка работает нормально, а вот в Explorer почему-то никаких действий не происходит.
Кто знает в чем дело, ПОМОГИТЕ!!! | |
|
|
| |
|