public ProtocolsCatalogVM(TECTemplates templates, ReferenceDropper dropHandler) : base(templates, dropHandler) { this.ConnectionTypes = new ObservableCollection <TECConnectionType>(); this.AddProtocolCommand = new RelayCommand(addProtocolExecute, canAddProtocol); this.ConnectionTypes.CollectionChanged += connectionTypesCollectionChanged; }
private static void createValvesSheet(XLWorkbook workbook, TECTemplates templates) { IXLWorksheet worksheet = workbook.Worksheets.Add("Valves"); int x = 1, y = 2; y = addHardwareHeader(worksheet, x, y).nextColumn; y = addEndDeviceHeader(worksheet, x, y).nextColumn; worksheet.Cell(x, y).Value = "Actuator"; worksheet.Cell(x, y).Style.Font.SetBold(); worksheet.Cell(x, y).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; x++; int startY = 2; foreach (TECValve valve in templates.Catalogs.Valves) { int rowY = startY; startY = addHardwareRow(worksheet, valve, x, startY).nextColumn; startY = addEndDeviceRow(worksheet, valve, x, startY).nextColumn; worksheet.Cell(x, startY).Value = valve.Actuator.Name; x++; } worksheet.Columns().AdjustToContents(); worksheet.PageSetup.PageOrientation = XLPageOrientation.Landscape; worksheet.PageSetup.FitToPages(1, 1); }
private static void createSystemSheet(XLWorkbook workbook, TECTemplates templates) { IXLWorksheet worksheet = workbook.Worksheets.Add("Systems"); int x = 1, y = 2; y = addScopeHeader(worksheet, x, y).nextColumn; y = addScopeHeader(worksheet, x, y).nextColumn; x = addSubScopeHeader(worksheet, x, y).nextRow; foreach (TECSystem system in templates.Templates.SystemTemplates) { foreach (TECEquipment equipment in system.Equipment) { foreach (TECSubScope scope in equipment.SubScope) { y = 2; y = addScopeRow(worksheet, system, x, y).nextColumn; y = addScopeRow(worksheet, equipment, x, y).nextColumn; x = addSubScopeRow(worksheet, scope, x, y).nextRow; } } } worksheet.Columns().AdjustToContents(); worksheet.PageSetup.PageOrientation = XLPageOrientation.Landscape; worksheet.PageSetup.FitToPages(1, 1); }
public void TemplatedSubScopeRemovedFromTemplateEquipment() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer; TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer; TECEquipment templateEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(templateEquip); TECSubScope templateSS = new TECSubScope(); templates.Templates.SubScopeTemplates.Add(templateSS); TECSubScope instanceSS = ssSynchronizer.NewItem(templateSS); templateEquip.SubScope.Add(instanceSS); TECEquipment instanceEquip = equipSynchronizer.NewItem(templateEquip); templates.Templates.EquipmentTemplates.Add(instanceEquip); //Act templateEquip.SubScope.Remove(instanceSS); //Assert Assert.IsTrue(instanceEquip.SubScope.Count == 0, "SubScope not removed properly from equipment reference."); Assert.IsFalse(ssSynchronizer.Contains(instanceSS), "Reference SubScope not removed properly from synchronizer."); Assert.IsTrue(ssSynchronizer.Contains(templateSS), "Template SubScope was removed from synchronizer when it shouldn't have been."); }
public void InstanceSubScopeRemovedFromReferenceEquipment() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer; TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer; TECEquipment templateEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(templateEquip); TECSubScope ss = new TECSubScope(); templateEquip.SubScope.Add(ss); TECEquipment refEqiup = equipSynchronizer.NewItem(templateEquip); TECSubScope refSS = refEqiup.SubScope[0]; //Act refEqiup.SubScope.Remove(refSS); //Assert Assert.IsTrue(templateEquip.SubScope.Count == 0, "SubScope not removed properly from Equipment template."); Assert.IsFalse(ssSynchronizer.Contains(ss), "SubScope was not removed properly from synchronizer."); Assert.IsFalse(ssSynchronizer.Contains(refSS), "Reference SubScope was not removed properly from synchronizer."); }
public void TemplateSubScopeRemoved() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECSubScope> synchronizer = templates.SubScopeSynchronizer; TECSubScope templateSS = new TECSubScope(); templateSS.Name = "First Name"; templates.Templates.SubScopeTemplates.Add(templateSS); TECEquipment templateEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(templateEquip); TECSubScope ss1 = synchronizer.NewItem(templateSS); TECSubScope ss2 = synchronizer.NewItem(templateSS); templateEquip.SubScope.Add(ss1); templateEquip.SubScope.Add(ss2); //Act templates.Templates.SubScopeTemplates.Remove(templateSS); ss2.Name = "Second Name"; //Assert Assert.IsFalse(synchronizer.Contains(templateSS)); Assert.IsFalse(synchronizer.Contains(ss1)); Assert.IsFalse(synchronizer.Contains(ss2)); Assert.AreEqual("First Name", ss1.Name); Assert.AreEqual("Second Name", ss2.Name); }
public void TemplateEquipmentRemoved() { //Arrange TECTemplates templates = new TECTemplates(); TemplateSynchronizer <TECEquipment> synchronizer = templates.EquipmentSynchronizer; TECEquipment templateEquip = new TECEquipment(); templateEquip.Name = "First Name"; templates.Templates.EquipmentTemplates.Add(templateEquip); TECSystem templateSys = new TECSystem(); templates.Templates.SystemTemplates.Add(templateSys); TECEquipment equip1 = synchronizer.NewItem(templateEquip); TECEquipment equip2 = synchronizer.NewItem(templateEquip); templateSys.Equipment.Add(equip1); templateSys.Equipment.Add(equip2); //Act templates.Templates.EquipmentTemplates.Remove(templateEquip); equip2.Name = "Second Name"; //Assert Assert.IsFalse(synchronizer.Contains(templateEquip)); Assert.IsFalse(synchronizer.Contains(equip1)); Assert.IsFalse(synchronizer.Contains(equip2)); Assert.AreEqual("First Name", equip1.Name); Assert.AreEqual("Second Name", equip2.Name); }
public ControllersPanelsVM(TECTemplates templates) : this(templates, templates.Templates.ControllerTemplates, templates.Templates.PanelTemplates) { PanelSelectionReadOnly = false; PanelSelectionVisibility = Visibility.Collapsed; Templates = templates; }
public static void ClassInitialize(TestContext TestContext) { string path = Path.GetTempFileName(); TestDBHelper.CreateTestTemplates(path); actualTemplates = EULTestHelper.LoadTestTemplates(path); }
public void Refresh(TECScopeManager scopeManager) { var bid = scopeManager as TECBid; var templates = scopeManager as TECTemplates; if (bid != null) { QuantityVisibility = Visibility.Visible; if (_bid != null) { _bid.MiscCosts.CollectionChanged -= MiscCosts_CollectionChanged; } bid.MiscCosts.CollectionChanged += MiscCosts_CollectionChanged; _bid = bid; sourceCollection = bid.MiscCosts; populateCollections(); } else if (templates != null) { QuantityVisibility = Visibility.Collapsed; if (templates != null) { templates.Templates.MiscCostTemplates.CollectionChanged -= MiscCosts_CollectionChanged; } templates.Templates.MiscCostTemplates.CollectionChanged += MiscCosts_CollectionChanged; _templates = templates; sourceCollection = templates.Templates.MiscCostTemplates; populateCollections(); } }
private string getTemplateText(TECObject item) { TECTemplates templates = ScopeManager as TECTemplates; if (templates.IsTemplateObject(item)) { string parentString = ""; if (item is TECSubScope subScope) { TECSubScope parent = templates.SubScopeSynchronizer.GetParent(subScope); if (item != parent && parent != null) { parentString = String.Format(" of {0}", parent.Name); } } else if (item is TECEquipment equipment) { TECEquipment parent = templates.EquipmentSynchronizer.GetParent(equipment); if (item != parent && parent != null) { parentString = String.Format(" of {0}", parent.Name); } } return(String.Format("Reference{0}", parentString)); } return("Instance Template"); }
private void handleLoadedTemplates(TECTemplates templates) { if (ReplaceScope) { bid.Templates.Unionize(templates.Templates); } else { bid.Templates.Fill(templates.Templates); } if (ReplaceCatalogs) { bid.Catalogs.Unionize(templates.Catalogs); } else { bid.Catalogs.Fill(templates.Catalogs); } if (databaseManager == null && bid.Templates.Parameters.Count > 0) { bid.Parameters = new TECParameters(bid.Templates.Parameters.First()); } ModelLinkingHelper.LinkBidToCatalogs(bid); estimate = new TECEstimator(bid, watcher); EditorVM = new EstimateEditorVM(bid, watcher, estimate); CurrentVM = EditorVM; ViewEnabled = true; }
public static bool LinkLoadedTemplates(TECTemplates templates, Dictionary <Guid, List <Guid> > templateReferences) { bool needsSave = false; linkTemplateReferences(templates, templateReferences); return(needsSave); }
public DevicesCatalogVM(TECTemplates templates, ReferenceDropper dropHandler) : base(templates, dropHandler) { this.DeviceConnectionTypes = new ObservableCollection <TECConnectionType>(); this.DeviceProtocols = new ObservableCollection <TECProtocol>(); this.AddDeviceCommand = new RelayCommand(addDeviceExecute, canAddDevice); this.DeleteDeviceCommand = new RelayCommand(deleteDeviceExecute, canDeleteDevice); }
public IOModulesCatalogVM(TECTemplates templates, ReferenceDropper dropHandler) : base(templates, dropHandler) { this.ModuleIO = new ObservableCollection <TECIO>(); this.AddIOToModuleCommand = new RelayCommand(addIOToModuleExecute, canAddIOToModule); this.AddIOModuleCommand = new RelayCommand(addIOModuleExecute, canAddIOModuleExecute); this.ProtocolToIODropTarget = new ProtocolToIODropTarget(); }
public static void ClassInitialize(TestContext TestContext) { var path = Path.GetTempFileName(); LegacyDBGenerator.CreateTestTemplates(path); DatabaseManager <TECTemplates> manager = new DatabaseManager <TECTemplates>(path); actualTemplates = manager.Load() as TECTemplates; }
public static TECTemplates TestTemplates(Random rand) { TECTemplates templates = new TECTemplates(); templates.Catalogs = TestCatalogs(rand, 5); templates.Templates = TestScopeTemplates(templates.Catalogs, rand); return(templates); }
public void DeleteDeviceUserInputNo() { //Arrange TECTemplates templatesManager = new TECTemplates(); TECScopeTemplates templates = templatesManager.Templates; TECManufacturer man = new TECManufacturer(); templatesManager.Catalogs.Add(man); TECDevice dev = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), man); templatesManager.Catalogs.Add(dev); TECSystem sys = new TECSystem(); templates.SystemTemplates.Add(sys); TECEquipment sysEquip = new TECEquipment(); sys.Equipment.Add(sysEquip); TECSubScope sysSS = new TECSubScope(); sysEquip.SubScope.Add(sysSS); sysSS.Devices.Add(dev); TECEquipment equip = new TECEquipment(); templates.EquipmentTemplates.Add(equip); TECSubScope equipSS = new TECSubScope(); equip.SubScope.Add(equipSS); equipSS.Devices.Add(dev); TECSubScope ss = new TECSubScope(); templates.SubScopeTemplates.Add(ss); ss.Devices.Add(dev); //Act Mock <IUserConfirmable> mockMessageBox = new Mock <IUserConfirmable>(); mockMessageBox .Setup(x => x.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>())) .Returns(MessageBoxResult.No); DeleteEndDeviceVM vm = new DeleteEndDeviceVM(dev, templatesManager); vm.messageBox = mockMessageBox.Object; vm.DeleteCommand.Execute(null); //Assert Assert.IsTrue(templatesManager.Catalogs.Devices.Contains(dev), "Device not removed from device templates properly."); Assert.IsTrue(sysSS.Devices.Contains(dev), "Device not removed from system template properly."); Assert.IsTrue(equipSS.Devices.Contains(dev), "Device not removed from equipment template properly."); Assert.IsTrue(ss.Devices.Contains(dev), "Device not removed from subscope template properly."); }
public ControllerTypesCatalogVM(TECTemplates templates, ReferenceDropper dropHandler) : base(templates, dropHandler) { this.ControllerTypeIO = new ObservableCollection <TECIO>(); this.ControllerTypeModules = new QuantityCollection <TECIOModule>(); this.AddIOCommand = new RelayCommand(addIOToControllerTypeExecute, canAddIOToControllerType); this.AddControllerTypeCommand = new RelayCommand(addControllerTypeExecute, canAddControllerType); this.ProtocolToIODropTarget = new ProtocolToIODropTarget(); }
private void setupAddRemoveMethods(TECTemplates templates) { addControllerMethod = templates.Templates.ControllerTemplates.Add; addPanelMethod = templates.Templates.PanelTemplates.Add; deleteControllerMethod = controller => { controller.DisconnectAll(); templates.Templates.ControllerTemplates.Remove(controller); }; deletePanelMethod = panel => { templates.Templates.PanelTemplates.Remove(panel); }; }
public static void ClassInitialize(TestContext TestContext) { path = Path.GetTempFileName(); TestDBHelper.CreateTestBid(path); bid = EULTestHelper.LoadTestBid(path); path = Path.GetTempFileName(); TestDBHelper.CreateTestTemplates(path); templates = EULTestHelper.LoadTestTemplates(path); }
public DeleteEndDeviceVM(IEndDevice endDevice, TECTemplates templates) { messageBox = new MessageBoxService(); this.templates = templates; this.EndDevice = endDevice; PotentialReplacements = new List <IEndDevice>(); populatePotentialReplacements(); DeleteCommand = new RelayCommand(deleteExecute); DeleteAndReplaceCommand = new RelayCommand(deleteAndReplaceExecute, deleteAndReplaceCanExecute); }
public void SubScopeTemplateChanged() { //Arrange TECTemplates templates = new TECTemplates(); TECSubScope templateSS = new TECSubScope(); templateSS.Name = "Template SubScope"; templates.Templates.SubScopeTemplates.Add(templateSS); TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer; TECSubScope refSS = ssSynchronizer.NewItem(templateSS); TECEquipment equip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(equip); equip.SubScope.Add(refSS); TECDevice dev = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer()); templates.Catalogs.Add(dev); TECPoint point = new TECPoint(); point.Label = "Test Point"; point.Type = IOType.AI; point.Quantity = 5; TECAssociatedCost cost = new TECAssociatedCost(CostType.TEC); templates.Catalogs.Add(cost); TECTag tag = new TECTag(); templates.Catalogs.Add(tag); //Act templateSS.Description = "Test Description"; templateSS.Devices.Add(dev); templateSS.AddPoint(point); templateSS.AssociatedCosts.Add(cost); templateSS.Tags.Add(tag); //Assert //Assert.AreEqual(templateSS.Description, refSS.Description, "Description didn't sync properly between SubScope."); Assert.AreEqual(templateSS.Devices[0], refSS.Devices[0], "Devices didn't sync properly between SubScope."); Assert.AreEqual(templateSS.Points[0].Label, refSS.Points[0].Label, "Points didn't sync properly between SubScope."); Assert.AreEqual(templateSS.Points[0].Type, refSS.Points[0].Type, "Points didn't sync properly between SubScope."); Assert.AreEqual(templateSS.Points[0].Quantity, refSS.Points[0].Quantity, "Points didn't sync properly between SubScope."); Assert.AreEqual(templateSS.AssociatedCosts[0], refSS.AssociatedCosts[0], "Associated costs didn't sync properly between SubScope."); Assert.AreEqual(templateSS.Tags[0], refSS.Tags[0], "Tags didn't sync properly between SubScope."); }
public void IsTemplateObjectTest() { Random rand = new Random(0); TECTemplates templates = ModelCreation.TestTemplates(rand); var scopeTemplates = templates.Templates; Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.SubScopeTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.EquipmentTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.SystemTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.ControllerTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.PanelTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.MiscCostTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.Parameters.First())); }
public static void ClassInitialize(TestContext TestContext) { rand = new Random(0); //Arrange expectedTemplates = ModelCreation.TestTemplates(rand); ModelCreation.AddSyncronizerItems(expectedTemplates); expectedSystem = expectedTemplates.Templates.SystemTemplates.First(); expectedEquipment = expectedTemplates.Templates.EquipmentTemplates.First(); expectedSubScope = expectedTemplates.Templates.SubScopeTemplates.First(); expectedDevice = expectedTemplates.Catalogs.Devices.First(); expectedManufacturer = expectedTemplates.Catalogs.Manufacturers.First(); expectedTag = expectedTemplates.Catalogs.Tags[0]; expectedController = (TECProvidedController)expectedTemplates.Templates.ControllerTemplates.First(sys => sys is TECProvidedController); expectedAssociatedCost = expectedTemplates.Catalogs.AssociatedCosts[0]; expectedConnectionType = expectedTemplates.Catalogs.ConnectionTypes[0]; expectedConduitType = expectedTemplates.Catalogs.ConduitTypes[0]; path = Path.GetTempFileName(); //Act DatabaseManager <TECTemplates> manager = new DatabaseManager <TECTemplates>(path); bool success = manager.New(expectedTemplates); Assert.IsTrue(success, "New method in DatabaseManager returned false."); actualTemplates = manager.Load(); if (actualTemplates.Templates.SystemTemplates.Count == 0) { string failDirectory = Path.GetTempPath() + "Estimating Tools\\"; Directory.CreateDirectory(failDirectory); string failPath = failDirectory + "SaveNewTemplatesTestFailed.tdb"; if (File.Exists(failPath)) { File.Delete(failPath); } File.Copy(path, failPath); Assert.Fail(string.Format("No systems loaded into templates. File saved at: {0}", failPath)); } actualSystem = actualTemplates.Templates.SystemTemplates.First(x => x.Guid == expectedSystem.Guid); actualEquipment = actualTemplates.Templates.EquipmentTemplates.First(x => x.Guid == expectedEquipment.Guid); actualSubScope = actualTemplates.Templates.SubScopeTemplates.First(x => x.Guid == expectedSubScope.Guid); actualDevice = actualTemplates.Catalogs.Devices.First(x => x.Guid == expectedDevice.Guid); actualManufacturer = actualTemplates.Catalogs.Manufacturers.First(x => x.Guid == expectedManufacturer.Guid); actualTag = actualTemplates.Catalogs.Tags.First(x => x.Guid == expectedTag.Guid); actualController = actualTemplates.Templates.ControllerTemplates.First(x => x.Guid == expectedController.Guid) as TECProvidedController; actualAssociatedCost = actualTemplates.Catalogs.AssociatedCosts.First(x => x.Guid == expectedAssociatedCost.Guid); actualConnectionType = actualTemplates.Catalogs.ConnectionTypes.First(x => x.Guid == expectedConnectionType.Guid); actualConduitType = actualTemplates.Catalogs.ConduitTypes.First(x => x.Guid == expectedConduitType.Guid); }
public void CopyTemplateWithReferences() { //Arrange TECTemplates templates = new TECTemplates(); TECEquipment tempEquip = new TECEquipment(); templates.Templates.EquipmentTemplates.Add(tempEquip); TECSubScope tempSS = new TECSubScope(); tempSS.Name = "Template SS"; templates.Templates.SubScopeTemplates.Add(tempSS); tempEquip.SubScope.Add(templates.SubScopeSynchronizer.NewItem(tempSS)); TECSubScope equipSS = new TECSubScope(); equipSS.Name = "Equipment SS"; tempEquip.SubScope.Add(equipSS); //Act TECEquipment equipCopy = new TECEquipment(tempEquip, ssSynchronizer: templates.SubScopeSynchronizer); //Assert TECSubScope newTempSS = null, newEquipSS = null; foreach (TECSubScope ss in equipCopy.SubScope) { if (ss.Name == "Template SS") { newTempSS = ss; } else if (ss.Name == "Equipment SS") { newEquipSS = ss; } else { Assert.Fail("Different subScope than expected in equipment copy."); } } Assert.IsNotNull(newTempSS, "Template SubScope didn't copy properly."); Assert.IsNotNull(newEquipSS, "Equipment SubScope didn't copy properly."); TemplateSynchronizer <TECSubScope> ssSync = templates.SubScopeSynchronizer; Assert.IsTrue(ssSync.Contains(newTempSS)); Assert.IsTrue(ssSync.GetFullDictionary()[tempSS].Contains(newTempSS)); }
public ControllersPanelsVM(TECSystem system, TECScopeManager manager, bool canSelectPanel = true) : this(system, system.Controllers, system.Panels) { if (manager is TECBid) { _bid = manager as TECBid; } else { _templates = manager as TECTemplates; } PanelSelectionReadOnly = !canSelectPanel; PanelSelectionVisibility = Visibility.Visible; SelectedSystem = system; }
private static void createSubScopeSheet(XLWorkbook workbook, TECTemplates templates) { IXLWorksheet worksheet = workbook.Worksheets.Add("Points"); int x = 1, y = 2; x = addSubScopeHeader(worksheet, x, y).nextRow; foreach (TECSubScope scope in templates.Templates.SubScopeTemplates) { x = addSubScopeRow(worksheet, scope, x, y).nextRow; } worksheet.Columns().AdjustToContents(); worksheet.PageSetup.PageOrientation = XLPageOrientation.Landscape; worksheet.PageSetup.FitToPages(1, 1); }
public MaterialVM(TECTemplates templates) { ReferenceDropHandler = new ReferenceDropper(templates); Templates = templates; //Setup VMs subscribeToVM(DeviceVM = new DevicesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(ValveVM = new ValvesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(ConnectionTypeVM = new ConnectionTypesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(ConduitTypeVM = new ConduitTypesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(ControllerTypeVM = new ControllerTypesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(PanelTypeVM = new PanelTypesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(AssociatedCostVM = new AssociatedCostsCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(IOModuleVM = new IOModulesCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(ManufacturerVM = new ManufacturersCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(TagVM = new TagsCatalogVM(templates, ReferenceDropHandler)); subscribeToVM(MiscVM = new MiscCostsVM(templates)); subscribeToVM(ProtocolVM = new ProtocolsCatalogVM(templates, ReferenceDropHandler)); }
private static void createControllerTypeSheet(XLWorkbook workbook, TECTemplates templates) { IXLWorksheet worksheet = workbook.Worksheets.Add("Controller Types"); int x = 1, y = 2; (x, y) = addHardwareHeader(worksheet, x, y); int startY = 2; foreach (TECControllerType item in templates.Catalogs.ControllerTypes) { int rowY = startY; x = addHardwareRow(worksheet, item, x, rowY).nextRow; } worksheet.Columns().AdjustToContents(); worksheet.PageSetup.PageOrientation = XLPageOrientation.Landscape; worksheet.PageSetup.FitToPages(1, 1); }