忍者ブログ
日記とか趣味の乙女ゲームとか。
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

PHPExcel本家

<PHPExcelでExcel5>
インストールはすっ飛ばしマス(自分メモなので優しくないです。



・インクルーズパスを設定
----
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/html/');
?>
----

・基本はExcel5でもExcel2007でも以下を入れる。
----
<?php
/** PHPExcel */
require_once 'PHPExcel.php';

/** PHPExcel_RichText */
require_once 'PHPExcel/RichText.php';

// Create new PHPExcel object
$excel = new PHPExcel();

// Create a first sheet, representing sales data
$excel->setActiveSheetIndex(0);

$sheet = $excel->getActiveSheet();
?>
----
    :
この間に一行ごとの記述入れて、最後に
    :
----
<?php
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$excel->setActiveSheetIndex(0);
?>
----

ここまでは共通。
ここからが、Excel5・Excel2007・htmlごとの設定

Excel5の場合は以下で「list_xxxx.xls」ファイルが作られます。
----
<?php
// Excel5
require_once 'PHPExcel/Writer/Excel5.php';
$writer = new PHPExcel_Writer_Excel5($excel);
$savefile = 'list_'.date('Ymd').'.xls';
// save
$writer->save($savefile);
?>
----

以下で「(Filename).htm」ファイルが作られます。
(こっちはなんだか表示がオカシイ。なんで?)。
----
<?php
include 'PHPExcel/Writer/HTML.php';
$writer = new PHPExcel_Writer_HTML($excel);
$writer->setSheetIndex(0);
$writer->save(str_replace('.php', '.htm', __FILE__));
?>
----

大まかなところ、こんな感じ。
Excel記述の詳しいところは、また後で。

拍手

PR
この記事へのコメント
name
title
color
mail
URL
comment
pass   Vodafone絵文字 i-mode絵文字 Ezweb絵文字

secret(※チェックを入れると管理者へのみの表示となります。)
Template and graphic by karyou
忍者ブログ [PR]