コード例 #1
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
        public GroupSheetCollection New()
        {
            GroupSheetCollection group = new GroupSheetCollection();

            List.Add(group);

            return(group);
        }
コード例 #2
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
        public int IndexOf(string WBName, int regressionIteration)
        {
            for (int i = 0; i < List.Count; i++)
            {
                GroupSheetCollection gsc = (GroupSheetCollection)List[i];
                if (gsc.WBName == WBName && gsc.regressionIteration == regressionIteration)
                {
                    return(i);
                }
            }

            return(-1);
        }
コード例 #3
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
        private void loadStateData(Excel.Worksheet ws, Excel.Workbook Wb)
        {
            try
            {
                removeEntriesFromMasterGroupCollection(Wb.Name);
                foreach (Excel.ListObject LO in ws.ListObjects)
                {
                    GroupSheetCollection gsc = new GroupSheetCollection();
                    gsc.WB     = Wb;
                    gsc.WBName = Wb.Name;
                    int rowCount = 0;
                    int r;
                    foreach (Excel.ListRow row in LO.ListRows)
                    {
                        rowCount++;
                        string sheetguid = row.Range.get_Resize(1, 1).Value2.ToString();
                        string iter      = row.Range.get_Resize(1, 1).Value2.ToString() == "regressionIteration" ? row.Range.get_Offset(0, 1).get_Resize(1, 1).Value2.ToString() : null;
                        string pltnm     = row.Range.get_Resize(1, 1).Value2.ToString() == "plantName" ? row.Range.get_Offset(0, 1).get_Resize(1, 1).Value2.ToString() : null;

                        Excel.Worksheet workSheet = ExcelHelpers.GetWorksheetbyGUID(Wb, sheetguid);

                        if (workSheet != null)
                        {
                            GroupSheet gs = new GroupSheet((Excel.Worksheet)workSheet, Convert.ToBoolean(((Excel.Range)row.Range.Cells[1, 3]).Value2.ToString()), Convert.ToBoolean(((Excel.Range)row.Range.Cells[1, 4]).Value2.ToString()), ws.Name);

                            if (gs.adjustedDataSheet && gs.WS.get_Range("A1").Value2 != null) //.ToString()
                            {
                                gs.Name = gs.WS.get_Range("A1").Value2.ToString();
                            }
                            gsc.Add(gs);
                        }

                        gsc.regressionIteration = int.TryParse(iter, out r) ? r : gsc.regressionIteration;
                        gsc.PlantName           = pltnm == null ? gsc.PlantName : pltnm;
                    }
                    if (masterGroupCollection.IndexOf(gsc.WBName, gsc.regressionIteration) < 0)
                    {
                        masterGroupCollection.Add(gsc);   // add the workbooks sheet collections to the master collection
                    }
                }
                //this will prevent the "would you like to save" dialog showing even when the user hasn't done anything
                Wb.Saved = true;
            }
            catch (Exception ex)
            {
                //throw ex;
                //TODO: Add Exception and Logging module
            }
        }
コード例 #4
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
        public void actualEnPI(Excel.ListObject LO)
        {
            groupSheetCollection           = new GroupSheetCollection();
            groupSheetCollection.PlantName = ((Excel.Worksheet)LO.Parent).Name;
            groupSheetCollection.WB        = (Excel.Workbook)((Excel.Worksheet)LO.Parent).Parent;
            groupSheetCollection.WBName    = groupSheetCollection.WB.Name;
            masterGroupCollection.Add(groupSheetCollection);
            groupSheetCollection.regressionIteration = masterGroupCollection.WorkbookNextIteration(groupSheetCollection.WB);

            object[,] sourcerows = ExcelHelpers.getYearArray(LO, Years);
            DataTable dtSourceData = DataHelper.ConvertToDataTable(LO.HeaderRowRange.Value2 as object[, ], sourcerows);

            EnPIData = new EnPIDataSet();

            EnPIData.WorksheetName  = ((Excel.Worksheet)LO.Parent).Name;
            EnPIData.SourceData     = dtSourceData;
            EnPIData.ListObjectName = LO.Name;
            EnPIData.BaselineYear   = BaselineYear;

            EnPIData.ProductionVariables = SelectedProduction;
            EnPIData.BuildingVariables   = SelectedBuildings;

            SelectedSources.Add(rsc.GetString("unadjustedTotalColName"));
            EnPIData.EnergySourceVariables = SelectedSources;

            EnPIData.Init();

            fromRegression = false;

            AdjustedDataSheet adjData = new AdjustedDataSheet(EnPIData);

            adjData.Populate(false);

            ActualSheet results = new ActualSheet(EnPIData);

            results.DetailDataSheet = adjData.thisSheet;
            results.AdjustedData    = adjData.AdjustedData;
            results.Populate();

            if (Globals.ThisAddIn.wizardPane.Visible)
            {
                Globals.ThisAddIn.hideWizard();
            }

            // cleanup
            ExcelHelpers.Cleanup(Globals.ThisAddIn.Application.ActiveWorkbook);
        }
コード例 #5
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
 public void Add(GroupSheetCollection group)
 {
     List.Add(group);
 }
コード例 #6
0
ファイル: ThisAddIn.cs プロジェクト: Tubbz-alt/EnPI
        public void plotEnPI(Excel.ListObject LO)
        {
            groupSheetCollection           = new GroupSheetCollection();
            groupSheetCollection.PlantName = ((Excel.Worksheet)LO.Parent).Name;
            groupSheetCollection.WB        = (Excel.Workbook)((Excel.Worksheet)LO.Parent).Parent;
            groupSheetCollection.WBName    = groupSheetCollection.WB.Name;
            masterGroupCollection.Add(groupSheetCollection);
            groupSheetCollection.regressionIteration = masterGroupCollection.WorkbookNextIteration(groupSheetCollection.WB);


            // create a data table with the data to be adjusted
            object[,] sourcerows = ExcelHelpers.getYearArray(LO, Years);
            DataTable dtSourceData = DataHelper.ConvertToDataTable(LO.HeaderRowRange.Value2 as object[, ], sourcerows);

            EnPIData = new EnPIDataSet();
            EnPIData.WorksheetName  = ((Excel.Worksheet)LO.Parent).Name;
            EnPIData.SourceData     = dtSourceData;
            EnPIData.ListObjectName = LO.Name;
            EnPIData.BaselineYear   = BaselineYear;
            EnPIData.ModelYear      = SelectedYear;
            EnPIData.ReportYear     = ReportYear; //Added By Suman for SEP Changes
            EnPIData.Years          = Years.Cast <string>().ToList();

            if (Utilities.Constants.MODEL_TOTAL)
            {
                SelectedSources.Add(rsc.GetString("unadjustedTotalColName"));
            }
            EnPIData.EnergySourceVariables = SelectedSources;
            EnPIData.IndependentVariables  = SelectedVariables;
            EnPIData.ProductionVariables   = SelectedProduction;
            EnPIData.BuildingVariables     = SelectedBuildings;

            EnPIData.Init();

            ModelSheets = new ModelSheetCollection();
            foreach (Utilities.EnergySource src in EnPIData.EnergySources)
            {
                ModelSheet aSrc = ModelSheets.Add(src);
                aSrc.Populate();
                aSrc.WS.Visible = Excel.XlSheetVisibility.xlSheetVisible;
            }

            AdjustedDataSheet adjData = new AdjustedDataSheet(EnPIData);

            adjData.Populate(true);

            EnPISheet results = new EnPISheet(EnPIData, false);

            results.AdjustedDataSheet = adjData.thisSheet;
            results.AdjustedData      = adjData.AdjustedData;
            results.Populate();

            //EnPISheet senpiresults = new EnPISheet(EnPIData, true);
            //senpiresults.AdjustedDataSheet = adjData.thisSheet;
            //senpiresults.AdjustedData = adjData.AdjustedData;
            //senpiresults.Populate();


            SEPSheet sepResults = new SEPSheet(EnPIData);

            sepResults.AdjustedDataSheet = adjData.thisSheet;
            sepResults.AdjustedData      = adjData.AdjustedData;
            sepResults.Populate();

            if (Globals.ThisAddIn.wizardPane.Visible)
            {
                Globals.ThisAddIn.hideWizard();
            }

            // cleanup
            ExcelHelpers.Cleanup(Globals.ThisAddIn.Application.ActiveWorkbook);
        }