Пример #1
0
        public ExcelHelper GetExcelFile()
        {
            if (_SingleExcelHelper == null)
            {
                _SingleExcelHelper = new ExcelHelper();
                _SingleExcelHelper.Create();
            }

            return _SingleExcelHelper;
        }
Пример #2
0
        public ExcelHelper GetExcelFileByPath(string FilePath)
        {
            if (_SingleExcelHelper == null)
            {
                _SingleExcelHelper = new ExcelHelper();
                _SingleExcelHelper.GetCreated(FilePath);
                _FilePath = FilePath;
            }

            return _SingleExcelHelper;
        }
Пример #3
0
        public void Release()
        {
            if (xlWorkBook != null)
            {

                xlWorkBook = null;
            }

            if (xlApp != null)
            {
                xlApp.Quit();
                xlApp = null;

                _SingleExcelHelper = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
Пример #4
0
        public bool GetResourceReport()
        {
            try
            {
                DataTable departmentNamesWithTeamSize = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByManCount_ExcelTeam");

                DataView dv = departmentNamesWithTeamSize.DefaultView;
                dv.Sort = departmentNamesWithTeamSize.Columns[0].Caption;
                DataTable sortedDepartmentNamesWithTeamSize = dv.ToTable();

                for (int i = 0; i < departmentNamesWithTeamSize.Rows.Count; i++)
                {

                    DataTable teamNamesWithTeamSize = spHelper.GetData_withSpNameAndParameter("sp_FunctionTeam_MH_Report_ByManCount_byTeamName", sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0].ToString());

                    xlHelper = xlHelper.GetExcelFileByPath(Environment.CurrentDirectory + @"\PKL_Kaynak.xlsm");


                    #region HS Kadro Data


                    DataTable departmentNameWithTeamSize = sortedDepartmentNamesWithTeamSize.Clone();
                    departmentNameWithTeamSize.Rows.Add(sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray);


                    xlHelper.ExportDataTable2TemplateSheetExpress(departmentNameWithTeamSize, "HS Kadro-Data", 1, true);

                    xlHelper.ExportDataTable2TemplateSheetExpress(teamNamesWithTeamSize, "HS Kadro-Data", 49, true);

                    #endregion

                    #region Ekip Bazında Data

                    DataTable squadNamesWithMh = spHelper.GetData_withSpNameAndParameter("sp_FunctionTeam_MH_Report_ByTeam_WithParameterTeamName", sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0].ToString());

                    xlHelper.ExportDataTable2TemplateSheetExpress(squadNamesWithMh, "Ekip Bazında-Data", 1, true);

                    #endregion

                    #region HS Kaynak Planı

                    DataTable hsSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByPlatform");

                    xlHelper.ExportDataTable2TemplateSheetExpress(hsSourcePlan, "HS Kaynak Planı", 1, true);
                    //
                    hsSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByPlatform_Cumulative_Excel");

                    xlHelper.ExportDataTable2TemplateSheetExpress(hsSourcePlan, "HS Kaynak Planı", 12, false);
                    //
                    hsSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_GetDate");

                    xlHelper.ExportDataTable2TemplateSheetExpress(hsSourcePlan, "HS Kaynak Planı", 25, false);
                    //
                    hsSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByPlatform_LastWeek");

                    xlHelper.ExportDataTable2TemplateSheetExpress(hsSourcePlan, "HS Kaynak Planı", 59, false);
                    //
                    hsSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByPlatform_LastWeek_Cumulative");

                    xlHelper.ExportDataTable2TemplateSheetExpress(hsSourcePlan, "HS Kaynak Planı", 70, false);
                    //



                    #endregion

                    #region MP Kaynak Planı

                    DataTable mpSourcePlan = spHelper.GetData_withSpName("sp_FunctionTeam_GetDate");
                    xlHelper.ExportDataTable2TemplateSheetExpress(mpSourcePlan, "MP Kaynak Planı", 25, false);

                    #endregion

                    #region Proje Bazında Grafik

                    DataTable graphicsBasedOnProject = spHelper.GetData_withSpName("sp_FunctionTeam_MH_Report_ByProject");
                    xlHelper.ExportDataTable2TemplateSheetExpress(graphicsBasedOnProject, "Proje Bazında-Grafik", 11, true);

                    #endregion




                    if (sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0].ToString().Contains("/"))
                    {
                        xlHelper.SaveCopyAs(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0].ToString().Split('/')[0].Trim() + "_" + sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0].ToString().Split('/')[1].Trim() + "_Report", ".xlsm");
                        xlHelper.ForceRelease();
                    }
                    else
                    {
                        xlHelper.SaveCopyAs(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + sortedDepartmentNamesWithTeamSize.Rows[i].ItemArray[0] + "_Report", ".xlsm");
                        xlHelper.ForceRelease();
                    }

                }

                return true;
            }
            catch (Exception)
            {

                throw;
                return false;
            }


        }
Пример #5
0
 public ReportManager()
 {
     xlHelper = new ExcelHelper();
 }