実行サンプル DB は、EUC-JP で、EUC-JP の HTML としてページ(テーブルのみ)を作成します。 実際 IE は、いったんダウンロードして、Excel を(プラグインで)起動します。 table=%BC%D2%B0%F7%A5%DE%A5%B9%A5%BF は、EUC-JP でURLエンコードされた表名であり、 Sheet 名として使用される事になります 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <? header( "Content-Type: application/vnd.ms-excel;" ); header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); ini_set( 'display_errors', "1" ); function inc( $path ) { $inc = @file( $path ); array_shift($inc); array_pop($inc); $GLOBALS['inc_eval_txt'] = implode( "", $inc ); eval($GLOBALS['inc_eval_txt']); } # ********************************************************** # 外部ファイル # ********************************************************** $conf_client_charset = "EUC-JP"; $conf_db_type = 1; inc( "http://lightbox.in.coocan.jp/gen/db.txt" ); if ( trim($_GET['table']) == '' ) { $_GET['table'] = 'Sheet1'; } ?> <HTML xmlns:x="urn:schemas-microsoft-com:office:excel"> <HEAD> <META http-equiv="content-type" content="text/html; charset=<?= $conf_client_charset ?>"> <xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name><?= $_GET['table'] ?></x:Name> <x:WorksheetOptions> <x:DefaultRowHeight>270</x:DefaultRowHeight> <x:Selected/> <x:ProtectContents>False</x:ProtectContents> <x:ProtectObjects>False</x:ProtectObjects> <x:ProtectScenarios>False</x:ProtectScenarios> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> <x:WindowHeight>13275</x:WindowHeight> <x:WindowWidth>18180</x:WindowWidth> <x:WindowTopX>480</x:WindowTopX> <x:WindowTopY>30</x:WindowTopY> <x:ProtectStructure>False</x:ProtectStructure> <x:ProtectWindows>False</x:ProtectWindows> </x:ExcelWorkbook> </xml> </HEAD> <BODY> <? # ********************************************************** # 接続 # ********************************************************** $SQL = new DB( "********", "********", "********", "********" ); $Query = "select * from `{$_GET['table']}`"; $Column = $SQL->QueryEx( $Query ); print "<TABLE border=1>\n"; while( $Column ) { print "<TR>\n"; for( $i = 0; $i < $SQL->nField; $i++ ) { print "<TD nowrap>{$Column[$i]}</TD>\n"; } print "</TR>\n"; $Column = $SQL->QueryEx( ); } print "</TABLE>\n"; # ********************************************************** # 接続解除 # ********************************************************** $SQL->Close(); ?> </BODY> </HTML> DB クラス利用方法 Microsoft ドキュメント参考ページ
<? header( "Content-Type: application/vnd.ms-excel;" ); header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); ini_set( 'display_errors', "1" ); function inc( $path ) { $inc = @file( $path ); array_shift($inc); array_pop($inc); $GLOBALS['inc_eval_txt'] = implode( "", $inc ); eval($GLOBALS['inc_eval_txt']); } # ********************************************************** # 外部ファイル # ********************************************************** $conf_client_charset = "EUC-JP"; $conf_db_type = 1; inc( "http://lightbox.in.coocan.jp/gen/db.txt" ); if ( trim($_GET['table']) == '' ) { $_GET['table'] = 'Sheet1'; } ?> <HTML xmlns:x="urn:schemas-microsoft-com:office:excel"> <HEAD> <META http-equiv="content-type" content="text/html; charset=<?= $conf_client_charset ?>"> <xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name><?= $_GET['table'] ?></x:Name> <x:WorksheetOptions> <x:DefaultRowHeight>270</x:DefaultRowHeight> <x:Selected/> <x:ProtectContents>False</x:ProtectContents> <x:ProtectObjects>False</x:ProtectObjects> <x:ProtectScenarios>False</x:ProtectScenarios> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> <x:WindowHeight>13275</x:WindowHeight> <x:WindowWidth>18180</x:WindowWidth> <x:WindowTopX>480</x:WindowTopX> <x:WindowTopY>30</x:WindowTopY> <x:ProtectStructure>False</x:ProtectStructure> <x:ProtectWindows>False</x:ProtectWindows> </x:ExcelWorkbook> </xml> </HEAD> <BODY> <? # ********************************************************** # 接続 # ********************************************************** $SQL = new DB( "********", "********", "********", "********" ); $Query = "select * from `{$_GET['table']}`"; $Column = $SQL->QueryEx( $Query ); print "<TABLE border=1>\n"; while( $Column ) { print "<TR>\n"; for( $i = 0; $i < $SQL->nField; $i++ ) { print "<TD nowrap>{$Column[$i]}</TD>\n"; } print "</TR>\n"; $Column = $SQL->QueryEx( ); } print "</TABLE>\n"; # ********************************************************** # 接続解除 # ********************************************************** $SQL->Close(); ?> </BODY> </HTML>
拡張子:txtvbswsfjsphpjavahtmlutf8sjis <xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name>シート名</x:Name> <x:WorksheetOptions> <x:Selected/> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> </x:ExcelWorkbook> </xml>
<xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name>シート名</x:Name> <x:WorksheetOptions> <x:Selected/> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> </x:ExcelWorkbook> </xml>
拡張子:txtvbswsfjsphpjavahtmlutf8sjis .className { mso-style-parent:style0; mso-number-format:"\#\,\#\#0"; } ↓TDにデータをセットしなくても計算してくれる( num の値も 0 をセットしておけば良い ) 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <td class=className align=right x:num="0" x:fmla="=SUM(B4:B7)"></td>
.className { mso-style-parent:style0; mso-number-format:"\#\,\#\#0"; }
<td class=className align=right x:num="0" x:fmla="=SUM(B4:B7)"></td>
拡張子:txtvbswsfjsphpjavahtmlutf8sjis font-size:11.0pt; font-weight:400; font-style:normal; font-family:"MS PGothic", monospace; mso-font-charset:128; 0 : Windows 標準文字セット 2 : 特殊文字セット 128: 日本語版 Windows 専用の 2 バイト文字セット(DBCS) 255: DOS アプリケーションで表示する拡張文字セット
font-size:11.0pt; font-weight:400; font-style:normal; font-family:"MS PGothic", monospace; mso-font-charset:128;