PIbd-32.-Stroev-V.M.-COP/WinFormsLibrary1/WinFormsApp1/Form2.cs

95 lines
3.5 KiB
C#
Raw Normal View History

2024-10-14 19:54:00 +04:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsLibrary1.Models;
namespace WinFormsApp1
{
public partial class Form2: Form
{
public Form2()
{
InitializeComponent();
}
private void buttonCreateTextDocument_Click(object sender, EventArgs e)
{
string filepath = "C:\\Users\\Владимир\\Desktop\\BigTextDocumentExcel.xlsx";
string title = "Документ с большим текстом";
string[] rows =
{
"Строка1",
"Строка2",
"Строка3",
"Строка4"
};
bigTextComponent1.CreateDocument(filepath, title, rows);
}
private void buttonCreateTableDocument_Click(object sender, EventArgs e)
{
string filepath = "C:\\Users\\Владимир\\Desktop\\TableDocumentExcel.xlsx";
string title = "Документ с таблицей";
List<MergeCell> mergeCells = new List<MergeCell>()
{
new MergeCell("Личные данные", new int[] { 2, 3, 4 }),
};
List<Column> columns = new List<Column>()
{
new Column("Id", "Id", 10),
new Column("Status", "Статус", 10),
new Column("Name", "Имя", 20),
new Column("Familia", "Фамилия", 20),
new Column("Age", "Возраст", 20),
new Column("Department", "Подразделение", 30),
new Column("Salary", "зарплата", 10)
};
List<User> data = new List<User>()
{
new User(1, "нет", "Владимир", "Строев", 34, "Департамент 1", 2000.1),
new User(2, "нет", "Михаил", "Патрушев", 23, "Департамент 2", 192.9),
new User(3, "да", "Евгений", "Борисов", 19, "Департамент 4", 566),
new User(4, "да", "Иван", "Иванов", 41, "Департамент 5", 3990.5),
new User(5, "нет", "Владимир", "Строев", 39, "Департамент 3", 1596.0),
};
tableComponent1.CreateDocument(filepath, title,
mergeCells, columns,
data);
}
private void buttonCreateDiagramDocument_Click(object sender, EventArgs e)
{
LineChartConfig config = new LineChartConfig();
config.Filepath = "C:\\Users\\Владимир\\Desktop\\DiagramDocumentExcel.xlsx";
config.Header = "Документ с диаграммой";
config.ChartTitle = "Моя диаграмма";
string[] charts = { "График 1", "График 2" };
var data = new Dictionary<string, List<int>>();
for (int i = 0; i < 2; i++)
{
var row = new List<int>();
for (var j = 0; j < 5; j++)
{
row.Add(5 * i + j + 1);
}
data.Add(charts[i], row);
}
config.Values = data;
config.LegendPosition = LegendPosition.Bottom;
diagramComponent1.CreateDocument(config);
}
}
}