Compare commits
2 Commits
a90c2b2cde
...
6c1b361fef
Author | SHA1 | Date | |
---|---|---|---|
6c1b361fef | |||
a69a7fa17d |
@ -1,3 +1,4 @@
|
|||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
using ShabComponentsLibrary;
|
using ShabComponentsLibrary;
|
||||||
using ShabComponentsLibrary.Exceptions;
|
using ShabComponentsLibrary.Exceptions;
|
||||||
|
|
||||||
@ -132,12 +133,15 @@ namespace FormsTesting
|
|||||||
};
|
};
|
||||||
|
|
||||||
ConfigurableTableComponent.CreateDocument(
|
ConfigurableTableComponent.CreateDocument(
|
||||||
@"C:\Comps\Doc2.pdf",
|
@"C:\Comps\Doc2.pdf", "Íŕńňđŕčâŕĺěŕ˙ ňŕáëčöŕ",
|
||||||
"Íàñòðàèâàåìàÿ òàáëèöà",
|
new List<(double, string, string)>
|
||||||
new List<string> { "3cm", "2cm", "3cm", "4cm" },
|
{
|
||||||
new List<string> { "1cm", "0.6cm" },
|
(3.0, "Ôŕěčëč˙", "LastName"),
|
||||||
new List<string> { "Ôàìèëèÿ", "Èäåíò.", "Èìÿ", "Âîçðàñò" },
|
(2.0, "Čäĺíň.", "Id"),
|
||||||
new List<string> { "LastName", "Id", "FirstName", "Age" },
|
(3.0, "Čě˙", "FirstName"),
|
||||||
|
(4.0, "Âîçđŕńň", "Age"),
|
||||||
|
},
|
||||||
|
new List<double> { 1.0, 0.6 },
|
||||||
Persons);
|
Persons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ namespace ShabComponentsLibrary.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public PdfParagraphAlignmentType? FirstCellParagraphAlignment { get; set; }
|
public PdfParagraphAlignmentType? FirstCellParagraphAlignment { get; set; }
|
||||||
|
|
||||||
public string? RowHeight { get; set; }
|
public double? RowHeight { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,15 @@ namespace ShabComponentsLibrary.OfficePackage
|
|||||||
Paragraph.Style = PdfParagraph.Style;
|
Paragraph.Style = PdfParagraph.Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateTable(List<string> Columns)
|
public void CreateTable(List<double> ColumnWidths)
|
||||||
{
|
{
|
||||||
if (_document == null)
|
if (_document == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_table = _document.LastSection.AddTable();
|
_table = _document.LastSection.AddTable();
|
||||||
foreach (var Column in Columns)
|
foreach (var ColumnWidth in ColumnWidths)
|
||||||
{
|
{
|
||||||
_table.AddColumn(Column);
|
_table.AddColumn(Unit.FromCentimeter(ColumnWidth));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ namespace ShabComponentsLibrary.OfficePackage
|
|||||||
|
|
||||||
if (RowParameters.RowHeight is not null)
|
if (RowParameters.RowHeight is not null)
|
||||||
{
|
{
|
||||||
Row.Height = RowParameters.RowHeight;
|
Row.Height = Unit.FromCentimeter((double)RowParameters.RowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit borderWidth = 0.5;
|
Unit borderWidth = 0.5;
|
||||||
@ -126,9 +126,6 @@ namespace ShabComponentsLibrary.OfficePackage
|
|||||||
series.Add(dataSeries.Value.Select(x => (double)x).ToArray());
|
series.Add(dataSeries.Value.Select(x => (double)x).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
//var xseries = chart.XValues.AddXSeries();
|
|
||||||
//xseries.Add(new string[] { "1", "2", "3" });
|
|
||||||
|
|
||||||
chart.TopArea.AddParagraph(ChartParameters.Title);
|
chart.TopArea.AddParagraph(ChartParameters.Title);
|
||||||
|
|
||||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
@ -22,23 +22,20 @@ namespace ShabComponentsLibrary
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateDocument<T>(string Filename, string Title, List<string> ColumnWidths, List<string> RowHeights,
|
public void CreateDocument<T>(string Filename, string Title,
|
||||||
List<string> TableHeaders, List<string> HeaderPropertyNames, List<T> Data)
|
List<(double ColumnWidth, string TableHeader, string HeaderPropertyName)> ColumnData,
|
||||||
|
List<double> RowHeights, List<T> Data)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Filename))
|
if (string.IsNullOrEmpty(Filename))
|
||||||
throw new ArgumentException("Filename cannot be empty");
|
throw new ArgumentException("Filename cannot be empty");
|
||||||
if (string.IsNullOrEmpty(Title))
|
if (string.IsNullOrEmpty(Title))
|
||||||
throw new ArgumentException("Title cannot be empty");
|
throw new ArgumentException("Title cannot be empty");
|
||||||
if (TableHeaders.Count == 0)
|
if (ColumnData.Count == 0)
|
||||||
throw new ArgumentException("Headers cannot be empty");
|
throw new ArgumentException("Headers cannot be empty");
|
||||||
if (Data.Count == 0)
|
if (Data.Count == 0)
|
||||||
throw new ArgumentException("Data cannot be empty");
|
throw new ArgumentException("Data cannot be empty");
|
||||||
if (ColumnWidths.Count != TableHeaders.Count)
|
|
||||||
throw new ArgumentException("Column widths count must match headers count");
|
|
||||||
if (RowHeights.Count != 2)
|
if (RowHeights.Count != 2)
|
||||||
throw new ArgumentException("Row heights should be specified for header row and other rows");
|
throw new ArgumentException("Row heights should be specified for header row and other rows");
|
||||||
if (HeaderPropertyNames.Count != TableHeaders.Count)
|
|
||||||
throw new ArgumentException("Each column must have a corresponding property mapping");
|
|
||||||
|
|
||||||
SaveToPdf Pdf = new SaveToPdf();
|
SaveToPdf Pdf = new SaveToPdf();
|
||||||
Pdf.CreatePdf();
|
Pdf.CreatePdf();
|
||||||
@ -49,12 +46,12 @@ namespace ShabComponentsLibrary
|
|||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
|
|
||||||
Pdf.CreateTable(ColumnWidths);
|
Pdf.CreateTable(ColumnData.Select(x => x.ColumnWidth).ToList());
|
||||||
|
|
||||||
// Шапка
|
// Шапка
|
||||||
Pdf.CreateRow(new PdfRowParameters
|
Pdf.CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = TableHeaders,
|
Texts = ColumnData.Select(x => x.TableHeader).ToList(),
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center,
|
ParagraphAlignment = PdfParagraphAlignmentType.Center,
|
||||||
RowHeight = RowHeights[0]
|
RowHeight = RowHeights[0]
|
||||||
@ -65,9 +62,9 @@ namespace ShabComponentsLibrary
|
|||||||
{
|
{
|
||||||
List<string> Cells = new List<string>();
|
List<string> Cells = new List<string>();
|
||||||
|
|
||||||
for (int ColumnIndex = 0; ColumnIndex < TableHeaders.Count; ++ColumnIndex)
|
for (int ColumnIndex = 0; ColumnIndex < ColumnData.Count; ++ColumnIndex)
|
||||||
{
|
{
|
||||||
string PropertyName = HeaderPropertyNames[ColumnIndex];
|
string PropertyName = ColumnData[ColumnIndex].HeaderPropertyName;
|
||||||
var Property = typeof(T).GetProperty(PropertyName);
|
var Property = typeof(T).GetProperty(PropertyName);
|
||||||
if (Property is null)
|
if (Property is null)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ namespace ShabComponentsLibrary
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pdf.CreateTable(Enumerable.Repeat("3cm", Table[0].Length).ToList());
|
Pdf.CreateTable(Enumerable.Repeat(3.0, Table[0].Length).ToList());
|
||||||
foreach (string[] Row in Table)
|
foreach (string[] Row in Table)
|
||||||
{
|
{
|
||||||
Pdf.CreateRow(new PdfRowParameters
|
Pdf.CreateRow(new PdfRowParameters
|
||||||
|
Loading…
Reference in New Issue
Block a user