Returned excel image info
This commit is contained in:
parent
543925e6fe
commit
42b90c4d90
@ -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(path, "Header", files)) MessageBox.Show("Успех!");
|
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Header", files))) MessageBox.Show("Успех!");
|
||||||
else MessageBox.Show("Ошибка, проверьте консоль");
|
else MessageBox.Show("Ошибка, проверьте консоль");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ namespace AbazovAppView
|
|||||||
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
|
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, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
|
||||||
workers.Add(new OfficeWorker(1, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
|
workers.Add(new OfficeWorker(1, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "test.xlsx";
|
string path = AppDomain.CurrentDomain.BaseDirectory + "test2.xlsx";
|
||||||
List<(int, int)> merges = new List<(int, int)>();
|
List<(int, int)> merges = new List<(int, int)>();
|
||||||
merges.Add((1, 3));
|
merges.Add((1, 3));
|
||||||
merges.Add((4, 6));
|
merges.Add((4, 6));
|
||||||
@ -162,7 +162,7 @@ namespace AbazovAppView
|
|||||||
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон"),
|
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон"),
|
||||||
("isInVacation", "В отпуске"), };
|
("isInVacation", "В отпуске"), };
|
||||||
|
|
||||||
if (excelTableComponent.createWithTable(path, "test", merges, heights, headers, workers)) MessageBox.Show("Успех");
|
if (excelTableComponent.createWithTable(path, "test2", merges, heights, headers, workers)) MessageBox.Show("Успех");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonExcelDiagram_Click(object sender, EventArgs e)
|
private void buttonExcelDiagram_Click(object sender, EventArgs e)
|
||||||
@ -172,8 +172,8 @@ namespace AbazovAppView
|
|||||||
departments.Add(new Department("Dep 1", 330));
|
departments.Add(new Department("Dep 1", 330));
|
||||||
departments.Add(new Department("Dep 2", 500));
|
departments.Add(new Department("Dep 2", 500));
|
||||||
departments.Add(new Department("Dep 3", 170));
|
departments.Add(new Department("Dep 3", 170));
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "test.xlsx";
|
string path = AppDomain.CurrentDomain.BaseDirectory + "test3.xlsx";
|
||||||
if (excelDiagramComponent.createWithDiagram(path, "test", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells")) MessageBox.Show("Успех");
|
if (excelDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells")) MessageBox.Show("Успех");
|
||||||
else MessageBox.Show("Fail :(");
|
else MessageBox.Show("Fail :(");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
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(string pathToFile, string title, string[] imagePaths)
|
public bool createWithImages(ExcelImageInfo info)
|
||||||
{
|
{
|
||||||
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 = title;
|
excelcells.Value2 = info.title;
|
||||||
|
|
||||||
int topOffset = 25;
|
int topOffset = 25;
|
||||||
foreach (string path in imagePaths)
|
foreach (string path in info.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(pathToFile, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
workbook.SaveAs(info.path, 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