PIbd-32_Shabunov_O.A._COP/ShabComponentsLibrary/ShabDocumentContextComponent.cs

59 lines
1.4 KiB
C#
Raw 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 ShabComponentsLibrary.OfficePackage;
using ShabComponentsLibrary.OfficePackage.HelperEnums;
using ShabComponentsLibrary.OfficePackage.HelperModels;
using System.ComponentModel;
namespace ShabComponentsLibrary
{
/// <summary>
/// Невизуальный компонент для создания документа с таблицами
/// </summary>
public partial class ShabDocumentContextComponent : Component
{
public ShabDocumentContextComponent()
{
InitializeComponent();
}
public ShabDocumentContextComponent(IContainer Container)
{
Container.Add(this);
InitializeComponent();
}
public void CreateDocument(string Filename, string Title, List<string[][]> Tables)
{
SaveToPdf Pdf = new SaveToPdf();
Pdf.CreatePdf();
Pdf.CreateParagraph(new PdfParagraph
{
Text = Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (string[][] Table in Tables)
{
if (Table.Length == 0)
{
continue;
}
Pdf.CreateTable(Enumerable.Repeat("3cm", Table[0].Length).ToList());
foreach (string[] Row in Table)
{
Pdf.CreateRow(new PdfRowParameters
{
Texts = Row.ToList(),
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
Pdf.CreateParagraph(new PdfParagraph());
}
Pdf.SavePdf(Filename);
}
}
}