public void ReadComtecFile(bool consoleOut, bool party) { excel.OpenWorkBook(comtecFilePath); int lastRow = excel.LastRow(); for (int i = 2; i <= lastRow; i++) { comtecList.Add(new Item { store = !party ? excel.ReadValue(i, 1) : null, party = party ? excel.ReadValue(i, 1) : null, name = excel.ReadValue(i, 2), cQuantity = Convert.ToDecimal(excel.ReadValue(i, 3)) }); if (consoleOut) { ConsoleOut(i); } } excel.CloseWorkBook(); }