ブラウザに Excel を貼り付けさせる送り方


  Excel が正しく登録されているマシンのレジストリ


  PHP での出力内容と結果




  

<?
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");
    }
  

  Microsoft の参考リンク

MIME の種類を使用して IE 内に Excel で ASP の結果を表示する方法

http://support.microsoft.com/kb/296717/ja
http://support.microsoft.com/kb/318756/ja
http://support.microsoft.com/kb/899646/ja




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[realwebapp]
claudebot
24/03/29 05:15:57
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube