diff --git a/AbazovApp/AbazovAppView/FormTest.cs b/AbazovApp/AbazovAppView/FormTest.cs index 6a052d0..bfa9301 100644 --- a/AbazovApp/AbazovAppView/FormTest.cs +++ b/AbazovApp/AbazovAppView/FormTest.cs @@ -138,7 +138,7 @@ namespace AbazovAppView openFileDialog.Dispose(); List images = new List(); string path = AppDomain.CurrentDomain.BaseDirectory + "test.xlsx"; - if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Header", files))) MessageBox.Show("Успех!"); + if (excelImagesComponent.createWithImages(path, "Header", files)) MessageBox.Show("Успех!"); else MessageBox.Show("Ошибка, проверьте консоль"); } diff --git a/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImageInfo.cs b/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImageInfo.cs deleted file mode 100644 index 179b035..0000000 --- a/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImageInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AbazovViewComponents.LogicalComponents -{ - public class ExcelImageInfo - { - public ExcelImageInfo(string path, string title, string[] imagePaths) - { - this.path = path; - this.title = title; - this.imagePaths = imagePaths; - } - - public string path; - public string title; - public string[] imagePaths; - } -} diff --git a/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImagesComponent.cs b/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImagesComponent.cs index 26cfe6d..94f3aa3 100644 --- a/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImagesComponent.cs +++ b/AbazovApp/AbazovViewComponents/LogicalComponents/ExcelImagesComponent.cs @@ -24,7 +24,7 @@ namespace AbazovViewComponents.LogicalComponents InitializeComponent(); } - public bool createWithImages(ExcelImageInfo info) + public bool createWithImages(string pathToFile, string title, string[] imagePaths) { var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 }; Workbook workbook = excelApp.Workbooks.Add(Type.Missing); @@ -43,10 +43,10 @@ namespace AbazovViewComponents.LogicalComponents excelcells.RowHeight = 25; excelcells.HorizontalAlignment = Constants.xlCenter; excelcells.VerticalAlignment = Constants.xlCenter; - excelcells.Value2 = info.title; + excelcells.Value2 = title; int topOffset = 25; - foreach (string path in info.imagePaths) + foreach (string path in imagePaths) { Bitmap bm = new Bitmap(path); worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse); @@ -56,7 +56,7 @@ namespace AbazovViewComponents.LogicalComponents //save object missing = System.Reflection.Missing.Value; - workbook.SaveAs(info.path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange, + workbook.SaveAs(pathToFile, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing); workbook.Close(); excelApp.Quit();