А еще лучше так

This commit is contained in:
dasha 2023-03-23 16:41:06 +04:00
parent 96f5a5ac76
commit 32635a6eba
3 changed files with 9 additions and 9 deletions

View File

@ -55,7 +55,7 @@ namespace SushiBarBusinessLogic.OfficePackage
List<WordRow> rows = new List<WordRow>(); List<WordRow> rows = new List<WordRow>();
rows.Add(new WordRow rows.Add(new WordRow
{ {
Texts = new List<(string, WordTextProperties)> { Rows = new List<(string, WordTextProperties)> {
("Название", new WordTextProperties { Size = "24", Bold = true }), ("Название", new WordTextProperties { Size = "24", Bold = true }),
("Адрес", new WordTextProperties { Size = "24", Bold = true }), ("Адрес", new WordTextProperties { Size = "24", Bold = true }),
("Дата открытия", new WordTextProperties { Size = "24", Bold = true }) ("Дата открытия", new WordTextProperties { Size = "24", Bold = true })
@ -66,7 +66,7 @@ namespace SushiBarBusinessLogic.OfficePackage
{ {
rows.Add(new WordRow rows.Add(new WordRow
{ {
Texts = new List<(string, WordTextProperties)> { Rows = new List<(string, WordTextProperties)> {
(shop.ShopName, new WordTextProperties { Size = "24" }), (shop.ShopName, new WordTextProperties { Size = "24" }),
(shop.Address, new WordTextProperties { Size = "24" }), (shop.Address, new WordTextProperties { Size = "24" }),
(shop.DateOpening.ToShortDateString(), new WordTextProperties { Size = "24" }) (shop.DateOpening.ToShortDateString(), new WordTextProperties { Size = "24" })

View File

@ -2,6 +2,6 @@
{ {
public class WordRow public class WordRow
{ {
public List<(string, WordTextProperties)> Texts { get; set; } = new(); public List<(string, WordTextProperties)> Rows { get; set; } = new();
} }
} }

View File

@ -109,7 +109,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto }); tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
table.AppendChild(tableProp); table.AppendChild(tableProp);
TableGrid tableGrid = new TableGrid(); TableGrid tableGrid = new TableGrid();
for (int j = 0; j < data[0].Texts.Count; ++j) for (int j = 0; j < data[0].Rows.Count; ++j)
{ {
tableGrid.AppendChild(new GridColumn() { Width = "3200" }); tableGrid.AppendChild(new GridColumn() { Width = "3200" });
} }
@ -117,21 +117,21 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
for (int i = 0; i < data.Count; ++i) for (int i = 0; i < data.Count; ++i)
{ {
TableRow docRow = new TableRow(); TableRow docRow = new TableRow();
for (int j = 0; j < data[i].Texts.Count; ++j) for (int j = 0; j < data[i].Rows.Count; ++j)
{ {
var docParagraph = new Paragraph(); var docParagraph = new Paragraph();
var docRun = new Run(); var docRun = new Run();
var runProperties = new RunProperties(); var runProperties = new RunProperties();
docParagraph.AppendChild(CreateParagraphProperties(data[i].Texts[j].Item2)); docParagraph.AppendChild(CreateParagraphProperties(data[i].Rows[j].Item2));
runProperties.AppendChild(new RunFonts() { Ascii = "Times New Roman", ComplexScript = "Times New Roman", HighAnsi = "Times New Roman" }); runProperties.AppendChild(new RunFonts() { Ascii = "Times New Roman", ComplexScript = "Times New Roman", HighAnsi = "Times New Roman" });
runProperties.AppendChild(new FontSize { Val = data[i].Texts[j].Item2.Size == null ? data[i].Texts[j].Item2.Size : "24" }); runProperties.AppendChild(new FontSize { Val = data[i].Rows[j].Item2.Size == null ? data[i].Rows[j].Item2.Size : "24" });
if (data[i].Texts[j].Item2.Bold) if (data[i].Rows[j].Item2.Bold)
runProperties.AppendChild(new Bold()); runProperties.AppendChild(new Bold());
docRun.AppendChild(runProperties); docRun.AppendChild(runProperties);
docRun.AppendChild(new Text { Text = data[i].Texts[j].Item1.ToString(), Space = SpaceProcessingModeValues.Preserve }); docRun.AppendChild(new Text { Text = data[i].Rows[j].Item1.ToString(), Space = SpaceProcessingModeValues.Preserve });
docParagraph.AppendChild(docRun); docParagraph.AppendChild(docRun);
TableCell docCell = new TableCell(); TableCell docCell = new TableCell();