Removed excel image info class
This commit is contained in:
parent
d302d4644b
commit
543925e6fe
@ -138,7 +138,7 @@ namespace AbazovAppView
|
|||||||
openFileDialog.Dispose();
|
openFileDialog.Dispose();
|
||||||
List<Bitmap> images = new List<Bitmap>();
|
List<Bitmap> images = new List<Bitmap>();
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "test.xlsx";
|
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("Ошибка, проверьте консоль");
|
else MessageBox.Show("Ошибка, проверьте консоль");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ namespace AbazovViewComponents.LogicalComponents
|
|||||||
InitializeComponent();
|
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 };
|
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||||
@ -43,10 +43,10 @@ namespace AbazovViewComponents.LogicalComponents
|
|||||||
excelcells.RowHeight = 25;
|
excelcells.RowHeight = 25;
|
||||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||||
excelcells.Value2 = info.title;
|
excelcells.Value2 = title;
|
||||||
|
|
||||||
int topOffset = 25;
|
int topOffset = 25;
|
||||||
foreach (string path in info.imagePaths)
|
foreach (string path in imagePaths)
|
||||||
{
|
{
|
||||||
Bitmap bm = new Bitmap(path);
|
Bitmap bm = new Bitmap(path);
|
||||||
worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse);
|
worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse);
|
||||||
@ -56,7 +56,7 @@ namespace AbazovViewComponents.LogicalComponents
|
|||||||
|
|
||||||
//save
|
//save
|
||||||
object missing = System.Reflection.Missing.Value;
|
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);
|
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||||
workbook.Close();
|
workbook.Close();
|
||||||
excelApp.Quit();
|
excelApp.Quit();
|
||||||
|
Loading…
Reference in New Issue
Block a user