示例#1
0
        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
            }
        }
示例#2
0
        private void removeEntriesFromMasterGroupCollection(string wbName)
        {
            MasterGroupSheetCollection tempGroupCollection = new MasterGroupSheetCollection();

            foreach (GroupSheetCollection gsc in this.masterGroupCollection)
            {
                if (gsc.WBName != wbName)
                {
                    tempGroupCollection.Add(gsc);
                }
            }
            masterGroupCollection = tempGroupCollection;
        }