PIbd-33_Sergunov_M.A._COP_4/Library/LibraryView/FormSecond.cs

79 lines
2.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CustomComponents;
using CustomComponents.MyNonVisualComponents;
using Microsoft.VisualBasic;
namespace LibraryView
{
public partial class FormSecond : Form
{
public FormSecond()
{
InitializeComponent();
}
private void buttonCreateExDoc_Click(object sender, EventArgs e)
{
string[] text = { "Некий текст 1", "Ещё один некий текст", "Текст" };
BigTextComponent bigText = new BigTextComponent();
bigText.CreateExcel("D:\\Papka\\КОП\\ExcelDoc.xls", "Документ", text);
}
private void buttonCreateTable_Click(object sender, EventArgs e)
{
TableComponent table = new TableComponent();
var dict = new List<MergeCells>();
//table.columnsName = new List<string>() { "ID", "Status", "Name", "Surname", "Age", "Kid", "Division", "Post", "Prize" };
var columnsName = new List<string>() { "ID", "Status", "Name", "Surname", "Age", "Kid", "Division", "Post", "Prize" };
int[] arrayHeight = { 30, 30, 20, 20, 30, 40, 20, 20, 20 };
string[] arrayHeaderAL = { "Идентификатор", "Статус", "Имя", "Фамилия", "Возраст", "Дети", "Подразделение", "Должность", "Премия" };
var listPeople = new List<People>() { new People(1, "Женат", "Иван", "Иванов", 31, 2, "One", "One", 25000),
new People(2, "Не женат", "Андрей", "Петров", 26, 1, "One", "One", 31000),
new People(3, "Замужем", "Наталья", "Беляева", 21, 0, "One", "One", 20000),
new People(4, "Не женат", "Константин", "Рогов", 28, 1, "One", "One", 29000) };
dict.Add(new MergeCells("Личные данные", new int[] { 2, 3, 4 }));
dict.Add(new MergeCells("Работа", new int[] { 6, 7 }));
table.CreateTableExcel("D:\\Papka\\КОП\\ExcelTab.xls", "Люди", dict, arrayHeight, arrayHeaderAL, columnsName, listPeople);
}
private List<(double, double)> GenerateRandomData(int count)
{
Random random = new Random();
var data = new List<(double, double)>();
for (int i = 1; i <= count; i++)
{
data.Add((i, random.NextDouble() * 50));
}
return data;
}
private void buttonCreateDiagram_Click(object sender, EventArgs e)
{
LineChartConfig data = new LineChartConfig();
data.FilePath = "D:\\Papka\\КОП\\ExcelDiagram.xls";
data.Header = "MyDiagram";
data.ChartTitle = "Diagram";
string[] Names = { "Первая", "Вторая" };
var list2D = new Dictionary<string, List<int>>();
for (var i = 0; i < 2; i++)
{
var row = new List<int>();
for (var j = 0; j < 5; j++)
row.Add(5 * i + j + 1);
list2D.Add(Names[i], row);
}
data.Values = list2D;
DiagramComponent diagram = new DiagramComponent();
diagram.CreateExcel(data);
}
}
}