<?php
trait EXCEL {
/*----------------------------------------------------------------------------*/
/* Construct                                                                  */
/*----------------------------------------------------------------------------*/
    private function __construct($CL) {
        $CL['LG']->cLog('T0001');
        // 変数取得
        $this->lbl_AriyaName       = $CL['LB']->gCOMON_Label('AriyaName');
        $this->lbl_SerachCondition = $CL['LB']->gDF_Label('SerachCondition');
        $this->lbl_Screen          = $CL['LB']->gDF_Label('Screen');
        $this->lbl_SerachUser      = $CL['LB']->gDF_Label('SerachUser');
        $this->lbl_CompanyName     = $CL['LB']->gDF_Label('CompanyName');
        $this->lbl_UserID          = $CL['LB']->gDF_Label('UserID');
        $this->lbl_UserName        = $CL['LB']->gDF_Label('UserName');
        $this->lbl_UserAuth        = $CL['LB']->gDF_Label('UserAuth');
        $this->lbl_LocationTime    = $CL['LB']->gDF_Label('LocationTime');
        $this->lbl_Language        = $CL['LB']->gDF_Label('Language');
        $this->lbl_Time            = $CL['LB']->gDF_Label('Time');
        $this->lbl_Location        = $CL['LB']->gDF_Label('Location');
        $this->lbl_Location        = $CL['LB']->gDF_Label('Location');
        $this->lbl_Everything      = $CL['LB']->gDF_Label('Everything');
        
        // 共通クラスを保持
        $this->CL = $CL;
    }
    
/*----------------------------------------------------------------------------*/
/* Clone                                                                      */
/*----------------------------------------------------------------------------*/
    public final function __clone() {
        $CL['LG']->cLog('S0002');
    }
    
/*----------------------------------------------------------------------------*/
/* Variable                                                                   */
/*----------------------------------------------------------------------------*/
/*------------------------------------*/
/* Public                             */
/*------------------------------------*/


/*------------------------------------*/
/* Private                            */
/*------------------------------------*/
    private static $instance = [];

/*------------------------------------*/
/* Protected                          */
/*------------------------------------*/
    protected $CL;


/*----------------------------------------------------------------------------*/
/* Public Function                                                            */
/*----------------------------------------------------------------------------*/
    // インスタンス作成
    public static function getInstance($CL) {
        $CL['LG']->cLog('T0002');
        $class = get_called_class();
        if (!isset(self::$instance[$class])) self::$instance[$class] = new $class($CL);
        return self::$instance[$class];
    }
    
    // EXCELデータ作成
    public function cExcel($SheetName, $HeadCond, $MainCond, $HeadData, $MainData, $DataType = NULL, $TotalData = NULL, $BeginData = NULL, $Status = NULL) {
        $this->CL['LG']->cLog('T0002');
        
        // 前繰越データ形式チェック
        if ($BeginData != NULL && count($MainData) != count($BeginData)) {
            $caller = debug_backtrace()[0];
            trigger_error('Beginning Data type information is not match as data.'.' in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler",E_USER_WARNING);
            return false;
        }
        // 表示データ形式情報チェック （表示データのカラム数と表示データ形式のカラム数が一致すること）
        if ($DataType != NULL && count($MainData) != count($DataType)) {
            $caller = debug_backtrace()[0];
            trigger_error('Data type information is not match as data.'.' in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler",E_USER_WARNING);
            return false;
        }
        // $TotalData形式チェック
        if ($TotalData !== NULL) {
            if (!is_array($TotalData)) {
                trigger_error('Total information is invalid format. (not array :'.$TotalData.') in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler",E_USER_WARNING);
                return false;
            }
            for ($i = 0; $i < count($TotalData); $i++) {
                if (count($TotalData[$i]) != count($DataType)) {
                    trigger_error('Total information ('.($i + 1).' is not match as data. ('.json_encode($TotalData[$i]).') in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler",E_USER_WARNING);
                    return false;
                }
            }
        }
        
        // $Status形式チェック （$MainDataの各アイテムと同じ行数があるか？）
        if ($Status != NULL) {
            do {
                if (is_array($Status)) {
                    if (count($MainData[0]) == count($Status)) {
                        break;
                    }
                }
                // 上記の条件以外はエラーとする
                $caller = debug_backtrace()[0];
                trigger_error('Data Status information is not match as data.'.' in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler",E_USER_WARNING);
                return false;
            } while (false); // breakを使えるようにするためのダミー
        }
        
        // EXCEL出力ディレクトリ作成
        $ExcelPath = self::cExcelPath($SheetName);
        
        // ファイル作成
        touch($ExcelPath);
        chmod($ExcelPath, octdec($this->CL['DF']->PermissionFile));
        
        // ファイルオープン
        $fp = fopen($ExcelPath, 'w');
        
        // EXCELヘッダ出力
        self::cExcelHeader($fp);
        
        // Style出力
        self::cExcelStyle($fp);
        
        // 検索条件
        self::cExcelCondition($fp, $HeadCond, $MainCond);
        
        // メイン出力(取引先情報)
        switch ($SheetName) {
            // マイビュー
            case $this->CL['DF']->MyView:
                self::cExcelMyView($fp, $SheetName, $HeadData, $MainData);
                break;
            // 取引先情報
//            case $this->CL['DF']->ClientList:
//                self::cExcelClient($fp, $SheetName, $HeadData, $MainData);
//                break;
            // ユーザ情報
            case $this->CL['DF']->UserList:
                self::cExcelUser($fp, $SheetName, $HeadData, $MainData);
                break;
            // 勘定科目情報
//            case $this->CL['DF']->AccountList:
//                self::cExcelAccount($fp, $SheetName, $HeadData, $MainData);
//                break;
//            // 仕訳帳情報
//            case $this->CL['DF']->JournalList:
//                self::cExcelJournal($fp, $SheetName, $HeadData, $MainData);
//                break;
            // 取引情報
            case $this->CL['DF']->TransactionList:
                self::cExcelTransaction($fp, $SheetName, $HeadData, $MainData);
                break;
            // 月次確定情報
            case $this->CL['DF']->MoCfmList:
                self::cExcelMoCfm($fp, $SheetName, $HeadData, $MainData);
                break;
            // 標準式総勘定元帳
            case $this->CL['DF']->GeneralLedgerT:
                self::cExcelGeneralLedgerT($fp, $SheetName, $HeadData, $MainData);
                break;
            // 補助元帳
            case $this->CL['DF']->SubLedger:
                self::cExcelSubLedger($fp, $SheetName, $HeadData, $MainData);
                break;
            // 残高一覧表
            case $this->CL['DF']->SubLedgerBal:
                self::cExcelSubLedgerBal($fp, $SheetName, $HeadData, $MainData);
                break;
            // Aging Report
            case $this->CL['DF']->AgingReport:
                self::cExcelAgingReport($fp, $SheetName, $HeadData, $MainData);
                break;
            // 試算表
            case $this->CL['DF']->TrialBalance:
                self::cExcelTrialBalance($fp, $SheetName, $HeadData, $MainData);
                break;
            // 精算表
            case $this->CL['DF']->WorkSheet:
                self::cExcelWorkSheet($fp, $SheetName, $HeadData, $MainData);
                break;
            // 貸借対照表
            case $this->CL['DF']->BalanceSheet:
                self::cExcelBalanceSheet($fp, $SheetName, $HeadData, $MainData);
                break;
            // 損益計算書
            case $this->CL['DF']->ProfitAndLoss:
                self::cExcelProfitAndLoss($fp, $SheetName, $HeadData, $MainData);
                break;
            // 開始残高
            case $this->CL['DF']->OpningBalance:
                self::cExcelOpningBalance($fp, $SheetName, $HeadData, $MainData);
                break;
            // その他（汎用リスト）
            default:
                self::cExcelList($fp, $SheetName, $HeadData, $MainData, $DataType, $TotalData, $BeginData, $Status);
        }
        
        // EXCELフッタ出力
        self::cExcelFooter($fp);
        
        // ファイルクローズ
        $fp = fclose($fp);
        
        // ダウンロード用のHTTPヘッダ送信
        header('Content-Disposition: inline; filename="'.basename($ExcelPath).'"');
        header('Content-Length: '.filesize($ExcelPath));
        header('Content-Type: application/octet-stream');
        
        // ファイルを読んで出力
        readfile($ExcelPath);
    }
    
    
/*----------------------------------------------------------------------------*/
/* Private Function                                                           */
/*----------------------------------------------------------------------------*/
/*--------------------------------------------------------*/
/* 共通                                                   */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* EXCEL出力フルパスを作成する                                */
    /*                                                            */
    /* Arg1:ExportName                                            */
    /*      EXCEL出力ファイル名                                   */
    /* Ret :EXCEL出力フルパス                                     */
    /*------------------------------------------------------------*/
    private function cExcelPath($ExportName) {
        $this->CL['LG']->cLog('T0002');
        // EXCEL出力ディレクトリ(Export/Excel)
        $ExportDir = $this->CL['DF']->ExportDirExcel;
        if (file_exists($ExportDir)) {
            // 存在するなら何もしない
            ;
        } else {
            // 存在しないなら作成する
            mkdir($ExportDir, octdec($this->CL['DF']->PermissionDir), true);
            chmod($ExportDir, octdec($this->CL['DF']->PermissionDir)); // 作成時にはumaskの影響を受けるので、明示的に属性設定
        }
        
        // EXCEL出力ディレクトリ(Export/Excel/YYYYMMDD)
        $ExportDir = $this->CL['DF']->ExportDirExcel.'/'.date_format(new DateTime('now'), "Ymd");
        if (file_exists($ExportDir)) {
            // 存在するなら何もしない
            ;
        } else {
            // 存在しないなら作成する
            mkdir($ExportDir, octdec($this->CL['DF']->PermissionDir), true);
            chmod($ExportDir, octdec($this->CL['DF']->PermissionDir)); // 作成時にはumaskの影響を受けるので、明示的に属性設定
        }
        
        return $ExportDir.'/'.$ExportName.'_'.date_format(new DateTime('now', new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale'])), "YmdHis").$this->CL['DF']->ExtensionExcel;
    }

    /*------------------------------------------------------------*/
    /* XML用エスケープ文字変換                                       */
    /*                                                            */
    /* Arg1:str                                                   */
    /*      文字列                                                */
    /* Ret :エスケープ文字処理後文字列                                */
    /*------------------------------------------------------------*/
    private function strEscape($str) {
        $this->CL['LG']->cLog('T0002');
        $ret = $str;
        $ret = str_replace('&', '&amp;', $ret);
        $ret = str_replace('"', $this->CL['DF']->QUOT, $ret);
        $ret = str_replace('<', '&lt;', $ret);
        $ret = str_replace('>', '&gt;', $ret);
        $ret = str_replace('\'', '&apos;', $ret);
        $ret = str_replace($this->CL['DF']->LF, $this->CL['DF']->XLF, $ret);
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 仕訳帳のExcel出力のデザイン判定(区切,打消の有無)           */
    /*                                                            */
    /* Arg1:TrVal                                                 */
    /*      Trクラス                                              */
    /* Arg2:GenTrnPageList                                        */
    /*      取引(当該ページ全件)                                  */
    /* Ret :仕訳帳Excel出力デザイン                               */
    /*------------------------------------------------------------*/
    private function cDesign($TrVal, $GenTrnPageList) {
        $this->CL['LG']->cLog('T0002');
        // 指数マイナスは削除
        unset($TrVal[-1]);
        $TrVal = array_values($TrVal);
        
        for ($i = 0, $c = count($TrVal); $i < $c; $i++) {
            if (strpos($TrVal[$i], $this->CL['DF']->seprow) !== false) {
                // 区切有
                if ($GenTrnPageList[$i]['Status'] == $this->CL['DF']->false) {
                    // 打消有
                    $ret[$i] = $this->CL['DF']->ExcelStyle_SepStr;
                } else {
                    // 打消無
                    $ret[$i] = $this->CL['DF']->ExcelStyle_Sep;
                }
            } else {
                // 区切無
                if ($GenTrnPageList[$i]['Status'] == $this->CL['DF']->false) {
                    // 打消有
                    $ret[$i] = $this->CL['DF']->ExcelStyle_Str;
                } else {
                    // 打消無
                    $ret[$i] = $this->CL['DF']->ExcelStyle_Non;
                }
            }
        }
        return $ret;
    }
    
/*--------------------------------------------------------*/
/* 部品                                                   */
/*--------------------------------------------------------*/
    // EXCELヘッダ出力
    private function cExcelHeader($fp) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        fwrite($fp, '<?xml version="1.0"?>'.$LF);
        fwrite($fp, '<?mso-application progid="Excel.Sheet"?>'.$LF);
        fwrite($fp, '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">'.$LF);
        fwrite($fp, '    <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">'.$LF);
        fwrite($fp, '        <Author>'.$this->lbl_AriyaName.'</Author>'.$LF);
        fwrite($fp, '        <LastAuthor>'.$this->lbl_AriyaName.'</LastAuthor>'.$LF);
        fwrite($fp, '        <Created>'.date_format(new DateTime('now', new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale'])), "Y-m-d").'T'.date_format(new DateTime('now', new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale'])), "H:i:s").'Z</Created>'.$LF);
        fwrite($fp, '        <Version>12.00</Version>'.$LF);
        fwrite($fp, '    </DocumentProperties>'.$LF);
        fwrite($fp, '    <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">'.$LF);
        fwrite($fp, '        <WindowHeight>12015</WindowHeight>'.$LF);
        fwrite($fp, '        <WindowWidth>19095</WindowWidth>'.$LF);
        fwrite($fp, '        <WindowTopX>120</WindowTopX>'.$LF);
        fwrite($fp, '        <WindowTopY>30</WindowTopY>'.$LF);
        fwrite($fp, '        <ProtectStructure>False</ProtectStructure>'.$LF);
        fwrite($fp, '        <ProtectWindows>False</ProtectWindows>'.$LF);
        fwrite($fp, '    </ExcelWorkbook>'.$LF);
    }
    
    // Style出力
    private function cExcelStyle($fp) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        fwrite($fp, '    <Styles>'.$LF);
        
        /*------------------------------------*/
        /* 共通                               */
        /*------------------------------------*/
        // FmtAll:共通(全般)
        fwrite($fp, '        <Style ss:ID="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        /*------------------------------------*/
        /* タイトル行                         */
        /*------------------------------------*/
        // Ttl:タイトル行
        fwrite($fp, '        <Style ss:ID="Ttl" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#D7E4BC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        /*------------------------------------*/
        /* 数値用                             */
        /*------------------------------------*/
        // Numeric:カンマなし数値用（小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="Numeric" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="_-* #0.########_-;\-* #0.########_-;_-* &quot;-&quot;_-;_-@_-"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        // Comma:カンマつき数値用（小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="Comma" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="_-* #,##0.########_-;\-* #,##0.########_-;_-* &quot;-&quot;_-;_-@_-"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        // Num:カンマつき数値（小数点以下なし）
        fwrite($fp, '        <Style ss:ID="Num" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="_-* #,##0_-;\-* #,##0_-;_-* &quot;-&quot;_-;_-@_-"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // Amt:金額用
        $decZero = '';
        if ((isset($this->CL['DF']->LenDec)) && ($this->CL['DF']->LenDec != 0)) {
            $decZero = '.'.str_repeat('0',$this->CL['DF']->LenDec);
        }
        fwrite($fp, '        <Style ss:ID="Amt" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="_-* #,##0'.$decZero.'_-;\-* #,##0'.$decZero.'_-;_-* &quot;-&quot;_-;_-@_-"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        // Rate:レート用
        $decZero = '';
        if ((isset($this->CL['DF']->LenDecRate)) && ($this->CL['DF']->LenDecRate != 0)) {
            $decZero = '.'.str_repeat('0',$this->CL['DF']->LenDecRate);
        }
        fwrite($fp, '        <Style ss:ID="Rate" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="_-* #,##0'.$decZero.'_-;\-* #,##0'.$decZero.'_-;_-* &quot;-&quot;_-;_-@_-"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        // NumLft:数値用(左寄(Lft))
        fwrite($fp, '        <Style ss:ID="NumLft" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="#,##0"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // CommaStr:数値用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="CommaStr" ss:Parent="Comma">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumericStr:数値用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="NumericStr" ss:Parent="Numeric">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumStr:数値用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="NumStr" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // AmtStr:金額用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="AmtStr" ss:Parent="Amt">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // RateStr:金額用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="RateStr" ss:Parent="Rate">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumPct:数値用(パーセント(Pct))
        fwrite($fp, '        <Style ss:ID="NumPct" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="0%"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumDbl:数値用(下二重線(Dbl))
        fwrite($fp, '        <Style ss:ID="NumDbl" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Double" ss:Weight="3"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumDblBld:数値用(下二重線(Dbl)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="NumDblBld" ss:Parent="NumDbl">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // AmtDbl:金額用(下二重線(Dbl))
        fwrite($fp, '        <Style ss:ID="AmtDbl" ss:Parent="Amt">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Double" ss:Weight="3"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // AmtDblBld:金額用(下二重線(Dbl)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="AmtDblBld" ss:Parent="AmtDbl">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        // NumDblBldPct:数値用(下二重線(Dbl)/太字(Bld)/パーセント(Pct))
        fwrite($fp, '        <Style ss:ID="NumDblBldPct" ss:Parent="NumDblBld">'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="0%"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumSep:数値用(下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="NumSep" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // NumStrSep:数値用(打消線(Str)/下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="NumStrSep" ss:Parent="NumSep">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // AmtSep:金額用(下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="AmtSep" ss:Parent="Amt">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // AmtStrSep:金額用(打消線(Str)/下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="AmtStrSep" ss:Parent="AmtSep">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        /*------------------------------------*/
        /* 文字列用                           */
        /*------------------------------------*/
        // Str:文字列用
        fwrite($fp, '        <Style ss:ID="Str" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrRgh:文字列用
        fwrite($fp, '        <Style ss:ID="StrRgh" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrBld:文字列用(太字(Bld))
        fwrite($fp, '        <Style ss:ID="StrBld" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID1:文字列用(段落:1(ID1))
        fwrite($fp, '        <Style ss:ID="StrID1" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID2:文字列用(段落:2(ID2))
        fwrite($fp, '        <Style ss:ID="StrID2" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="2"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID3:文字列用(段落:3(ID3))
        fwrite($fp, '        <Style ss:ID="StrID3" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="3"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID3Bld:文字列用(段落:3(ID3)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="StrID3Bld" ss:Parent="StrID3">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID4:文字列用(段落:4(ID4))
        fwrite($fp, '        <Style ss:ID="StrID4" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="4"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID4Bld:文字列用(段落:4(ID4)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="StrID4Bld" ss:Parent="StrID4">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID5:文字列用(段落:5(ID5))
        fwrite($fp, '        <Style ss:ID="StrID5" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="5"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrID5Bld:文字列用(段落:5(ID5)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="StrID5Bld" ss:Parent="StrID5">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrWrp:文字列用(折り返し(Wrp))
        fwrite($fp, '        <Style ss:ID="StrWrp" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:WrapText="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrWrpVrt:文字列用(縦書(Vrt))
        fwrite($fp, '        <Style ss:ID="StrWrpVrt" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:VerticalText="1" ss:WrapText="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrCtr:文字列用(中央寄(Ctr))
        fwrite($fp, '        <Style ss:ID="StrCtr" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrStr:文字列用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="StrStr" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrStrRgh:文字列用(打消線右寄せ(Str))
        fwrite($fp, '        <Style ss:ID="StrStrRgh" ss:Parent="StrRgh">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrStrCtr:文字列用(打消線中央寄(Ctr))
        fwrite($fp, '        <Style ss:ID="StrStrCtr" ss:Parent="StrStr">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrSep:文字列用(下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="StrSep" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrStrSep:文字列用(打消線(Str)/下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="StrStrSep" ss:Parent="StrSep">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrDbl:文字列用(下二重線(Dbl))
        fwrite($fp, '        <Style ss:ID="StrDbl" ss:Parent="Str">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Double" ss:Weight="3"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrDblRgh:文字列用(下二重線(Dbl)/右寄(Rgh))
        fwrite($fp, '        <Style ss:ID="StrDblRgh" ss:Parent="StrDbl">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrDblBld:文字列用(下二重線(Dbl)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="StrDblBld" ss:Parent="StrDbl">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // StrDblBldRgh:文字列用(下二重線(Dbl)/太字(Bld)/右寄(Rgh))
        fwrite($fp, '        <Style ss:ID="StrDblBldRgh" ss:Parent="StrDblBld">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        /*------------------------------------*/
        /* 時刻用                             */
        /*------------------------------------*/
        // Dat:時刻用
        fwrite($fp, '        <Style ss:ID="Dat" ss:Parent="FmtAll">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="yyyy/mm/dd hh:mm"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // DatStr:時刻用(打消線(Str))
        fwrite($fp, '        <Style ss:ID="DatStr" ss:Parent="Dat">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // DatSep:時刻用(下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="DatSep" ss:Parent="Dat">'.$LF);
        fwrite($fp, '            <Borders>'.$LF);
        fwrite($fp, '                <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '                <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>'.$LF);
        fwrite($fp, '            </Borders>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // DatStrSep:時刻用(打消線(Str)/下線太線(Sep))
        fwrite($fp, '        <Style ss:ID="DatStrSep" ss:Parent="DatSep">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumDat:時刻用 （合計行）
        fwrite($fp, '        <Style ss:ID="SumDat" ss:Parent="Dat">'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevDat:時刻用 （前残行）
        fwrite($fp, '        <Style ss:ID="PrevDat" ss:Parent="Dat">'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        /*------------------------------------*/
        /* 合計行                             */
        /*------------------------------------*/
        // SumNumeric:合計行（カンマなし数値用、小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="SumNumeric" ss:Parent="Numeric">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumComma:合計行（カンマ付数値用、小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="SumComma" ss:Parent="Comma">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // Sum:合計行（金額）
        fwrite($fp, '        <Style ss:ID="Sum" ss:Parent="Amt">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumNum:合計行（カンマ付数値、小数点なし）
        fwrite($fp, '        <Style ss:ID="SumNum" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumRate:合計行（レート用）
        fwrite($fp, '        <Style ss:ID="SumRate" ss:Parent="Rate">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#B6DDE8" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumBld:合計行(太字(Bld))
        fwrite($fp, '        <Style ss:ID="SumBld" ss:Parent="Sum">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumBldPct:合計行(太字(Bld)/パーセント(Pct))
        fwrite($fp, '        <Style ss:ID="SumBldPct" ss:Parent="SumBld">'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="0%"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumCtr:合計行(中央寄(Ctr))
        fwrite($fp, '        <Style ss:ID="SumCtr" ss:Parent="Sum">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumCtrBld:合計行(中央寄(Ctr)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="SumCtrBld" ss:Parent="SumCtr">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumLftBld:合計行(左寄(Lft)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="SumLftBld" ss:Parent="Sum">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // SumLftBldID1:合計行(左寄(Lft)/太字(Bld)/段落:1(ID1))
        fwrite($fp, '        <Style ss:ID="SumLftBldID1" ss:Parent="SumLftBld">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);

        /*------------------------------------*/
        /* 前残行                             */
        /*------------------------------------*/
        // PrevNumeric:前残行（カンマなし数値用、小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="PrevNumeric" ss:Parent="Numeric">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevComma:前残行（カンマ付数値用、小数点以下8桁まで可変表示）
        fwrite($fp, '        <Style ss:ID="PrevComma" ss:Parent="Comma">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // Prev:前残行（金額）
        fwrite($fp, '        <Style ss:ID="Prev" ss:Parent="Amt">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevNum:前残行（カンマ付数値、小数点なし）
        fwrite($fp, '        <Style ss:ID="PrevNum" ss:Parent="Num">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevRate:前残行（レート用）
        fwrite($fp, '        <Style ss:ID="PrevRate" ss:Parent="Rate">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Right" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Interior ss:Color="#DDECBC" ss:Pattern="Solid"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevBld:前残行(太字(Bld))
        fwrite($fp, '        <Style ss:ID="PrevBld" ss:Parent="Prev">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevBldPct:前残行(太字(Bld)/パーセント(Pct))
        fwrite($fp, '        <Style ss:ID="PrevBldPct" ss:Parent="PrevBld">'.$LF);
        fwrite($fp, '            <NumberFormat ss:Format="0%"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevCtr:前残行(中央寄(Ctr))
        fwrite($fp, '        <Style ss:ID="PrevCtr" ss:Parent="Prev">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevCtrBld:前残行(中央寄(Ctr)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="PrevCtrBld" ss:Parent="PrevCtr">'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevLftBld:前残行(左寄(Lft)/太字(Bld))
        fwrite($fp, '        <Style ss:ID="PrevLftBld" ss:Parent="Prev">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center"/>'.$LF);
        fwrite($fp, '            <Font ss:FontName="Tahoma" x:CharSet="128" x:Family="Swiss" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        // PrevLftBldID1:前残行(左寄(Lft)/太字(Bld)/段落:1(ID1))
        fwrite($fp, '        <Style ss:ID="PrevLftBldID1" ss:Parent="PrevLftBld">'.$LF);
        fwrite($fp, '            <Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="1"/>'.$LF);
        fwrite($fp, '        </Style>'.$LF);
        
        fwrite($fp, '    </Styles>'.$LF);
    }
    
    // EXCELフッタ出力
    private function cExcelFooter($fp) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        fwrite($fp, '</Workbook>'.$LF);
        fwrite($fp, $LF);
    }
    
    // ワークシートオプション
    private function cWorksheetOptionsData($fp) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        fwrite($fp, '        <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">'.$LF);
        fwrite($fp, '            <PageSetup>'.$LF);
        fwrite($fp, '                <Layout x:Orientation="Landscape"/>'.$LF);
        fwrite($fp, '                <Header x:Margin="0.19685039370078741"/>'.$LF);
        fwrite($fp, '                <Footer x:Margin="0.19685039370078741" x:Data="&amp;C&amp;A&amp;R&amp;P/&amp;N"/>'.$LF);
        fwrite($fp, '                <PageMargins x:Bottom="0.39370078740157483" x:Left="0.19685039370078741" x:Right="0.19685039370078741" x:Top="0.19685039370078741"/>'.$LF);
        fwrite($fp, '            </PageSetup>'.$LF);
        fwrite($fp, '            <Unsynced/>'.$LF);
        fwrite($fp, '            <FitToPage/>'.$LF);
        fwrite($fp, '            <Print>'.$LF);
        fwrite($fp, '                <FitHeight>0</FitHeight>'.$LF);
        fwrite($fp, '                <ValidPrinterInfo/>'.$LF);
        fwrite($fp, '                <PaperSizeIndex>9</PaperSizeIndex>'.$LF);
        fwrite($fp, '                <Scale>79</Scale>'.$LF);
        fwrite($fp, '                <VerticalResolution>0</VerticalResolution>'.$LF);
        fwrite($fp, '            </Print>'.$LF);
        fwrite($fp, '            <Zoom>70</Zoom>'.$LF);
        fwrite($fp, '            <Selected/>'.$LF);
        fwrite($fp, '            <ProtectObjects>False</ProtectObjects>'.$LF);
        fwrite($fp, '            <ProtectScenarios>False</ProtectScenarios>'.$LF);
        fwrite($fp, '        </WorksheetOptions>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 検索条件                                               */
/*--------------------------------------------------------*/
    public function cDBText($TrdLbl, $AdjLbl, $TrdVal, $AdjVal) {
        $this->CL['LG']->cLog('T0002');
        $ret = $TrdLbl.$TrdVal.$this->CL['DF']->LF.$AdjLbl.$AdjVal;
        return $ret;
    }
    
    private function cExcelCondition($fp, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 先頭
        fwrite($fp, '    <Worksheet ss:Name="'.$this->CL['DF']->Condition.'">'.$LF);
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="3" ss:AutoFitWidth="0" ss:Width="117"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="300"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // 検索条件
        if (count($Head) > 0) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2"><Data ss:Type="String">■'.$this->lbl_SerachCondition.'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);

            for ($i = 0; $i < count($Head); $i++){
                fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.self::strEscape($Head[$i]).'</Data></Cell>'.$LF);
                if (substr_count($Main[$i], $this->CL['DF']->BR)>0){
                    fwrite($fp, '                <Cell ss:StyleID="StrWrp"><Data ss:Type="String">'.self::strEscape($this->CL['FC']->cStr($this->CL['DF']->BR, ', ', $Main[$i])).'</Data></Cell>'.$LF);
                } elseif(is_numeric($this->CL['FC']->gIntFmt($Main[$i]))) {
                    fwrite($fp, '                <Cell ss:StyleID="NumLft"><Data ss:Type="Number">'.$Main[$i].'</Data></Cell>'.$LF);
                } else {
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.self::strEscape($Main[$i]).'</Data></Cell>'.$LF);
                }
                fwrite($fp, '            </Row>'.$LF);
            }

            fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        }
        
        // 検索者
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2"><Data ss:Type="String">■'.$this->lbl_SerachUser.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_CompanyName.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['SW']->gCompanyNameVal().'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_UserID.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$_SESSION[$this->CL['DF']->SysID]['UserID'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_UserName.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$_SESSION[$this->CL['DF']->SysID]['UserName'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_UserAuth.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['SW']->gConstAuthNameVal().'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // 実施場所/時刻
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2"><Data ss:Type="String">■'.$this->lbl_LocationTime.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_Screen.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['FC']->gCurrentFile($this->CL['DF']->gCurrentFile_delParam).'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_Language.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['SW']->gConstLangVal().'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_Time.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.date_format(new DateTime('now', new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale'])), "Y-m-d").' '.date_format(new DateTime('now', new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale'])), "H:i:s").'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$this->lbl_Location.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$_SESSION[$this->CL['DF']->SysID]['Locale'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        fwrite($fp, '        <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">'.$LF);
        fwrite($fp, '            <PageSetup>'.$LF);
        fwrite($fp, '                <Header x:Margin="0.19685039370078741"/>'.$LF);
        fwrite($fp, '                <Footer x:Margin="0.19685039370078741" x:Data="&amp;C&amp;A"/>'.$LF);
        fwrite($fp, '                <PageMargins x:Bottom="0.19685039370078741" x:Left="0.19685039370078741" x:Right="0.19685039370078741" x:Top="0.19685039370078741"/>'.$LF);
        fwrite($fp, '            </PageSetup>'.$LF);
        fwrite($fp, '            <Unsynced/>'.$LF);
        fwrite($fp, '            <Print>'.$LF);
        fwrite($fp, '                <ValidPrinterInfo/>'.$LF);
        fwrite($fp, '                <PaperSizeIndex>9</PaperSizeIndex>'.$LF);
        fwrite($fp, '                <VerticalResolution>0</VerticalResolution>'.$LF);
        fwrite($fp, '            </Print>'.$LF);
        fwrite($fp, '            <Zoom>70</Zoom>'.$LF);
        fwrite($fp, '            <Selected/>'.$LF);
        fwrite($fp, '            <ProtectObjects>False</ProtectObjects>'.$LF);
        fwrite($fp, '            <ProtectScenarios>False</ProtectScenarios>'.$LF);
        fwrite($fp, '        </WorksheetOptions>'.$LF);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 汎用リスト（べた打ち）                                       */
/*--------------------------------------------------------*/
    // メイン出力
    private function cExcelList($fp, $SheetName, $Head, $Main, $DataType = NULL, $TotalData = NULL, $BeginData = NULL, $Status = NULL) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="18.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        if (count($Head)>0) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            for ($i = 0; $i < count($Head); $i++) {
                $Idx = '';
                if ($i == 0) {
                    $Idx = 'ss:Index="2" ';
                }
                fwrite($fp, '                <Cell '.$Idx.'ss:StyleID="Ttl"><Data ss:Type="String">'.self::strEscape($Head[$i]).'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }

        // 前繰越
        if ($BeginData) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            for ($j = 0; $j < count($BeginData); $j++) {
                $Idx ='';
                if ($j == 0) {
                    $Idx = 'ss:Index="2" ';
                }
                $data = $BeginData[$j];
                $StyleID = 'Prev';
                $Type = 'String';

                $pType = 0;
                if ($DataType != NULL){
                    $pType = $DataType[$j];
                }
                
                switch ($pType) {
                    case $this->CL['DF']->ExItemNumber:   // 数字として出力
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'PrevNumeric';
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemComma:    // カンマつき数字として出力
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'PrevComma';
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemInteger:  // 小数点なしの数字として表示
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'PrevNum';
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemMoney:    // 金額として編集して表示（システム内の小数点以下の桁数で編集）
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'Prev';
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemRate:     // レートとして編集して表示（システム内の小数点以下の桁数で編集）
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'PrevRate';
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemDateTime: // 日時として表示
                        $data = $this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $data);
                        $StyleID = 'PrevDat';
                        $Type = 'DateTime';
                        break;
                }
                fwrite($fp, '                <Cell '.$Idx.' ss:StyleID="'.$StyleID.'"><Data ss:Type="'.$Type.'">'.self::strEscape($data).'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }

        // メイン
        for ($i = 0, $c = count($Main[0]); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            for ($j = 0; $j < count($Main); $j++) {
                $Idx = '';
                if ($j == 0) {
                    $Idx = 'ss:Index="2" ';
                }

                $strline = true;
                if ($Status) {
                    $strline = $Status[$i];
                }
                
                $data = $Main[$j][$i];
                $StyleID = self::gStrikeOut($strline, 'Str', 'StrStr');
                $Type = 'String';
                
                $pType = 0;
                if ($DataType != NULL){
                    $pType = $DataType[$j];
                }
                
                switch ($pType) {
                    case $this->CL['DF']->ExItemRight:    // 右詰で出力
                        $StyleID = self::gStrikeOut($strline, 'StrRgh', 'StrStrRgh') ;
                        break;
                    case $this->CL['DF']->ExItemNumber:   // 数字として出力
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = self::gStrikeOut($strline, 'Numeric', 'NumericStr') ;
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemComma:    // カンマつき数字として出力
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = self::gStrikeOut($strline, 'Comma', 'CommaStr') ;
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemInteger:  // 小数点なしの数字として表示
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = 'Num';
                            $StyleID = self::gStrikeOut($strline, 'Num', 'NumStr') ;
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemMoney:    // 金額として編集して表示（システム内の小数点以下の桁数で編集）
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = self::gStrikeOut($strline, 'Amt', 'AmtStr') ;
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemRate:     // レートとして編集して表示（システム内の小数点以下の桁数で編集）
                        $wdata = $this->CL['FC']->gIntFmt($data);
                        if (is_numeric($wdata)) {
                            $data = $wdata;
                            $StyleID = self::gStrikeOut($strline, 'Rate', 'RateStr') ;
                            $Type = 'Number';
                        }
                        break;
                    case $this->CL['DF']->ExItemDateTime: // 日時として表示
                        $data = $this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $data);
                        $StyleID = 'Dat';
                        $StyleID = self::gStrikeOut($strline, 'Dat', 'DatStr') ;
                        $Type = 'DateTime';
                        break;
                }
                fwrite($fp, '                <Cell '.$Idx.' ss:StyleID="'.$StyleID.'"><Data ss:Type="'.$Type.'">'.self::strEscape($data).'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計行
        if ($TotalData) {
            for ($i = 0; $i < count($TotalData); $i++) {
                fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                for ($j = 0; $j < count($TotalData[$i]); $j++) {
                    $Idx ='';
                    if ($j == 0) {
                        $Idx = 'ss:Index="2" ';
                    }
                    $data = $TotalData[$i][$j];
                    $StyleID = 'Sum';
                    $Type = 'String';

                    $pType = 0;
                    if ($DataType != NULL){
                        $pType = $DataType[$j];
                    }
                    
                    switch ($pType) {
                        case $this->CL['DF']->ExItemNumber:   // 数字として出力
                            $wdata = $this->CL['FC']->gIntFmt($data);
                            if (is_numeric($wdata)) {
                                $data = $wdata;
                                $StyleID = 'SumNumeric';
                                $Type = 'Number';
                            }
                            break;
                        case $this->CL['DF']->ExItemComma:    // カンマつき数字として出力
                            $wdata = $this->CL['FC']->gIntFmt($data);
                            if (is_numeric($wdata)) {
                                $data = $wdata;
                                $StyleID = 'SumComma';
                                $Type = 'Number';
                            }
                            break;
                        case $this->CL['DF']->ExItemInteger:  // 小数点なしの数字として表示
                            $wdata = $this->CL['FC']->gIntFmt($data);
                            if (is_numeric($wdata)) {
                                $data = $wdata;
                                $StyleID = 'SumNum';
                                $Type = 'Number';
                            }
                            break;
                        case $this->CL['DF']->ExItemMoney:    // 金額として編集して表示（システム内の小数点以下の桁数で編集）
                            $wdata = $this->CL['FC']->gIntFmt($data);
                            if (is_numeric($wdata)) {
                                $data = $wdata;
                                $StyleID = 'Sum';
                                $Type = 'Number';
                            }
                            break;
                        case $this->CL['DF']->ExItemRate:     // レートとして編集して表示（システム内の小数点以下の桁数で編集）
                            $wdata = $this->CL['FC']->gIntFmt($data);
                            if (is_numeric($wdata)) {
                                $data = $wdata;
                                $StyleID = 'SumRate';
                                $Type = 'Number';
                            }
                            break;
                        case $this->CL['DF']->ExItemDateTime: // 日時として表示
                            $data = $this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $data);
                            $StyleID = 'SumDat';
                            $Type = 'DateTime';
                            break;
                    }
                    fwrite($fp, '                <Cell '.$Idx.' ss:StyleID="'.$StyleID.'"><Data ss:Type="'.$Type.'">'.self::strEscape($data).'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
                }
                fwrite($fp, '            </Row>'.$LF);
            }
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
    private function gStrikeOut($cond, $rettrue, $retfalse) {
        if ($cond) {
            return $rettrue;
        }
        return $retfalse;
    }
/*--------------------------------------------------------*/
/* マイビュー                                             */
/*--------------------------------------------------------*/
    // メイン出力(マイビュー)
    private function cExcelMyView($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_Period    = $Head[$i++];
        $lbl_Number    = $Head[$i++];
        $lbl_CfmSts    = $Head[$i++];
        $lbl_UnApprove = $Head[$i++];
        $lbl_Approved  = $Head[$i++];
        $lbl_Posted    = $Head[$i++];
        $lbl_Cfm       = $Head[$i++];
        $lbl_Cls       = $Head[$i++];
        $lbl_Total     = $Head[$i++];
        $lbl_CfmUser   = $Head[$i++];
        $lbl_CfmDate   = $Head[$i++];
        
        $MTrVal             = $Main[$j++];
        $MCfmDateVal        = $Main[$j++];
        $MUnApproveExcelVal = $Main[$j++];
        $MApprovedExcelVal  = $Main[$j++];
        $MPostedVal         = $Main[$j++];
        $MCfmVal            = $Main[$j++];
        $MClsVal            = $Main[$j++];
        $MTotalVal          = $Main[$j++];
        $MCfmStsNameVal     = $Main[$j++];
        $MUnapproveTotal    = $Main[$j++];
        $MApprovedTotal     = $Main[$j++];
        $MPostedTotal       = $Main[$j++];
        $MCfmTotal          = $Main[$j++];
        $MClsTotal          = $Main[$j++];
        $MAllTotal          = $Main[$j++];
        $MCfmNamVal         = $Main[$j++];
        $MCfmDatVal         = $Main[$j++];
        $MCfmStsIDVal       = $Main[$j++];

        $DTrVal             = $Main[$j++];
        $DCfmDateVal        = $Main[$j++];
        $DUnApproveExcelVal = $Main[$j++];
        $DApprovedExcelVal  = $Main[$j++];
        $DPostedVal         = $Main[$j++];
        $DCfmVal            = $Main[$j++];
        $DClsVal            = $Main[$j++];
        $DTotalVal          = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="134.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="9" ss:Width="84"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="10" ss:Width="84"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="11" ss:Width="110"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル(月)
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Period.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Number.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmSts.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UnApprove.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Approved.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Posted.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cfm.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cls.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン(月)
        for ($i = 1, $c = count($MTrVal); $i <= $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="StrCtr"><Data ss:Type="String">'.$MCfmDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MUnApproveExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MApprovedExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MPostedVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MCfmVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MClsVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$MTotalVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$MCfmStsNameVal[$i].'</Data></Cell>'.$LF);
            if ($MCfmStsIDVal[$i] == $this->CL['DF']->cfmSts_UnCfm) {
                fwrite($fp, '                <Cell ss:StyleID="Str"/>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"/>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$MCfmNamVal[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt19, $MCfmDatVal[$i]).'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計(月)
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MUnapproveTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MApprovedTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MPostedTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MCfmTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MClsTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$MAllTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // タイトル(日)
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Period.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Number.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UnApprove.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Approved.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Posted.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cfm.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cls.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン(日)
        for ($i = 1, $c = count($DTrVal); $i <= $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="StrCtr"><Data ss:Type="String">'.$DCfmDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DUnApproveExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DApprovedExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DPostedVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DCfmVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DClsVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$DTotalVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 取引先情報                                             */
/*--------------------------------------------------------*/
    // メイン出力(取引先情報)
    private function cExcelClient($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No             = $Head[$i++];
        $lbl_CltID          = $Head[$i++];
        $lbl_CltName        = $Head[$i++];
        $lbl_CltSupplierFlg = $Head[$i++];
        $lbl_CltClientFlg   = $Head[$i++];
        $lbl_CreateDate     = $Head[$i++];
        
        $NoVal          = $Main[$j++];
        $CltIdExcelVal  = $Main[$j++];
        $CltNameVal     = $Main[$j++];
        $SupplierFlgVal = $Main[$j++];
        $ClientFlgVal   = $Main[$j++];
        $EntryDateVal   = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="18.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltID.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltName.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltSupplierFlg.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltClientFlg.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreateDate.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($NoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltIdExcelVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltNameVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$SupplierFlgVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$ClientFlgVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $EntryDateVal[$i]).'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* ユーザ情報                                             */
/*--------------------------------------------------------*/
    // メイン出力(ユーザ情報)
    private function cExcelUser($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No          = $Head[$i++];
        $lbl_UserID      = $Head[$i++];
        $lbl_UserAuth    = $Head[$i++];
        $lbl_DefLangID   = $Head[$i++];
        $lbl_UserName    = $Head[$i++];
        $lbl_MailAddress = $Head[$i++];
        $lbl_SearchDate  = $Head[$i++];
        
        $NoVal           = $Main[$j++];
        $UserIdExcelVal  = $Main[$j++];
        $AutNameVal      = $Main[$j++];
        $LngNameVal      = $Main[$j++];
        $UserNameVal     = $Main[$j++];
        $MailAddressVal  = $Main[$j++];
        $EntryDateVal    = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="18.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="5" ss:Width="89.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="150"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="105.75"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UserID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UserAuth.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DefLangID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UserName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_MailAddress.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_SearchDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($NoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$UserIdExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AutNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$LngNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$UserNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$MailAddressVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $EntryDateVal[$i]).'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 勘定科目情報                                           */
/*--------------------------------------------------------*/
    // メイン出力(勘定科目情報)
    private function cExcelAccount($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No         = $Head[$i++];
        $lbl_AccID      = $Head[$i++];
        $lbl_AccLName   = $Head[$i++];
        $lbl_AccMName   = $Head[$i++];
        $lbl_AccSName   = $Head[$i++];
        $lbl_AccKind1   = $Head[$i++];
        $lbl_AccKind2   = $Head[$i++];
        $lbl_AccKind3   = $Head[$i++];
        $lbl_AccKind4   = $Head[$i++];
        $lbl_AccKind5   = $Head[$i++];
        $lbl_SubLedFlg  = $Head[$i++];
        $lbl_ViceExpDmt = $Head[$i++];
        $lbl_ViceExpInt = $Head[$i++];
        $lbl_CreateDate = $Head[$i++];
        
        $NoVal            = $Main[$j++];
        $AccIdExcelVal    = $Main[$j++];
        $AccTitleLNameVal = $Main[$j++];
        $AccTitleMNameVal = $Main[$j++];
        $AccTitleSNameVal = $Main[$j++];
        $AccKind1NameVal  = $Main[$j++];
        $AccKind2NameVal  = $Main[$j++];
        $AccKind3NameVal  = $Main[$j++];
        $AccKind4NameVal  = $Main[$j++];
        $AccKind5NameVal  = $Main[$j++];
        $SubLedFlgVal     = $Main[$j++];
        $ViceExpDmtVal    = $Main[$j++];
        $ViceExpIntVal    = $Main[$j++];
        $EntryDateVal     = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="24.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="112.5" ss:Span="7"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="14" ss:Width="94.5"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="28.5">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccLName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccKind1.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccKind2.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccKind3.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccKind4.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccKind5.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_SubLedFlg.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ViceExpDmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ViceExpInt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreateDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($NoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccIdExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleLNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleMNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleSNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccKind1NameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccKind2NameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccKind3NameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccKind4NameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccKind5NameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$SubLedFlgVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$ViceExpDmtVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$ViceExpIntVal[$i].'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            $val = $this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $EntryDateVal[$i]);
            if ($val != '-') {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$val.'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="String">'.$val.'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 仕訳帳情報                                             */
/*--------------------------------------------------------*/
    // メイン出力(仕訳帳情報)
    private function cExcelJournal($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No          = $Head[$i++];
        $lbl_TrnID       = $Head[$i++];
        $lbl_NumLine     = $Head[$i++];
        $lbl_JnlKind     = $Head[$i++];
        $lbl_TrnKind     = $Head[$i++];
        $lbl_AccrualDate = $Head[$i++];
        $lbl_CltName     = $Head[$i++];
        $lbl_TrnSts      = $Head[$i++];
        $lbl_Summary     = $Head[$i++];
        $lbl_Debit       = $Head[$i++];
        $lbl_Credit      = $Head[$i++];
        $lbl_LedS        = $Head[$i++];
        $lbl_Inputuser   = $Head[$i++];
        $lbl_DebitAmt    = $Head[$i++];
        $lbl_CreditAmt   = $Head[$i++];
        $lbl_AccLName    = $Head[$i++];
        $lbl_AccMName    = $Head[$i++];
        $lbl_AccSName    = $Head[$i++];
        $lbl_Prev        = $Head[$i++];
        $lbl_This        = $Head[$i++];
        $lbl_Next        = $Head[$i++];
        
        $CarryOverTotalPrevDr = $Main[$j++];
        $CarryOverTotalPrevCr = $Main[$j++];
        $TrVal                = $Main[$j++];
        $GenTrnPageList       = $Main[$j++];
        $NoVal                = $Main[$j++];
        $JnlIDVal             = $Main[$j++];
        $LineViewVal          = $Main[$j++];
        $JnlKindNameVal       = $Main[$j++];
        $TrnKindNameVal       = $Main[$j++];
        $TrnDateVal           = $Main[$j++];
        $CltNameVal           = $Main[$j++];
        $TrnStsNameVal        = $Main[$j++];
        $SummaryVal           = $Main[$j++];
        $AccTitleDrLNameVal   = $Main[$j++];
        $AccTitleDrMNameVal   = $Main[$j++];
        $AccTitleDrSNameVal   = $Main[$j++];
        $AccTitleCrLNameVal   = $Main[$j++];
        $AccTitleCrMNameVal   = $Main[$j++];
        $AccTitleCrSNameVal   = $Main[$j++];
        $LedExcelVal          = $Main[$j++];
        $UsrNameVal           = $Main[$j++];
        $AmtDrVal             = $Main[$j++];
        $AmtCrVal             = $Main[$j++];
        $CarryOverTotalThisDr = $Main[$j++];
        $CarryOverTotalThisCr = $Main[$j++];
        $CarryOverTotalNextDr = $Main[$j++];
        $CarryOverTotalNextCr = $Main[$j++];
        
        // タグ落とし
        $tag = array('<span class="doubleline">', '</span>');
        $LineViewVal        = $this->CL['FC']->dStrTag($LineViewVal       , $tag);
        $TrnKindNameVal     = $this->CL['FC']->dStrTag($TrnKindNameVal    , $tag);
        $JnlKindNameVal     = $this->CL['FC']->dStrTag($JnlKindNameVal    , $tag);
        $TrnDateVal         = $this->CL['FC']->dStrTag($TrnDateVal        , $tag);
        $CltNameVal         = $this->CL['FC']->dStrTag($CltNameVal        , $tag);
        $TrnStsNameVal      = $this->CL['FC']->dStrTag($TrnStsNameVal     , $tag);
        $SummaryVal         = $this->CL['FC']->dStrTag($SummaryVal        , $tag);
        $UsrNameVal         = $this->CL['FC']->dStrTag($UsrNameVal        , $tag);
        $AccTitleDrLNameVal = $this->CL['FC']->dStrTag($AccTitleDrLNameVal, $tag);
        $AccTitleDrMNameVal = $this->CL['FC']->dStrTag($AccTitleDrMNameVal, $tag);
        $AccTitleDrSNameVal = $this->CL['FC']->dStrTag($AccTitleDrSNameVal, $tag);
        $AmtDrVal           = $this->CL['FC']->dStrTag($AmtDrVal          , $tag);
        $AccTitleCrLNameVal = $this->CL['FC']->dStrTag($AccTitleCrLNameVal, $tag);
        $AccTitleCrMNameVal = $this->CL['FC']->dStrTag($AccTitleCrMNameVal, $tag);
        $AccTitleCrSNameVal = $this->CL['FC']->dStrTag($AccTitleCrSNameVal, $tag);
        $AmtCrVal           = $this->CL['FC']->dStrTag($AmtCrVal          , $tag);
        
        // 区切,打消
        $TrVal = self::cDesign($TrVal, $GenTrnPageList);
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="23.25"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="50.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="11" ss:Width="117" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_NumLine.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_JnlKind.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnKind.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnSts.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Debit.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Credit.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_LedS.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Inputuser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="11" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccLName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccLName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 前繰越
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="16" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalPrevDr).'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalPrevCr).'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($NoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            switch ($TrVal[$i]) {
                case $this->CL['DF']->ExcelStyle_Non:       // 区切:無/打消:無
                    fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['FC']->gTrnIDFmt($this->CL['DF']->gTrnIDFmt5, $JnlIDVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$LineViewVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$JnlKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="String">'.$TrnDateVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnStsNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$SummaryVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleDrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleDrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleDrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleCrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleCrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleCrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$LedExcelVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$UsrNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtDrVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtCrVal[$i]).'</Data></Cell>'.$LF);
                    break;
                case $this->CL['DF']->ExcelStyle_Str:       // 区切:無/打消:有
                    fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="NumStr"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$this->CL['FC']->gTrnIDFmt($this->CL['DF']->gTrnIDFmt5, $JnlIDVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumStr"><Data ss:Type="Number">'.$LineViewVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$JnlKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$TrnKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="DatStr"><Data ss:Type="String">'.$TrnDateVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$CltNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$TrnStsNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$SummaryVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleDrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleDrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleDrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleCrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleCrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$AccTitleCrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumStr"><Data ss:Type="Number">'.$LedExcelVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStr"><Data ss:Type="String">'.$UsrNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtStr"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtDrVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtStr"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtCrVal[$i]).'</Data></Cell>'.$LF);
                    break;
                case $this->CL['DF']->ExcelStyle_Sep:       // 区切:有/打消:無
                    fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="NumSep"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$this->CL['FC']->gTrnIDFmt($this->CL['DF']->gTrnIDFmt5, $JnlIDVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumSep"><Data ss:Type="Number">'.$LineViewVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$JnlKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$TrnKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="DatSep"><Data ss:Type="String">'.$TrnDateVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$CltNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$TrnStsNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$SummaryVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleDrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleDrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleDrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleCrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleCrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$AccTitleCrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumSep"><Data ss:Type="Number">'.$LedExcelVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrSep"><Data ss:Type="String">'.$UsrNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtSep"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtDrVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtSep"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtCrVal[$i]).'</Data></Cell>'.$LF);
                    break;
                case $this->CL['DF']->ExcelStyle_SepStr:    // 区切:有/打消:有
                    fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="NumStrSep"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$this->CL['FC']->gTrnIDFmt($this->CL['DF']->gTrnIDFmt5, $JnlIDVal[$i]).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumStrSep"><Data ss:Type="Number">'.$LineViewVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$JnlKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$TrnKindNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="DatStrSep"><Data ss:Type="String">'.$TrnDateVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$CltNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$TrnStsNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$SummaryVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleDrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleDrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleDrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleCrLNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleCrMNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$AccTitleCrSNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="NumStrSep"><Data ss:Type="Number">'.$LedExcelVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="StrStrSep"><Data ss:Type="String">'.$UsrNameVal[$i].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtStrSep"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($this->CL['FC']->gIntFmt($AmtDrVal[$i])).'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="AmtStrSep"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($AmtCrVal[$i]).'</Data></Cell>'.$LF);
                    break;
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 当頁合計
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="16" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_This.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalThisDr).'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalThisCr).'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 次繰越
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="16" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Next.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalNextDr).'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$this->CL['FC']->gIntFmt($CarryOverTotalNextCr).'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 取引情報                                               */
/*--------------------------------------------------------*/
    // メイン出力(取引情報)
    private function cExcelTransaction($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No          = $Head[$i++];
        $lbl_TrnID       = $Head[$i++];
        $lbl_JnlKind     = $Head[$i++];
        $lbl_TrnKind     = $Head[$i++];
        $lbl_AccrualDate = $Head[$i++];
        $lbl_TrnSts      = $Head[$i++];
        $lbl_Summary     = $Head[$i++];
        $lbl_CfmDate     = $Head[$i++];
        $lbl_CfmUser     = $Head[$i++];
        $lbl_PostDate    = $Head[$i++];
        $lbl_PostUser    = $Head[$i++];
        $lbl_ApproveDate = $Head[$i++];
        $lbl_ApproveUser = $Head[$i++];
        $lbl_CreateDate  = $Head[$i++];
        $lbl_CreateUser  = $Head[$i++];
        $lbl_Total       = $Head[$i++];
        $lbl_Prev        = $Head[$i++];
        $lbl_Next        = $Head[$i++];
        
        $TrVal              = $Main[$j++];
        $NoVal              = $Main[$j++];
        $TrnIDExcelVal      = $Main[$j++];
        $JnlKindNameVal     = $Main[$j++];
        $TrnKindNameVal     = $Main[$j++];
        $TrnDateVal         = $Main[$j++];
        $TrnStsNameVal      = $Main[$j++];
        $SummaryVal         = $Main[$j++];
        $ConfirmDateVal     = $Main[$j++];
        $ConfirmUserVal     = $Main[$j++];
        $PostDateVal        = $Main[$j++];
        $PostUserVal        = $Main[$j++];
        $ApproveDateVal     = $Main[$j++];
        $ApproveUserVal     = $Main[$j++];
        $EntryDateVal       = $Main[$j++];
        $EntryUserVal       = $Main[$j++];
        $DrAmtVal           = $Main[$j++];
        $CarryOverPrevTotal = $Main[$j++];
        $CarryOverNextTotal = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="18.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="5" ss:Width="94.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="95.25"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="97.5" ss:Span="2"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="10" ss:Width="94.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="68.25"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="94.5"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_JnlKind.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnKind.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnSts.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PostDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PostUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ApproveDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ApproveUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreateDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreateUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 前繰越
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="14" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverPrevTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($TrVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$this->CL['FC']->gTrnIDFmt($this->CL['DF']->gTrnIDFmt5, $TrnIDExcelVal[$i]).'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$JnlKindNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnKindNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnStsNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$SummaryVal[$i].'</Data></Cell>'.$LF);
            if ($ConfirmDateVal[$i] == '') {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $ConfirmDateVal[$i]).'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$ConfirmUserVal[$i].'</Data></Cell>'.$LF);
            }
            if ($PostDateVal[$i] == '') {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $PostDateVal[$i]).'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$PostUserVal[$i].'</Data></Cell>'.$LF);
            }
            if ($ApproveDateVal[$i] == '') {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $ApproveDateVal[$i]).'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$ApproveUserVal[$i].'</Data></Cell>'.$LF);
            }
            if ($EntryDateVal[$i] == '') {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt17, $EntryDateVal[$i]).'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$EntryUserVal[$i].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrAmtVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="14" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Next.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverNextTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 月次確定情報                                           */
/*--------------------------------------------------------*/
    // メイン出力(月次確定情報)
    private function cExcelMoCfm($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_Period    = $Head[$i++];
        $lbl_Number    = $Head[$i++];
        $lbl_CfmSts    = $Head[$i++];
        $lbl_UnApprove = $Head[$i++];
        $lbl_Approved  = $Head[$i++];
        $lbl_Posted    = $Head[$i++];
        $lbl_Cfm       = $Head[$i++];
        $lbl_Cls       = $Head[$i++];
        $lbl_Total     = $Head[$i++];
        $lbl_CfmUser   = $Head[$i++];
        $lbl_CfmDate   = $Head[$i++];
        
        $TrVal             = $Main[$j++];
        $CfmDateVal        = $Main[$j++];
        $UnApproveExcelVal = $Main[$j++];
        $ApprovedExcelVal  = $Main[$j++];
        $PostedVal         = $Main[$j++];
        $CfmVal            = $Main[$j++];
        $ClsVal            = $Main[$j++];
        $TotalVal          = $Main[$j++];
        $CfmStsNameVal     = $Main[$j++];
        $UnapproveTotal    = $Main[$j++];
        $ApprovedTotal     = $Main[$j++];
        $PostedTotal       = $Main[$j++];
        $CfmTotal          = $Main[$j++];
        $ClsTotal          = $Main[$j++];
        $AllTotal          = $Main[$j++];
        $CfmNamVal         = $Main[$j++];
        $CfmDatVal         = $Main[$j++];
        $CfmStsIDVal       = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="134.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="45.75" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="9" ss:Width="84"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="10" ss:Width="84"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="11" ss:Width="110"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Period.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Number.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmSts.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmUser.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CfmDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_UnApprove.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Approved.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Posted.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cfm.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Cls.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 1, $c = count($TrVal); $i <= $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="StrCtr"><Data ss:Type="String">'.$CfmDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$UnApproveExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$ApprovedExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$PostedVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$CfmVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$ClsVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number">'.$TotalVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CfmStsNameVal[$i].'</Data></Cell>'.$LF);
            if ($CfmStsIDVal[$i] == $this->CL['DF']->cfmSts_UnCfm) {
                fwrite($fp, '                <Cell ss:StyleID="Str"/>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Str"/>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CfmNamVal[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Dat"><Data ss:Type="DateTime">'.$this->CL['FC']->gDateFmt($this->CL['DF']->gDateFmt19, $CfmDatVal[$i]).'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$UnapproveTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ApprovedTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$PostedTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CfmTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClsTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 標準式総勘定元帳                                        */
/*--------------------------------------------------------*/
    // メイン出力(標準式総勘定元帳)
    private function cExcelGeneralLedgerT($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        
        $lbl_Debit          = $Head[$i++];
        $lbl_Credit         = $Head[$i++];
        $lbl_No             = $Head[$i++];
        $lbl_AccrualDate    = $Head[$i++];
        $lbl_PartnerAcc     = $Head[$i++];
        $lbl_Amt            = $Head[$i++];
        $lbl_JnlKindS       = $Head[$i++];

        $lbl_Prev           = $Head[$i++];
        $lbl_This           = $Head[$i++];
        $lbl_Next           = $Head[$i++];

        $lbl_GrandTotal     = $Head[$i++];
        
        $DrStatus               = $Main[$j++];
        $DrNoVal                = $Main[$j++];
        $DrDateVal              = $Main[$j++];
        $DrPartnerAccVal        = $Main[$j++];
        $DrAmtVal               = $Main[$j++];
        $DrJnlIDVal             = $Main[$j++];
        $CrStatus               = $Main[$j++];
        $CrNoVal                = $Main[$j++];
        $CrDateVal              = $Main[$j++];
        $CrPartnerAccVal        = $Main[$j++];
        $CrAmtVal               = $Main[$j++];
        $CrJnlIDVal             = $Main[$j++];

        $DrPartnerAccVal0       = $Main[$j++];
        $DrAmtVal0              = $Main[$j++];
        $CrPartnerAccVal0       = $Main[$j++];
        $CrAmtVal0              = $Main[$j++];

        $DrPartnerAccValZ       = $Main[$j++];
        $DrAmtValZ              = $Main[$j++];
        $CrPartnerAccValZ       = $Main[$j++];
        $CrAmtValZ              = $Main[$j++];

        $CarryOverTotalPrevDr   = $Main[$j++];
        $CarryOverTotalPrevCr   = $Main[$j++];

        $CarryOverTotalThisDr   = $Main[$j++];
        $CarryOverTotalThisCr   = $Main[$j++];

        $CarryOverTotalNextDr   = $Main[$j++];
        $CarryOverTotalNextCr   = $Main[$j++];

        $GrandTotalDr           = $Main[$j++];
        $GrandTotalCr           = $Main[$j++];
        
        $prm_Pages              = $Main[$j++];
        $EndPage                = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);   // first column (no data)
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);      // DrNoVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // DrDateVal
        fwrite($fp, '            <Column ss:Width="187.5"/>'.$LF);      // DrPartnerAccVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // DrAmtVal
        fwrite($fp, '            <Column ss:Width="32.25"/>'.$LF);      // DrJnlIDVal
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);      // CrNoVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CrDateVal
        fwrite($fp, '            <Column ss:Width="187.5"/>'.$LF);      // CrPartnerAccVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // CrAmtVal
        fwrite($fp, '            <Column ss:Width="32.25"/>'.$LF);      // CrJnlIDVal
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="4" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Debit.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="4" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Credit.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PartnerAcc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_JnlKindS.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PartnerAcc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_JnlKindS.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // beginning of month or carried from last page
        if ($prm_Pages > 1) { 
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$CarryOverTotalPrevDr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$CarryOverTotalPrevCr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        } else {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$DrPartnerAccVal0.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrAmtVal0.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CrPartnerAccVal0.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$CrAmtVal0.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // main data
        for ($i = 0, $c = count($DrNoVal); $i < $c; $i++) {
            $drstrline = true;
            if ($DrStatus) {
                $drstrline = $DrStatus[$i];
            }
            if ($CrStatus) {
                $crstrline = $CrStatus[$i];
            }
            
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="'.self::gStrikeOut($drstrline, 'Num', 'NumStr').'"><Data ss:Type="Number">'.$DrNoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($drstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$DrDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($drstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$DrPartnerAccVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($drstrline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$DrAmtVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($drstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$DrJnlIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($crstrline, 'Num', 'NumStr').'"><Data ss:Type="Number">'.$CrNoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($crstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$CrDateVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($crstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$CrPartnerAccVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($crstrline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$CrAmtVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($crstrline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$CrJnlIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        // end of month
        if ($EndPage) { 
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$DrPartnerAccValZ.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrAmtValZ.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Num"><Data ss:Type="Number"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CrPartnerAccValZ.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$CrAmtValZ.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        } 
        // page total
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_This.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverTotalThisDr.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_This.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverTotalThisCr.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        if ($EndPage) { 
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_GrandTotal.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$GrandTotalDr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_GrandTotal.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$GrandTotalCr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        } else { 
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Next.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverTotalNextDr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Next.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CarryOverTotalNextCr.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        } 
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
/*--------------------------------------------------------*/
/* 補助元帳                                               */
/*--------------------------------------------------------*/
    // メイン出力(補助元帳)
    private function cExcelSubLedger($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No         = $Head[$i++];
        $lbl_TrnID      = $Head[$i++];
        $lbl_AccrualDate= $Head[$i++];
        $lbl_Segment    = $Head[$i++];
        $lbl_CltName    = $Head[$i++];
        $lbl_ControlNo  = $Head[$i++];
        $lbl_Summary    = $Head[$i++];
        $lbl_DueDate    = $Head[$i++];
        $lbl_PartnerAcc = $Head[$i++];
        $lbl_CurName    = $Head[$i++];
        $lbl_FCDebitAmt = $Head[$i++];
        $lbl_FCCreditAmt= $Head[$i++];
        $lbl_DebitAmt   = $Head[$i++];
        $lbl_CreditAmt  = $Head[$i++];
        $lbl_DrCr       = $Head[$i++];
        $lbl_FCBalance  = $Head[$i++];
        $lbl_Balance    = $Head[$i++];
        
        $lbl_Prev       = $Head[$i++];
        $lbl_Total      = $Head[$i++];
        $lbl_GrandTotal = $Head[$i++];
        
        $Status                 = $Main[$j++];
        $NoVal                  = $Main[$j++];
        $TrnIDVal               = $Main[$j++];
        $DateVal                = $Main[$j++];
        $SegNameVal             = $Main[$j++];
        $CltNameVal             = $Main[$j++];
        $ControlNoVal           = $Main[$j++];
        $SummaryVal             = $Main[$j++];
        $DueDateVal             = $Main[$j++];
        $PartnerAccVal          = $Main[$j++];
        $CurNameVal             = $Main[$j++];
        $FCDrAmtVal             = $Main[$j++];
        $FCCrAmtVal             = $Main[$j++];
        $DrAmtVal               = $Main[$j++];
        $CrAmtVal               = $Main[$j++];
        $DrCrVal                = $Main[$j++];
        $FCBalanceVal           = $Main[$j++];
        $BalanceVal             = $Main[$j++];
        
        $keySegNameVal          = $Main[$j++];
        $keyCltNameVal          = $Main[$j++];
        $keyControlNoVal        = $Main[$j++];
        $keyCurNameVal          = $Main[$j++];
        $ControlNoPrevDrCr      = $Main[$j++];
        $FCControlNoPrevBalance = $Main[$j++];
        $ControlNoPrevBalance   = $Main[$j++];
        $FCControlNoTotalDebit  = $Main[$j++];
        $FCControlNoTotalCredit = $Main[$j++];
        $ControlNoTotalDebit    = $Main[$j++];
        $ControlNoTotalCredit   = $Main[$j++];
        $ControlNoTotalDrCr     = $Main[$j++];
        $FCControlNoTotalBalance= $Main[$j++];
        $ControlNoTotalBalance  = $Main[$j++];
        
        $ClientPrevDrCr         = $Main[$j++];
        $FCClientPrevBalance    = $Main[$j++];
        $ClientPrevBalance      = $Main[$j++];
        $FCClientTotalDebit     = $Main[$j++];
        $FCClientTotalCredit    = $Main[$j++];
        $ClientTotalDebit       = $Main[$j++];
        $ClientTotalCredit      = $Main[$j++];
        $ClientTotalDrCr        = $Main[$j++];
        $FCClientTotalBalance   = $Main[$j++];
        $ClientTotalBalance     = $Main[$j++];
        
        $SegmentPrevDrCr        = $Main[$j++];
        $FCSegmentPrevBalance   = $Main[$j++];
        $SegmentPrevBalance     = $Main[$j++];
        $FCSegmentTotalDebit    = $Main[$j++];
        $FCSegmentTotalCredit   = $Main[$j++];
        $SegmentTotalDebit      = $Main[$j++];
        $SegmentTotalCredit     = $Main[$j++];
        $SegmentTotalDrCr       = $Main[$j++];
        $FCSegmentTotalBalance  = $Main[$j++];
        $SegmentTotalBalance    = $Main[$j++];
        
        $CurrencyPrevDrCr       = $Main[$j++];
        $FCCurrencyPrevBalance  = $Main[$j++];
        $CurrencyPrevBalance    = $Main[$j++];
        $FCCurrencyTotalDebit   = $Main[$j++];
        $FCCurrencyTotalCredit  = $Main[$j++];
        $CurrencyTotalDebit     = $Main[$j++];
        $CurrencyTotalCredit    = $Main[$j++];
        $CurrencyTotalDrCr      = $Main[$j++];
        $FCCurrencyTotalBalance = $Main[$j++];
        $CurrencyTotalBalance   = $Main[$j++];
        
        $AllPrevDrCr            = $Main[$j++];
        $AllPrevBalance         = $Main[$j++];
        $AllTotalDebit          = $Main[$j++];
        $AllTotalCredit         = $Main[$j++];
        $AllTotalDrCr           = $Main[$j++];
        $AllTotalBalance        = $Main[$j++];
        
        $prm_ShowCurrency       = $Main[$j++];
        $prm_ShowSegment        = $Main[$j++];
        $prm_ShowClient         = $Main[$j++];
        $prm_ShowControlNo      = $Main[$j++];


        // 各MergeAcrossの設定（検索条件で変わるため）
        $prm_ColSpanClient    = 2;
        $prm_ColSpanSegment   = 3;
        $prm_ColSpanCurrency  = 5;
        $prm_ColSpanGranTotal = 6;
        
        if (!$prm_ShowControlNo) {
            $prm_ColSpanSegment   -= 3;
            $prm_ColSpanCurrency  -= 3;
            $prm_ColSpanGranTotal -= 3;
        }
        if (!$prm_ShowClient) {
            $prm_ColSpanSegment   -= 1;
            $prm_ColSpanCurrency  -= 1;
            $prm_ColSpanGranTotal -= 1;
        }
        if (!$prm_ShowSegment) {
            $prm_ColSpanCurrency  -= 1;
            $prm_ColSpanGranTotal -= 1;
        }
        if (!$prm_ShowCurrency) {
            $prm_ColSpanGranTotal -= 1;
        }
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);   // first column (no data)
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);      // NoVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // TrnIDVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // DateVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // SegNameVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CltNameVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // ControlNoVal
        fwrite($fp, '            <Column ss:Width="187.5"/>'.$LF);      // SummaryVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // DueDateVal
        fwrite($fp, '            <Column ss:Width="187.5"/>'.$LF);      // PartnerAccVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CurNameVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // FCDrAmtVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // FCCrAmtVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // DrAmtVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // CrAmtVal
        fwrite($fp, '            <Column ss:Width="32.25"/>'.$LF);      // DrCrVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // FCBalanceVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // BalanceVal
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Segment.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ControlNo.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DueDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PartnerAcc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CurName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_FCDebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_FCCreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DrCr.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_FCBalance.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Balance.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        
        // メイン
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="13" ss:StyleID="Prev">'.$lbl_Prev.'<Data ss:Type="String"></Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$AllPrevDrCr.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$AllPrevBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        for ($i = 0; $i < count($keyCltNameVal); $i++) { 
            if ($prm_ShowCurrency) { 
                fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="8" ss:StyleID="Prev"><Data ss:Type="String"></Data>'.$lbl_Prev.'</Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCurNameVal[$i][0][0][0].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$CurrencyPrevDrCr[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$FCCurrencyPrevBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$CurrencyPrevBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '            </Row>'.$LF);
            } 
            for ($j = 0; $j < count($keyCltNameVal[$i]); $j++) { 
                // prev for segment
                if ($prm_ShowSegment && $prm_ShowClient) { 
                    fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                    fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keySegNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:MergeAcross="4" ss:StyleID="Prev"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$SegmentPrevDrCr[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$FCSegmentPrevBalance[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$SegmentPrevBalance[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '            </Row>'.$LF);
                } 
                for ($k = 0; $k < count($keyCltNameVal[$i][$j]); $k++) { 
                    // prev for client
                    if ($prm_ShowClient) { 
                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keySegNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCltNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Prev"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$ClientPrevDrCr[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$FCClientPrevBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$ClientPrevBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '            </Row>'.$LF);
                    } 
                    for ($l = 0; $l < count($keyCltNameVal[$i][$j][$k]); $l++) { 
                        // prev for control no
                        if ($prm_ShowControlNo) { 
                            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keySegNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCltNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyControlNoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Prev"><Data ss:Type="String">'.$lbl_Prev.'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Prev"><Data ss:Type="String"></Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="PrevCtr"><Data ss:Type="String">'.$ControlNoPrevDrCr[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$FCControlNoPrevBalance[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Prev"><Data ss:Type="Number">'.$ControlNoPrevBalance[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '            </Row>'.$LF);
                        } 
                        if (isset($NoVal[$i])) { 
                            if (count($NoVal[$i]) > 0) { 
                                if (isset($NoVal[$i][$j])) { 
                                    if (count($NoVal[$i][$j]) > 0) { 
                                        if (isset($NoVal[$i][$j][$k])) { 
                                            if (count($NoVal[$i][$j][$k]) > 0) { 
                                                if (isset($NoVal[$i][$j][$k][$l])) { 
                                                    for ($m = 0; $m < count($NoVal[$i][$j][$k][$l]); $m++) {  
                                                        $strline = true;
                                                        if ($Status) {
                                                            $strline = $Status[$i][$j][$k][$l][$m];
                                                        }
                                                        
                                                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                                                        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="'.self::gStrikeOut($strline, 'Num', 'NumStr').'"><Data ss:Type="Number">'.$NoVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$TrnIDVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$DateVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$SegNameVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$CltNameVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$ControlNoVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$SummaryVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$DueDateVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$PartnerAccVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Str', 'StrStr').'"><Data ss:Type="String">'.$CurNameVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$FCDrAmtVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$FCCrAmtVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$DrAmtVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$CrAmtVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'StrCtr', 'StrStrCtr').'"><Data ss:Type="String">'.$DrCrVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$FCBalanceVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '                <Cell ss:StyleID="'.self::gStrikeOut($strline, 'Amt', 'AmtStr').'"><Data ss:Type="Number">'.$BalanceVal[$i][$j][$k][$l][$m].'</Data></Cell>'.$LF);
                                                        fwrite($fp, '            </Row>'.$LF);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        // Control No Total
                        if ($prm_ShowControlNo) {
                            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keySegNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCltNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyControlNoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCControlNoTotalDebit[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCControlNoTotalCredit[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ControlNoTotalDebit[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ControlNoTotalCredit[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$ControlNoTotalDrCr[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCControlNoTotalBalance[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ControlNoTotalBalance[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '            </Row>'.$LF);
                        }
                    }
                    // Client Total
                    if ($prm_ShowClient) {
                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keySegNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCltNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:MergeAcross="3" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCClientTotalDebit[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCClientTotalCredit[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClientTotalDebit[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClientTotalCredit[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$ClientTotalDrCr[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCClientTotalBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClientTotalBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '            </Row>'.$LF);
                    }
                }
                // Segment Total
                if ($prm_ShowSegment) {
                    fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                    fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keySegNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:MergeAcross="4" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCurNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCSegmentTotalDebit[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCSegmentTotalCredit[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$SegmentTotalDebit[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$SegmentTotalCredit[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$SegmentTotalDrCr[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCSegmentTotalBalance[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$SegmentTotalBalance[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '            </Row>'.$LF);
                }
            }
            // Currency Total
            if ($prm_ShowCurrency) {
                fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="8" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$keyCurNameVal[$i][0][0][0].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCCurrencyTotalDebit[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCCurrencyTotalCredit[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CurrencyTotalDebit[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CurrencyTotalCredit[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$CurrencyTotalDrCr[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCCurrencyTotalBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CurrencyTotalBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '            </Row>'.$LF);
            }
        }
        
        // Grand Total
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="11" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_GrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotalDebit.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotalCredit.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$AllTotalDrCr.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotalBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
/*--------------------------------------------------------*/
/* 残高一覧表                                             */
/*--------------------------------------------------------*/
    // メイン出力(残高一覧表)
    private function cExcelSubLedgerBal($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No         = $Head[$i++];
        $lbl_Segment    = $Head[$i++];
        $lbl_CltName    = $Head[$i++];
        $lbl_ControlNo  = $Head[$i++];
        $lbl_Summary    = $Head[$i++];
        $lbl_DueDate    = $Head[$i++];
        $lbl_CurName    = $Head[$i++];
        $lbl_DrCr       = $Head[$i++];
        $lbl_FCBalance  = $Head[$i++];
        $lbl_Balance    = $Head[$i++];
        
        $lbl_Total      = $Head[$i++];
        $lbl_GrandTotal = $Head[$i++];
        
        $NoVal                  = $Main[$j++];
        $SegNameVal             = $Main[$j++];
        $CltNameVal             = $Main[$j++];
        $ControlNoVal           = $Main[$j++];
        $SummaryVal             = $Main[$j++];
        $DueDateVal             = $Main[$j++];
        $CurNameVal             = $Main[$j++];
        $DrCrVal                = $Main[$j++];
        $FCBalanceVal           = $Main[$j++];
        $BalanceVal             = $Main[$j++];
        
        $ClientTotalDrCr        = $Main[$j++];
        $FCClientTotalBalance   = $Main[$j++];
        $ClientTotalBalance     = $Main[$j++];
        
        $SegmentTotalDrCr       = $Main[$j++];
        $FCSegmentTotalBalance  = $Main[$j++];
        $SegmentTotalBalance    = $Main[$j++];
        
        $CurrencyTotalDrCr      = $Main[$j++];
        $FCCurrencyTotalBalance = $Main[$j++];
        $CurrencyTotalBalance   = $Main[$j++];
        
        $AllTotalDrCr           = $Main[$j++];
        $AllTotalBalance        = $Main[$j++];
        
        $prm_ShowCurrency       = $Main[$j++];
        $prm_ShowSegment        = $Main[$j++];
        $prm_ShowClient         = $Main[$j++];
        $prm_ShowControlNo      = $Main[$j++];


        // 各MergeAcrossの設定（検索条件で変わるため）
        $prm_ColSpanClient    = 2;
        $prm_ColSpanSegment   = 3;
        $prm_ColSpanCurrency  = 5;
        $prm_ColSpanGranTotal = 6;
        
        if (!$prm_ShowControlNo) {
            $prm_ColSpanSegment   -= 3;
            $prm_ColSpanCurrency  -= 3;
            $prm_ColSpanGranTotal -= 3;
        }
        if (!$prm_ShowClient) {
            $prm_ColSpanSegment   -= 1;
            $prm_ColSpanCurrency  -= 1;
            $prm_ColSpanGranTotal -= 1;
        }
        if (!$prm_ShowSegment) {
            $prm_ColSpanCurrency  -= 1;
            $prm_ColSpanGranTotal -= 1;
        }
        if (!$prm_ShowCurrency) {
            $prm_ColSpanGranTotal -= 1;
        }
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);   // first column (no data)
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);      // NoVal
        if ($prm_ShowSegment) {
            fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // SegNameVal
        }
        if ($prm_ShowClient) {
            fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CltNameVal
        }
        if ($prm_ShowControlNo) {
            fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // ControlNoVal
            fwrite($fp, '            <Column ss:Width="187.5"/>'.$LF);      // SummaryVal
            fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // DueDateVal
        }
        if ($prm_ShowCurrency) {
            fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CurNameVal
        }
        fwrite($fp, '            <Column ss:Width="32.25"/>'.$LF);      // DrCrVal
        if ($prm_ShowCurrency) {
            fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // FCBalanceVal
        }
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // BalanceVal
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        if ($prm_ShowSegment) {
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Segment.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        }
        if ($prm_ShowClient) {
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        }
        if ($prm_ShowControlNo) {
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ControlNo.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DueDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        }
        if ($prm_ShowCurrency) {
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CurName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        }
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DrCr.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        if ($prm_ShowCurrency) {
            fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_FCBalance.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        }
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Balance.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        
        // メイン
        for ($i = 0; $i < count($CltNameVal); $i++) { 
            for ($j = 0; $j < count($CltNameVal[$i]); $j++) { 
                for ($k = 0; $k < count($CltNameVal[$i][$j]); $k++) { 
                    for ($l = 0; $l < count($CltNameVal[$i][$j][$k]); $l++) { 
                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        if ($prm_ShowSegment) {
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$SegNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        }
                        if ($prm_ShowClient) {
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        }
                        if ($prm_ShowControlNo) {
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$ControlNoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$SummaryVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$DueDateVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        }
                        if ($prm_ShowCurrency) {
                            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CurNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        }
                        fwrite($fp, '                <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$DrCrVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        if ($prm_ShowCurrency) {
                            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$FCBalanceVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        }
                        fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$BalanceVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, '            </Row>'.$LF);
                    }
                    // Client Total
                    if ($prm_ShowControlNo) {
                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
                        if ($prm_ShowSegment) {
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$SegNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        }
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CltNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        fwrite($fp, '                <Cell ss:MergeAcross="'.$prm_ColSpanClient.'" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                        if ($prm_ShowCurrency) {
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CurNameVal[$i][$j][$k][0].'</Data></Cell>'.$LF);
                        }
                        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$ClientTotalDrCr[$i][$j][$k].'</Data></Cell>'.$LF);
                        if ($prm_ShowCurrency) {
                            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCClientTotalBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        }
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClientTotalBalance[$i][$j][$k].'</Data></Cell>'.$LF);
                        fwrite($fp, '            </Row>'.$LF);
                    }
                    
                }
                // Segment Total
                if ($prm_ShowSegment && $prm_ShowClient) {
                    fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                    fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$SegNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    fwrite($fp, '                <Cell ss:MergeAcross="'.$prm_ColSpanSegment.'" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                    if ($prm_ShowCurrency) {
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CurNameVal[$i][$j][0][0].'</Data></Cell>'.$LF);
                    }
                    fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$SegmentTotalDrCr[$i][$j].'</Data></Cell>'.$LF);
                    if ($prm_ShowCurrency) {
                        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCSegmentTotalBalance[$i][$j].'</Data></Cell>'.$LF);
                    }
                    fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$SegmentTotalBalance[$i][$j].'</Data></Cell>'.$LF);
                    fwrite($fp, '            </Row>'.$LF);
                }
            }
            // Currency Total
            if ($prm_ShowCurrency) {
                fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="'.$prm_ColSpanCurrency.'" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CurNameVal[$i][0][0][0].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$CurrencyTotalDrCr[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$FCCurrencyTotalBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CurrencyTotalBalance[$i].'</Data></Cell>'.$LF);
                fwrite($fp, '            </Row>'.$LF);
            }
        }
        
        // Grand Total
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="'.$prm_ColSpanGranTotal.'" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_GrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$AllTotalDrCr.'</Data></Cell>'.$LF);
        if ($prm_ShowCurrency) {
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number"></Data></Cell>'.$LF);
        }
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotalBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* Aging Report                                           */
/*--------------------------------------------------------*/
    // メイン出力(Aging Report)
    private function cExcelAgingReport($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No         = $Head[$i++];
        $lbl_AccID      = $Head[$i++];
        $lbl_AccSName   = $Head[$i++];
        $lbl_Segment    = $Head[$i++];
        $lbl_Client     = $Head[$i++];
        $lbl_CltName    = $Head[$i++];
        $lbl_TrnID      = $Head[$i++];
        $lbl_ControlNo  = $Head[$i++];
        $lbl_AccrualDate    = $Head[$i++];
        $lbl_CurName    = $Head[$i++];
        $lbl_FCInvoiceAmt   = $Head[$i++];
        $lbl_InvoiceAmt = $Head[$i++];
        $lbl_PayTerm    = $Head[$i++];
        $lbl_DueDate    = $Head[$i++];
        $lbl_NotYetDue  = $Head[$i++];
        $lbl_Overdue30  = $Head[$i++];
        $lbl_Overdue60  = $Head[$i++];
        $lbl_Overdue120 = $Head[$i++];
        $lbl_Overdue180 = $Head[$i++];
        $lbl_Overdue360 = $Head[$i++];
        $lbl_OverdueMore360 = $Head[$i++];
        $lbl_Total      = $Head[$i++];
        $lbl_DrCr       = $Head[$i++];
        
        $lbl_Total      = $Head[$i++];
        $lbl_GrandTotal = $Head[$i++];
        
        $NoVal                  = $Main[$j++];
        $AccIdVal               = $Main[$j++];
        $AccTitleSNameVal       = $Main[$j++];
        $SegNameVal             = $Main[$j++];
        $CltIDVal               = $Main[$j++];
        $CltNameVal             = $Main[$j++];
        $TrnIDVal               = $Main[$j++];
        $ControlNoVal           = $Main[$j++];
        $TrnDateVal             = $Main[$j++];
        $CurNameVal             = $Main[$j++];
        $FCInvoiceAmtVal        = $Main[$j++];
        $InvoiceAmtVal          = $Main[$j++];
        $PayTermVal             = $Main[$j++];
        $DueDateVal             = $Main[$j++];
        $NotYetDueVal           = $Main[$j++];
        $Overdue30Val           = $Main[$j++];
        $Overdue60Val           = $Main[$j++];
        $Overdue120Val          = $Main[$j++];
        $Overdue180Val          = $Main[$j++];
        $Overdue360Val          = $Main[$j++];
        $OverdueMore360Val      = $Main[$j++];
        $TotalVal               = $Main[$j++];
        $DrCrVal                = $Main[$j++];
        
        $ClientTotalBalance     = $Main[$j++];
        $ClientTotalDrCr        = $Main[$j++];
        
        $AllTotalBalance        = $Main[$j++];
        $AllTotalDrCr           = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R2"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);   // first column (no data)
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);      // NoVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // AccIdVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // AccTitleSNameVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // SegNameVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // CltIDVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CltNameVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // TrnIDVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // ControlNoVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // TrnDateVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // CurNameVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // FCInvoiceAmtVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // InvoiceAmtVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // PayTermVal
        fwrite($fp, '            <Column ss:Width="93.75"/>'.$LF);      // DueDateVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // NotYetDueVal
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // Overdue30Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // Overdue60Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // Overdue120Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // Overdue180Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // Overdue360Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // OverdueMore360Val
        fwrite($fp, '            <Column ss:Width="62.25"/>'.$LF);      // TotalVal
        fwrite($fp, '            <Column ss:Width="32.25"/>'.$LF);      // DrCrVal
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Segment.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Client.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CltName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TrnID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_ControlNo.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccrualDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CurName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_FCInvoiceAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_InvoiceAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PayTerm.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DueDate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_NotYetDue.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Overdue30.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Overdue60.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Overdue120.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Overdue180.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Overdue360.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_OverdueMore360.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DrCr.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        
        // メイン
        for ($i = 0; $i < count($CltNameVal); $i++) { 
            for ($j = 0; $j < count($CltNameVal[$i]); $j++) { 
                for ($k = 0; $k < count($CltNameVal[$i][$j]); $k++) { 
                    for ($l = 0; $l < count($CltNameVal[$i][$j][$k]); $l++) { 
                        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
                        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccIdVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccTitleSNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$SegNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltIDVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CltNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnIDVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$ControlNoVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$TrnDateVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$CurNameVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$FCInvoiceAmtVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$InvoiceAmtVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$PayTermVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Str"><Data ss:Type="String">'.$DueDateVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NotYetDueVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$Overdue30Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$Overdue60Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$Overdue120Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$Overdue180Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$Overdue360Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OverdueMore360Val[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$TotalVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, ' <Cell ss:StyleID="StrCtr"><Data ss:Type="String">'.$DrCrVal[$i][$j][$k][$l].'</Data></Cell>'.$LF);
                        fwrite($fp, '            </Row>'.$LF);
                    }
                }
            }
            // Client Total
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="3" ss:StyleID="Sum"><Data ss:Type="String"></Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CltIDVal[$i][0][0][0].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="String">'.$CltNameVal[$i][0][0][0].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:MergeAcross="14" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$ClientTotalBalance[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$ClientTotalDrCr[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
                    
        }
        
        // Grand Total
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="20" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_GrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AllTotalBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumCtr"><Data ss:Type="String">'.$AllTotalDrCr.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 試算表                                                 */
/*--------------------------------------------------------*/
    // メイン出力(試算表)
    private function cExcelTrialBalance($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No        = $Head[$i++];
        $lbl_Acc       = $Head[$i++];
        $lbl_LedS      = $Head[$i++];
        $lbl_Prev      = $Head[$i++];
        $lbl_Total     = $Head[$i++];
        $lbl_Balance   = $Head[$i++];
        $lbl_DebitAmt  = $Head[$i++];
        $lbl_CreditAmt = $Head[$i++];
        $lbl_Total     = $Head[$i++];
        
        $NoVal            = $Main[$j++];
        $AccVal           = $Main[$j++];
        $LedListIDVal     = $Main[$j++];
        $DrPrevVal        = $Main[$j++];
        $CrPrevVal        = $Main[$j++];
        $DrTotalVal       = $Main[$j++];
        $CrTotalVal       = $Main[$j++];
        $DrBalanceVal     = $Main[$j++];
        $CrBalanceVal     = $Main[$j++];
        $DrPrevGrandTotal = $Main[$j++];
        $CrPrevGrandTotal = $Main[$j++];
        $DrGrandTotal     = $Main[$j++];
        $CrGrandTotal     = $Main[$j++];
        $DrGrandBalance   = $Main[$j++];
        $CrGrandBalance   = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="26.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="299.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="28.5"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="11" ss:Width="117" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Acc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_LedS.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Prev.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Total.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Balance.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($AccVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$LedListIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrPrevVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$CrPrevVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrTotalVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$CrTotalVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$DrBalanceVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$CrBalanceVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$DrPrevGrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CrPrevGrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$DrGrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CrGrandTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$DrGrandBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$CrGrandBalance.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 精算表                                                 */
/*--------------------------------------------------------*/
    // メイン出力(精算表)
    private function cExcelWorkSheet($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_No        = $Head[$i++];
        $lbl_Acc       = $Head[$i++];
        $lbl_TB        = $Head[$i++];
        $lbl_Adj       = $Head[$i++];
        $lbl_PL        = $Head[$i++];
        $lbl_BS        = $Head[$i++];
        $lbl_DebitAmt  = $Head[$i++];
        $lbl_CreditAmt = $Head[$i++];
        $lbl_Total     = $Head[$i++];
        
        $TrVal      = $Main[$j++];
        $NoVal      = $Main[$j++];
        $AccNameVal = $Main[$j++];
        $TBDrVal    = $Main[$j++];
        $TBCrVal    = $Main[$j++];
        $AdjDrVal   = $Main[$j++];
        $AdjCrVal   = $Main[$j++];
        $PLDrVal    = $Main[$j++];
        $PLCrVal    = $Main[$j++];
        $BSDrVal    = $Main[$j++];
        $BSCrVal    = $Main[$j++];
        $TBDrTotal  = $Main[$j++];
        $TBCrTotal  = $Main[$j++];
        $AdjDrTotal = $Main[$j++];
        $AdjCrTotal = $Main[$j++];
        $PLDrTotal  = $Main[$j++];
        $PLCrTotal  = $Main[$j++];
        $BSDrTotal  = $Main[$j++];
        $BSCrTotal  = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="165.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75" ss:Span="7"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Acc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_TB.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Adj.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_PL.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_BS.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_DebitAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_CreditAmt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($TrVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AccNameVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$TBDrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$TBCrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$AdjDrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$AdjCrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$PLDrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$PLCrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$BSDrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$BSCrVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 合計
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="1" ss:StyleID="Sum"><Data ss:Type="String">'.$lbl_Total.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$TBDrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$TBCrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AdjDrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$AdjCrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$PLDrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$PLCrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$BSDrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Sum"><Data ss:Type="Number">'.$BSCrTotal.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 貸借対照表                                             */
/*--------------------------------------------------------*/
    // Style取得(勘定科目)
    private function gStyleAcc($css) {
        $this->CL['LG']->cLog('T0002');
        switch ($css) {
            case 'kind1':
                return 'StrCtr';
            case '':
            case 'kind2':
                return 'Str';
            case 'kind3':
                return 'StrID1';
            case 'kind4':
                return 'StrID2';
            case 'kind5':
                return 'StrID3';
            case 'kind6':
                return 'StrID4';
            case 'totalaccthis1':
            case 'totalaccthis2':
            case 'totalaccthis3':
                return 'SumLftBld';
            case 'totalaccsum':
                return 'SumCtrBld';
            case 'totalaccnotsum2':
                return 'StrID3Bld';
            case 'totalaccnotsum3':
                return 'StrID4Bld';
            case 'totalaccnotsum4':
                return 'StrID5Bld';
        }
    }
    
    // Style取得(金額)
    private function gStyleAmt($css) {
        $this->CL['LG']->cLog('T0002');
        switch ($css) {
            case '':
            case 'nowrap-R':
                return 'Num';
            case 'totalval':
            case 'totalvalsum':
                return 'Sum';
            case 'totalvalnotsumsub':
                return 'NumDbl';
        }
    }
    
    // メイン出力(貸借対照表)
    private function cExcelBalanceSheet($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_Debit  = $Head[$i++];
        $lbl_Credit = $Head[$i++];
        $lbl_Acc    = $Head[$i++];
        $lbl_Amt    = $Head[$i++];
        
        $DrAccClsVal = $Main[$j++];
        $DrAmtClsVal = $Main[$j++];
        $CrAccClsVal = $Main[$j++];
        $CrAmtClsVal = $Main[$j++];
        $DrAccNumVal = $Main[$j++];
        $DrAmtNumVal = $Main[$j++];
        $CrAccNumVal = $Main[$j++];
        $CrAmtNumVal = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="225"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="225"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Debit.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Credit.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Acc.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Acc.'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        for ($i = 0, $c = count($DrAmtNumVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="'.self::gStyleAcc($DrAccClsVal[$i]).'"><Data ss:Type="String">'.$DrAccNumVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStyleAmt($DrAmtClsVal[$i]).'"><Data ss:Type="Number">'.$DrAmtNumVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStyleAcc($CrAccClsVal[$i]).'"><Data ss:Type="String">'.$CrAccNumVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="'.self::gStyleAmt($CrAmtClsVal[$i]).'"><Data ss:Type="Number">'.$CrAmtNumVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 損益計算書                                             */
/*--------------------------------------------------------*/
    // メイン出力(損益計算書)
    private function cExcelProfitAndLoss($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $lbl_Acc         = $Head[$i++];
        $ThisTitle       = $Head[$i++];
        $PrevTitle       = $Head[$i++];
        $lbl_Fluctuation = $Head[$i++];
        $lbl_Amt         = $Head[$i++];
        $lbl_Ratio       = $Head[$i++];
        $lbl_Amt         = $Head[$i++];
        $lbl_Ratio       = $Head[$i++];
        $lbl_Amt         = $Head[$i++];
        $lbl_Rate        = $Head[$i++];
        
        $OperatingRevenueLine                = $Main[$j++];
        $DepartmentOfOrdinaryIncomeLine      = $Main[$j++];
        $DepartmentOfOrdinaryIncomeName      = $Main[$j++];
        $OperatingPLLine                     = $Main[$j++];
        $OperatingPLName                     = $Main[$j++];
        $OperatingRevenueVal                 = $Main[$j++];
        $OperatingExpenseLine                = $Main[$j++];
        $OperatingExpenseVal                 = $Main[$j++];
        $OperatingProfitLine                 = $Main[$j++];
        $OperatingProfitVal                  = $Main[$j++];
        $NonOperatingRevenueLine             = $Main[$j++];
        $NonOperatingPLLine                  = $Main[$j++];
        $NonOperatingPLName                  = $Main[$j++];
        $NonOperatingRevenueVal              = $Main[$j++];
        $NonOperatingExpenseLine             = $Main[$j++];
        $NonOperatingExpenseVal              = $Main[$j++];
        $OrdinaryProfitLine                  = $Main[$j++];
        $OrdinaryProfitVal                   = $Main[$j++];
        $ExtraordinaryIncomeLine             = $Main[$j++];
        $DepartmentOfSpecialGainsAndLossLine = $Main[$j++];
        $DepartmentOfSpecialGainsAndLossName = $Main[$j++];
        $ExtraordinaryIncomeVal              = $Main[$j++];
        $ExtraordinaryLossLine               = $Main[$j++];
        $ExtraordinaryLossVal                = $Main[$j++];
        $NetProfitBeforeTaxLine              = $Main[$j++];
        $NetProfitBeforeTaxVal               = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="27"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="26.25"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="120"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75" ss:Span="5"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="28.5">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:MergeDown="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Acc.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$ThisTitle.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$PrevTitle.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Fluctuation.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
        fwrite($fp, '                <Cell ss:Index="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Ratio.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Ratio.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Rate.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン
        // 営業収益
        for ($i = 0; $i < $OperatingRevenueLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="'.($DepartmentOfOrdinaryIncomeLine-1).'" ss:StyleID="StrWrpVrt"><Data ss:Type="String">'.$DepartmentOfOrdinaryIncomeName.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:MergeDown="'.($OperatingPLLine-1).'" ss:StyleID="StrWrpVrt"><Data ss:Type="String">'.$OperatingPLName.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBld"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrID1"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingRevenueVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingRevenueVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 営業費用
        for ($i = 0; $i < $OperatingExpenseLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrDblBld"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrID1"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$OperatingExpenseVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$OperatingExpenseVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 営業利益
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
        fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="SumLftBldID1"><Data ss:Type="String">'.$OperatingProfitVal[0]['Acc']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OperatingProfitVal[0]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OperatingProfitVal[0]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OperatingProfitVal[0]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OperatingProfitVal[0]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OperatingProfitVal[0]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OperatingProfitVal[0]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 営業外収益
        for ($i = 0; $i < $NonOperatingRevenueLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="3" ss:MergeDown="'.($NonOperatingPLLine-1).'" ss:StyleID="StrWrpVrt"><Data ss:Type="String">'.$NonOperatingPLName.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBld"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrID1"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingRevenueVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingRevenueVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 営業外費用
        for ($i = 0; $i < $NonOperatingExpenseLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrDblBld"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="4" ss:StyleID="StrID1"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NonOperatingExpenseVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$NonOperatingExpenseVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 経常利益
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
        fwrite($fp, '                <Cell ss:Index="3" ss:MergeAcross="1" ss:StyleID="SumLftBldID1"><Data ss:Type="String">'.$OrdinaryProfitVal[0]['Acc']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OrdinaryProfitVal[0]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OrdinaryProfitVal[0]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OrdinaryProfitVal[0]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OrdinaryProfitVal[0]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$OrdinaryProfitVal[0]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$OrdinaryProfitVal[0]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 特別利益
        for ($i = 0; $i < $ExtraordinaryIncomeLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="2" ss:MergeDown="'.($DepartmentOfSpecialGainsAndLossLine-1).'" ss:StyleID="StrWrpVrt"><Data ss:Type="String">'.$DepartmentOfSpecialGainsAndLossName.'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:MergeAcross="1" ss:StyleID="StrDblBld"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="3" ss:MergeAcross="1" ss:StyleID="StrID1"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryIncomeVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryIncomeVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 特別損失
        for ($i = 0; $i < $ExtraordinaryLossLine; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
            if ($i == 0) {
                fwrite($fp, '                <Cell ss:Index="3" ss:MergeAcross="1" ss:StyleID="StrDblBld"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="AmtDblBld"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrDblBldRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            } else {
                fwrite($fp, '                <Cell ss:Index="3" ss:MergeAcross="1" ss:StyleID="StrID1"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Acc']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$ExtraordinaryLossVal[$i]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
                fwrite($fp, '                <Cell ss:StyleID="StrRgh"><Data ss:Type="String">'.$ExtraordinaryLossVal[$i]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
            }
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 税引前当期純利益
        fwrite($fp, '            <Row ss:AutoFitHeight="0" ss:Height="27">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="2" ss:StyleID="SumLftBldID1"><Data ss:Type="String">'.$NetProfitBeforeTaxVal[0]['Acc']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$NetProfitBeforeTaxVal[0]['Ths']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$NetProfitBeforeTaxVal[0]['Ths']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$NetProfitBeforeTaxVal[0]['Prv']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$NetProfitBeforeTaxVal[0]['Prv']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="Number">'.$NetProfitBeforeTaxVal[0]['Flu']['Amt']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="SumBld"><Data ss:Type="String">'.$NetProfitBeforeTaxVal[0]['Flu']['Rto']['Val'].'</Data></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
    
/*--------------------------------------------------------*/
/* 開始残高                                               */
/*--------------------------------------------------------*/
    // メイン出力(開始残高)
    private function cExcelOpningBalance($fp, $SheetName, $Head, $Main) {
        $this->CL['LG']->cLog('T0002');
        $LF = $this->CL['DF']->LF;
        
        // 引数分解
        $i = $j = 0;
        $Asset        = $Head[$i++];
        $Liability    = $Head[$i++];
        $NetAssets    = $Head[$i++];
        $lbl_No       = $Head[$i++];
        $lbl_AccID    = $Head[$i++];
        $lbl_AccMName = $Head[$i++];
        $lbl_AccSName = $Head[$i++];
        $lbl_Amt      = $Head[$i++];
        $lbl_Summary  = $Head[$i++];
        
        $AssetNoVal           = $Main[$j++];
        $AssetAccIDVal        = $Main[$j++];
        $AssetAccMVal         = $Main[$j++];
        $AssetAccSVal         = $Main[$j++];
        $AssetAmtExcelVal     = $Main[$j++];
        $AssetSummaryExcelVal = $Main[$j++];
        $LiabilityNoVal           = $Main[$j++];
        $LiabilityAccIDVal        = $Main[$j++];
        $LiabilityAccMVal         = $Main[$j++];
        $LiabilityAccSVal         = $Main[$j++];
        $LiabilityAmtExcelVal     = $Main[$j++];
        $LiabilitySummaryExcelVal = $Main[$j++];
        $NetAssetsNoVal           = $Main[$j++];
        $NetAssetsAccIDVal        = $Main[$j++];
        $NetAssetsAccMVal         = $Main[$j++];
        $NetAssetsAccSVal         = $Main[$j++];
        $NetAssetsAmtExcelVal     = $Main[$j++];
        $NetAssetsSummaryExcelVal = $Main[$j++];
        
        // ワークシート
        fwrite($fp, '    <Worksheet ss:Name="'.$SheetName.'">'.$LF);
        
        // 印刷タイトル
        fwrite($fp, '        <Names>'.$LF);
        fwrite($fp, '            <NamedRange ss:Name="Print_Titles" ss:RefersTo="='.$SheetName.'!R1:R3"/>'.$LF);
        fwrite($fp, '        </Names>'.$LF);
        
        // 先頭
        fwrite($fp, '        <Table ss:ExpandedColumnCount="'.$this->CL['DF']->excelmax.'" ss:ExpandedRowCount="'.$this->CL['DF']->excelmax.'" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="13.5"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="26.25"/>'.$LF);
        fwrite($fp, '            <Column ss:Width="84.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="165" ss:Span="1"/>'.$LF);
        fwrite($fp, '            <Column ss:Index="6" ss:Width="84.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="246.75"/>'.$LF);
        fwrite($fp, '            <Column ss:AutoFitWidth="0" ss:Width="75" ss:Span="4"/>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル(資産)
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$Asset.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン(資産)
        for ($i = 0, $c = count($AssetNoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$AssetNoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AssetAccIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AssetAccMVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AssetAccSVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$AssetAmtExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$AssetSummaryExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル(負債)
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$Liability.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン(負債)
        for ($i = 0, $c = count($LiabilityNoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$LiabilityNoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$LiabilityAccIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$LiabilityAccMVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$LiabilityAccSVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$LiabilityAmtExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$LiabilitySummaryExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        fwrite($fp, '            <Row ss:AutoFitHeight="0"/>'.$LF);
        
        // タイトル(純資産)
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:MergeAcross="5" ss:StyleID="Ttl"><Data ss:Type="String">'.$NetAssets.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
        fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_No.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccID.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccMName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_AccSName.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Amt.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '                <Cell ss:StyleID="Ttl"><Data ss:Type="String">'.$lbl_Summary.'</Data><NamedCell ss:Name="Print_Titles"/></Cell>'.$LF);
        fwrite($fp, '            </Row>'.$LF);
        
        // メイン(純資産)
        for ($i = 0, $c = count($NetAssetsNoVal); $i < $c; $i++) {
            fwrite($fp, '            <Row ss:AutoFitHeight="0">'.$LF);
            fwrite($fp, '                <Cell ss:Index="2" ss:StyleID="Num"><Data ss:Type="Number">'.$NetAssetsNoVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$NetAssetsAccIDVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$NetAssetsAccMVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$NetAssetsAccSVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Amt"><Data ss:Type="Number">'.$NetAssetsAmtExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '                <Cell ss:StyleID="Str"><Data ss:Type="String">'.$NetAssetsSummaryExcelVal[$i].'</Data></Cell>'.$LF);
            fwrite($fp, '            </Row>'.$LF);
        }
        
        // 後尾
        fwrite($fp, '        </Table>'.$LF);
        self::cWorksheetOptionsData($fp);
        fwrite($fp, '    </Worksheet>'.$LF);
    }
}
?>
