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(); } }
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(); } }
/// <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) { } } }