diff --git a/COP/Components/LogicalComponents/ExcelImagesComponent.cs b/COP/Components/LogicalComponents/ExcelImagesComponent.cs index d791726..d99cbb3 100644 --- a/COP/Components/LogicalComponents/ExcelImagesComponent.cs +++ b/COP/Components/LogicalComponents/ExcelImagesComponent.cs @@ -25,6 +25,10 @@ namespace Components.LogicalComponents } public bool createWithImages(ExcelImageInfo info) { + if (string.IsNullOrEmpty(info.path) || string.IsNullOrEmpty(info.title) || info.imagePaths == null || info.imagePaths.Length == 0) + { + throw new ArgumentException("Не все поля заполнены."); + } var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 }; Workbook workbook = excelApp.Workbooks.Add(Type.Missing); try diff --git a/COP/WinFormsTest/FormTest.Designer.cs b/COP/WinFormsTest/FormTest.Designer.cs index d350632..0677660 100644 --- a/COP/WinFormsTest/FormTest.Designer.cs +++ b/COP/WinFormsTest/FormTest.Designer.cs @@ -223,6 +223,7 @@ // openFileDialog // this.openFileDialog.FileName = "openFileDialog"; + this.openFileDialog.Multiselect = true; // // FormTest // diff --git a/COP/WinFormsTest/FormTest.cs b/COP/WinFormsTest/FormTest.cs index 6c36304..cfb7286 100644 --- a/COP/WinFormsTest/FormTest.cs +++ b/COP/WinFormsTest/FormTest.cs @@ -1,5 +1,7 @@ using Components.Exceptions; using Components.LogicalComponents; +using Microsoft.Office.Core; +using Microsoft.VisualBasic.ApplicationServices; using System; using System.Collections.Generic; using System.ComponentModel; @@ -142,7 +144,7 @@ namespace WinFormsTest var files = openFileDialog.FileNames; openFileDialog.Dispose(); List images = new List(); - string path = AppDomain.CurrentDomain.BaseDirectory + "test.xlsx"; + string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test.xlsx"; if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Header", files))) MessageBox.Show("Успех!"); else MessageBox.Show("Ошибка, проверьте консоль"); } @@ -154,7 +156,7 @@ namespace WinFormsTest workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49")); workers.Add(new OfficeWorker(1, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49")); workers.Add(new OfficeWorker(1, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true)); - string path = AppDomain.CurrentDomain.BaseDirectory + "test2.xlsx"; + string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test2.xlsx"; List<(int, int)> merges = new List<(int, int)>(); merges.Add((1, 3)); merges.Add((4, 6)); @@ -177,7 +179,7 @@ namespace WinFormsTest departments.Add(new Department("Dep 1", 330)); departments.Add(new Department("Dep 2", 500)); departments.Add(new Department("Dep 3", 170)); - string path = AppDomain.CurrentDomain.BaseDirectory + "test3.xlsx"; + string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test3.xlsx"; if (excelDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells")) MessageBox.Show("Успех"); else MessageBox.Show("Fail :("); }