2024-09-06 04:27:34 +04:00
|
|
|
|
using Components.NonVisualComponents;
|
|
|
|
|
using Components.NonVisualComponents.HelperModels;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace WinForms
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Форма для не визуальных компонентов
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FormNonVisualComponents : Form
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Конструктор
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FormNonVisualComponents()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создать документ с текстом
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void buttonCreateTextDocument_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-09-06 09:50:22 +04:00
|
|
|
|
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\BigTextDocumentExcel.xlsx";
|
2024-09-06 04:27:34 +04:00
|
|
|
|
string title = "Документ с большим текстом";
|
|
|
|
|
|
|
|
|
|
string[] rows =
|
|
|
|
|
{
|
|
|
|
|
"Съешь еще",
|
|
|
|
|
"этих мягких",
|
|
|
|
|
"французских булок",
|
|
|
|
|
"да выпей чаю"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bigTextComponent1.CreateDocument(filepath, title, rows);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создать документ с таблицей
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void buttonCreateTableDocument_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-09-06 09:50:22 +04:00
|
|
|
|
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\TableDocumentExcel.xlsx";
|
2024-09-06 04:27:34 +04:00
|
|
|
|
string title = "Документ с таблицей";
|
|
|
|
|
|
|
|
|
|
List<MergeCells> mergeCells = new List<MergeCells>()
|
|
|
|
|
{
|
|
|
|
|
new MergeCells("Личные данные", new int[] { 2, 3, 4 }),
|
|
|
|
|
new MergeCells("Работа", new int[] { 7, 8 })
|
|
|
|
|
};
|
2024-09-06 11:10:37 +04:00
|
|
|
|
List<ColumnInfo> columns = new List<ColumnInfo>()
|
2024-09-06 04:27:34 +04:00
|
|
|
|
{
|
2024-09-06 11:10:37 +04:00
|
|
|
|
new ColumnInfo("Id", "Идент.", 10),
|
|
|
|
|
new ColumnInfo("Status", "Статус", 10),
|
|
|
|
|
new ColumnInfo("Name", "Имя", 20),
|
|
|
|
|
new ColumnInfo("Surname", "Фамилия", 20),
|
|
|
|
|
new ColumnInfo("Age", "Возраст", 20),
|
|
|
|
|
new ColumnInfo("Kids", "Дети", 20),
|
|
|
|
|
new ColumnInfo("Car", "Машина", 20),
|
|
|
|
|
new ColumnInfo("Department", "Подразделение", 30),
|
|
|
|
|
new ColumnInfo("Post", "Должность", 30),
|
|
|
|
|
new ColumnInfo("Prize", "Премия", 10)
|
2024-09-06 04:27:34 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
List<Employee> data = new List<Employee>()
|
|
|
|
|
{
|
|
|
|
|
new Employee(1, "нет", "Иван", "Иванов", 34, "нет", "есть", "Департамент 1", "Инженер", 2000.1),
|
|
|
|
|
new Employee(2, "нет", "Петр", "Петров", 44, "есть", "есть", "Департамент 1", "Инженер", 2000.1),
|
|
|
|
|
new Employee(3, "да", "Сергей", "Сепгеев", 55, "нет", "есть", "Департамент 1", "Руководитель", 5000.5),
|
|
|
|
|
new Employee(4, "нет", "Ольга", "Иванва", 34, "есть", "нет", "Бухгалтерия", "Бухгалтер", 2000.1),
|
|
|
|
|
new Employee(5, "да", "Татьяна", "Петрова", 44, "нет", "нет", "Бухгалтерия", "Старший бухгалтер", 7000.6)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tableComponent1.CreateDocument(filepath, title,
|
2024-09-06 11:10:37 +04:00
|
|
|
|
mergeCells, columns,
|
2024-09-06 04:27:34 +04:00
|
|
|
|
data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создать документ с диаграммой
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void buttonCreateDiagramDocument_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LineChartConfig config = new LineChartConfig();
|
2024-09-06 09:50:22 +04:00
|
|
|
|
config.Filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\DiagramDocumentExcel.xlsx";
|
2024-09-06 04:27:34 +04:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|