Excel が正しく登録されているマシンのレジストリ |
|
|
<?
header( "Content-Type: application/vnd.ms-excel;" ); // Excel 用
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); // キャッシュ無効
print "住所\t氏名\t年齢\n";
print "大阪府\t山田 太郎\t25\n";
?>
| |
|
|
<?
header( "Content-Type: application/vnd.ms-excel;" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
?>
<HTML>
<HEAD>
<STYLE type="text/css">
table {
background-color: skyblue;
}
.data {
background-color: green;
color: white;
font-weight: bold;
}
</STYLE>
</HEAD>
<BODY>
<TABLE border="1">
<TR>
<TD>住所</TD><TD>氏名</TD><TD>年齢</TD>
</TR>
<TR>
<TD>大阪府</TD><TD>山田 太郎</TD><TD class="data">25</TD>
</TR>
</TABLE>
</BODY>
</HTML>
| |
|
|
PEAR を使用したWindows 以外のサーバで利用可能な Excel データのバイナリ送信 |
|
ソースコードのダウンロード :
|
<?php
set_include_path( "PEAR" );
require_once 'Spreadsheet/Excel/Writer.php';
// ワークブックを作成します
$workbook = new Spreadsheet_Excel_Writer();
// HTTP ヘッダを送信します
# sendInline は、lightbox が追加しました
$workbook->sendInline('test.xls');
// ワークシートを作成します
$worksheet =& $workbook->addWorksheet('シート1');
// データを書き込みます
$worksheet->write(0, 0, '日本語');
$worksheet->write(0, 1, '表示');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 30);
$worksheet->write(2, 0, 'Johann Schmidt');
$worksheet->write(2, 1, 31);
$worksheet->write(3, 0, 'Juan Herrera');
$worksheet->write(3, 1, 32);
// ファイルを送信します
$workbook->close();
?>
| |
|
|
PEAR を使用したWindows 以外のサーバで利用可能な Excel データのダウンロード送信 |
|
|
<?php
set_include_path( "PEAR" );
require_once 'Spreadsheet/Excel/Writer.php';
// ワークブックを作成します
$workbook = new Spreadsheet_Excel_Writer();
// HTTP ヘッダを送信します
# sendInline は、lightbox が追加しました
$workbook->send('test.xls');
// ワークシートを作成します
$worksheet =& $workbook->addWorksheet('シート1');
// データを書き込みます
$worksheet->write(0, 0, '日本語');
$worksheet->write(0, 1, '表示');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 30);
$worksheet->write(2, 0, 'Johann Schmidt');
$worksheet->write(2, 1, 31);
$worksheet->write(3, 0, 'Juan Herrera');
$worksheet->write(3, 1, 32);
// ファイルを送信します
$workbook->close();
?>
| |
|
send メソッドのコード
|
function send($filename)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
| |
|
|
|