/// <summary>
        /// 插入数据到工作表
        /// </summary>
        /// <param name="excelUtil">源工作表文件</param>
        /// <param name="sheetIndex">工作表索引</param>
        /// <param name="cb">数据源</param>
        private void AddDataToStuSheet(ExcelUtil excelUtil, int sheetIndex, List<IModelObject> cb)
        {
            int temp = 0;

            foreach (ComboboxDataInfo item in cb)
            {
                temp++;
                excelUtil.AddValueToCell(sheetIndex, temp, 1, item.DisplayMember);
                excelUtil.AddValueToCell(sheetIndex, temp, 2, item.ValueMember);
            }
        }
        private void AddDataToSheet(ExcelUtil excelUtil, int sheetIndex, string startCell, List<IModelObject> cb)
        {
            int temp = 0;
            //  StringBuilder dataBuilder = new StringBuilder();
            // string data = "";

            foreach (ComboboxDataInfo item in cb)
            {
                temp++;
                excelUtil.AddValueToCell(sheetIndex, temp, 1, item.DisplayMember);
                excelUtil.AddValueToCell(sheetIndex, temp, 2, item.ValueMember);
                // dataBuilder.Append(item.DisplayMember).Append(",");
            }
            //  Microsoft.Office.Interop.Excel.Range rang = excelUtil.GetRange(startCell, startCell).get_Resize(10000, 1);
            //  data = dataBuilder.ToString();
            //  excelUtil.AddValidation(rang, data.Substring(0, data.Length - 1));
        }
        private void ExportTemplate(string xlsSavePath)
        {
            ExcelUtil excelUtil = null;
            try
            {

                excelUtil = new ExcelUtil();

                excelUtil.Open(Application.StartupPath + "/ExcelTemplate/studentModel.xls");
                bgWorkerInfoTemp.ReportProgress(10);
                //excelUtil.AddValueToCell(5,1,"simon");

                List<Model.IModel.IModelObject> sexList = _IGeneralBL.GetMasterDataInformations(DefineConstantValue.MasterType.CardUserSex);

                AddDataToStuSheet(excelUtil, 2, sexList);

                bgWorkerInfoTemp.ReportProgress(30);

                List<Model.IModel.IModelObject> classList = _IGeneralBL.GetMasterDataInformations(DefineConstantValue.MasterType.UserClass);

                AddDataToStuSheet(excelUtil, 3, classList);

                bgWorkerInfoTemp.ReportProgress(90);
                excelUtil.SaveCopyAs(xlsSavePath);
                bgWorkerInfoTemp.ReportProgress(100);
                ShowInformationMessage("导出成功。");
                //this.Close();
            }
            catch (Exception ex)
            {
                ShowInformationMessage("导出错误,请联系管理员。错误原因:" + ex.Message);

                if (excelUtil != null)
                {
                    excelUtil.Close();
                }
            }
            finally
            {
                //add by justinleung 2011/09/06
                if (excelUtil != null)
                {
                    excelUtil.Close();
                }
                //this.Close();
            }
        }
        private void ExportChangeClassTemplate(string xlsSavePath)
        {
            ExcelUtil excelUtil = null;
            try
            {

                excelUtil = new ExcelUtil();

                excelUtil.Open(Application.StartupPath + "/ExcelTemplate/studentChangeClass.xls");
                bgWorkerGradeUpTemp.ReportProgress(10);
                //excelUtil.AddValueToCell(5,1,"simon");

                bgWorkerGradeUpTemp.ReportProgress(30);

                List<Model.IModel.IModelObject> classList = _IGeneralBL.GetMasterDataInformations(DefineConstantValue.MasterType.UserClass);

                AddDataToStuSheet(excelUtil, 3, classList);

                int startRow = 3;

                if (this._ListQueryStuInfo != null)
                {
                    foreach (CardUserMaster_cus_Info item in this._ListQueryStuInfo)
                    {
                        excelUtil.AddValueToCell(startRow, (Int32)ColName.cus_cRecordID, item.cus_cRecordID.ToString());

                        excelUtil.AddValueToCell(startRow, (Int32)ColName.cus_cChaName, item.cus_cChaName);

                        excelUtil.AddValueToCell(startRow, (Int32)ColName.cus_cStudentID, item.cus_cStudentID);

                        excelUtil.AddValueToCell(startRow, (Int32)ColName.cus_cClassName, item.ClassName);

                        startRow++;
                    }
                }

                bgWorkerGradeUpTemp.ReportProgress(90);
                excelUtil.SaveCopyAs(xlsSavePath);
                bgWorkerGradeUpTemp.ReportProgress(100);
                ShowInformationMessage("导出成功。");

            }
            catch (Exception ex)
            {
                ShowInformationMessage("导出错误,请联系管理员。错误原因:" + ex.Message);

                if (excelUtil != null)
                {
                    excelUtil.Close();
                }

            }
            finally
            {
                //add by justinleung 2011/09/06
                if (excelUtil != null)
                {
                    excelUtil.Close();
                }
                //this.Close();
            }
        }
        /// <summary>
        /// 导出模板
        /// </summary>
        /// <param name="xlsSavePath">文件保存路径</param>
        private void ExportTemplate(string xlsSavePath)
        {
            ExcelUtil excelUtil = null;
            try
            {
                excelUtil = new ExcelUtil();

                excelUtil.Open(Application.StartupPath + "/ExcelTemplate/TransferBatchRecharge.xls");
                bgWorker.ReportProgress(10);

                List<Model.IModel.IModelObject> sexList = this._IGeneralBL.GetMasterDataInformations(DefineConstantValue.MasterType.CardUserSex);

                AddDataToStuSheet(excelUtil, 2, sexList);

                bgWorker.ReportProgress(30);

                List<Model.IModel.IModelObject> classList = this._IGeneralBL.GetMasterDataInformations(DefineConstantValue.MasterType.UserClass);

                AddDataToStuSheet(excelUtil, 3, classList);

                bgWorker.ReportProgress(90);
                excelUtil.SaveCopyAs(xlsSavePath);
                excelUtil.Close();
                bgWorker.ReportProgress(100);

                ShowInformationMessage("导出成功。");
            }
            catch (Exception ex)
            {
                ShowInformationMessage("导出错误,请联系管理员。错误原因:" + ex.Message);
            }
            finally
            {
                try
                {
                    if (excelUtil != null)
                    {
                        excelUtil.Close();
                    }
                }
                catch (Exception)
                { }
            }
        }