124 lines
5.0 KiB
C#
124 lines
5.0 KiB
C#
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)
|
||
{
|
||
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\BigTextDocumentExcel.xlsx";
|
||
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)
|
||
{
|
||
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\TableDocumentExcel.xlsx";
|
||
string title = "Документ с таблицей";
|
||
|
||
List<MergeCells> mergeCells = new List<MergeCells>()
|
||
{
|
||
new MergeCells("Личные данные", new int[] { 2, 3, 4 }),
|
||
new MergeCells("Работа", new int[] { 7, 8 })
|
||
};
|
||
List<ColumnInfo> columns = new List<ColumnInfo>()
|
||
{
|
||
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)
|
||
};
|
||
|
||
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,
|
||
mergeCells, columns,
|
||
data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Создать документ с диаграммой
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void buttonCreateDiagramDocument_Click(object sender, EventArgs e)
|
||
{
|
||
LineChartConfig config = new LineChartConfig();
|
||
config.Filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\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);
|
||
}
|
||
}
|
||
}
|