/// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Excel(bool CloseWindow)
        {
            try
            {
                string ProjectCode = this.txtProjectCode.Value;
                string StartYm     = "" + Request.QueryString["StartYm"];
                string EndYm       = "" + Request.QueryString["EndYm"];
                string PBSType     = "" + Request.QueryString["PBSType"];
                string PBSCode     = "" + Request.QueryString["PBSCode"];

                BLL.ContractPayScheduleBySubject sch = new RmsPM.BLL.ContractPayScheduleBySubject(ProjectCode);
                sch.PBSType = this.txtPBSType.Value;
                sch.PBSCode = this.txtPBSCode.Value;
                sch.StartYm = StartYm;
                sch.EndYm   = EndYm;
                sch.Generate();

                TExcel excel = new TExcel(Response, Request, Server, Session);
                try
                {
                    excel.StartRow      = 10;
                    excel.ColumnHeadRow = 9;

                    //去掉1级合计

                    /*
                     * DataView dv;
                     * if (dyn.NeedApport) //有分摊时,多了一级总计
                     * {
                     *  dv = new DataView(dyn.tb, "Deep=3", "SortID", DataViewRowState.CurrentRows);
                     * }
                     * else
                     * {
                     *  dv = new DataView(dyn.tb, "Deep=2", "SortID", DataViewRowState.CurrentRows);
                     * }
                     */

                    //新建工作簿
                    excel.TemplateFileName  = "付款一览表按科目.xls";
                    excel.TemplateSheetName = "";
                    excel.AddWorkbook();

                    //表头信息
                    string ProjectName = BLL.ProjectRule.GetProjectName(sch.ProjectCode);
                    if (PBSType != "")
                    {
                        ProjectName += "[" + this.sltPBS.Items[this.sltPBS.SelectedIndex].Text + "]";
                    }
                    excel.SetCellValue(1, 1, ProjectName);

                    //报表日期
                    excel.SetCellValue(1, 3, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    //最后两列是年月明细
                    int colYm = excel.Sheet.UsedRange.Columns.Count - 1;

                    if ((StartYm != "") && (EndYm != ""))  //有年月明细
                    {
                        int MonthCount = BLL.StringRule.GetMonthsBetween(StartYm, EndYm);

                        //插空列
                        TExcel.InsertBlankColumn(excel.Sheet, colYm, 1, 2, MonthCount);

                        int col = colYm - 1;
                        for (int i = 0; i < MonthCount; i++)
                        {
                            col++;
                            string ym = BLL.StringRule.YmAddMonths(StartYm, i);

                            //写excel的明细字段定义
                            excel.SetCellValue(excel.ColumnHeadRow, col, "PayoutMoneyYm_" + ym);
                        }
                    }
                    else  //无年月明细
                    {
                        //隐藏最后两列(年月明细)
                        TExcel.HideColumn(excel.Sheet, colYm);
                        TExcel.HideColumn(excel.Sheet, colYm + 1);
                    }

                    excel.DataSource = sch.tb;
                    excel.DataToSheet();

                    //保存
                    excel.SaveWorkbook();
                    excel.ShowClient();
                }
                finally
                {
                    excel.Dispose();
                }

                if (CloseWindow)
                {
                    Response.Write(Rms.Web.JavaScript.WinClose(true));
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(Rms.Web.JavaScript.Alert(true, "导出Excel出错:" + ex.Message));
            }
        }