using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Spreadsheet; using KOP_Labs.Classes; using Microsoft.VisualBasic.ApplicationServices; 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 WinForm { public partial class NonVisualForm : Form { public NonVisualForm() { InitializeComponent(); } MyHistogramm histogram; private void buttonWordSave_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { try { string title = "Заголовок"; string[,] row1 = { { "Стр1 Кол1", "Стр1 Кол2" } }; string[,] row2 = { { "Стр2 Кол1", "Стр2 Кол2" } }; string[,] row3 = { { "Стр3 Кол1", "Стр3 Кол3" } }; MyTable table = new MyTable(dialog.FileName, title, new List { row1, row2, row3 }); wordTableComponent1.CreateDoc(table); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } private void buttonSaveHist_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { try { histogram = new(dialog.FileName, "Заголовок", "Гистограмма", EnumLegends.Right, new List { new DataHistogramm("Тихий дон", 170), new DataHistogramm("Мастер и Маргарита", 400), new DataHistogramm("Сборник Пушкина", 240), new DataHistogramm("12 стульев", 200) }); wordHistogramm1.CreateHistogramm(histogram); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } List books; Book book1 = new Book("Pushkin", "fgsddsdf", "fdsds"); Book book2 = new Book("Pushkin", "aa", "fdads"); Book book3 = new Book("Pushkin", "fgdf", "ffsds"); Book book4 = new Book("Lermontov", "ffsssff", "asdss"); Book book5 = new Book("Lermontov", "ffdsff", "asdsss"); Book book6 = new Book("Pushkin", "fgdf", "ffsds"); Dictionary colData; private void buttonHead_Click(object sender, EventArgs e) { books = new() { book1, book2, book3, book4, book5, book6 }; colData = new Dictionary() { { 0, new ColumnParameters("Автор", "Author") }, { 1, new ColumnParameters("Id книги", "Id") }, { 2, new ColumnParameters("Имя", "Name") }, { 3, new ColumnParameters("Аннотация", "Annotation") } }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { try { MyTableWithHead myTable = new(dialog.FileName, "Заголовок", new List { 50, 50 }, new List { 2000, 2000, 1500, 1500 }, books.GroupBy(b => b.Author).SelectMany(a => a).ToList(), colData); wordTableHeaderComponent1.CreateDoc(myTable); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }