複数ページをSheetを利用してExcelで表示する

  複数シートを表示する為の構成



↓Excel がインストールされている場合はクリックして下さい
http://lightbox.on.coocan.jp/php/excel/excel_out.php

↓Microsoft の履歴書テンプレートでのサンプル
http://lightbox.on.coocan.jp/php/excel/rireki/excel_out.php

1) 実行ファイル
2) 実行ファイルと同じ名前を持つディレクトリ
3) ディレクトリ内に、シートを表示する為のファイル
4) ディレクトリ内にスタイルシート
※ book.php にある filelist.xml はディレクトリ内に環境によって必要なようです( 内容は正確でなくてもいいみたいなんですが )




データ部分はいずれも PHP なので、入力値やデータベースの値でシートを構成する事が可能です。



  excel_out.php



book.php と 別にする必要はありませんが、Excel が生成するファイルをそのまま利用する場合は、
HTML としても表示できるので、分けておくほうがいいかもしれません。

  
<?
header( "Content-Type: application/vnd.ms-excel;" );

include( "book.php" );

?>
  



  book.php

  
<link rel=File-List href="excel_out/filelist.xml">
は、実体が無くても必要なようです。
  

  
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta name="Excel Workbook Frameset">
<meta http-equiv=Content-Type content="text/html; charset=shift_jis">
<link rel=File-List href="excel_out/filelist.xml">

<xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet1</x:Name>
    <x:WorksheetSource HRef="excel_out/sheet.php?page=1"/>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetSource HRef="excel_out/sheet.php?page=2"/>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml>
</head>

  




  sheet.php

  
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=shift_jis">
<link rel=Stylesheet href=stylesheet.css>
<style>
<!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
@page
	{margin:.98in .79in .98in .79in;
	mso-header-margin:.51in;
	mso-footer-margin:.51in;}
ruby
	{ruby-align:left;}
rt
	{color:windowtext;
	font-size:6.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:"MS Pゴシック", monospace;
	mso-font-charset:128;
	mso-char-type:katakana;
	display:none;}
-->
</style>
<xml>
 <x:WorksheetOptions>
  <x:DefaultRowHeight>270</x:DefaultRowHeight>
  <x:ProtectContents>False</x:ProtectContents>
  <x:ProtectObjects>False</x:ProtectObjects>
  <x:ProtectScenarios>False</x:ProtectScenarios>
 </x:WorksheetOptions>
</xml>
</head>

<body link=blue vlink=purple>

<table x:str border=0 cellpadding=0 cellspacing=0 width=144 style='border-collapse:
 collapse;table-layout:fixed;width:108pt'>
 <col width=72 span=2 style='width:54pt'>
 <tr height=18 style='height:13.5pt'>
  <td height=18 width=72 style='height:13.5pt;width:54pt'>
<?
	if ( $_GET['page'] == 1 ) {
		print "ページ1";
	}
	if ( $_GET['page'] == 2 ) {
		print "ページ2";
	}
?>
  </td>
  <td width=72 style='width:54pt'>
<?
	if ( $_GET['page'] == 1 ) {
		print "ページは一つのPHPで表現できます";
	}
	if ( $_GET['page'] == 2 ) {
		print "1ページあたりのデータ量を決めておく必要があります";
	}
?>
  </td>
 </tr>
</table>

</body>

</html>
  



  stylesheet.css

  
tr
	{mso-height-source:auto;
	mso-ruby-visibility:none;}
col
	{mso-width-source:auto;
	mso-ruby-visibility:none;}
br
	{mso-data-placement:same-cell;}
ruby
	{ruby-align:left;}
.style0
	{mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	white-space:nowrap;
	mso-rotate:0;
	mso-background-source:auto;
	mso-pattern:auto;
	color:windowtext;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:"MS Pゴシック", monospace;
	mso-font-charset:128;
	border:none;
	mso-protection:locked visible;
	mso-style-name:標準;
	mso-style-id:0;}
td
	{mso-style-parent:style0;
	padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:"MS Pゴシック", monospace;
	mso-font-charset:128;
	mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	border:none;
	mso-background-source:auto;
	mso-pattern:auto;
	mso-protection:locked visible;
	white-space:nowrap;
	mso-rotate:0;}
  













   SQLの窓    create:2007/11/13  update:2018/02/23   管理者用(要ログイン)





フリーフォントツール

SQLの窓ツール

SQLの窓フリーソフト

写真素材

一般ツールリンク

SQLの窓

フリーソフト

JSライブラリ