private Table CreateTableWithHeading(string heading)
        {
            Section section = _document.LastSection;

            section.AddParagraph().AddLineBreaks(count: 2);
            //
            Paragraph     paragraph = section.AddParagraph();
            FormattedText text      = paragraph.AddFormattedText(heading, "Heading");

            text.Color = Colors.Black;
            paragraph.AddLineBreaks(count: 2);
            //
            Table  table = section.AddTable();
            Column col   = table.AddColumn(); // 1 column

            col.Width = 80;
            col       = table.AddColumn();  // 2 column
            col.Width = 200;
            col       = table.AddColumn();  // 3 column
            col.Width = 100;
            col       = table.AddColumn();  // 4 column
            col.Width = 100;
            //
            return(table);
        }
Beispiel #2
0
        private void Fill()
        {
            Section   section = _document.AddSection();
            Paragraph par     = _document.LastSection.AddParagraph("Цены самых продаваемых товаров", "Header");

            par.Format.Alignment = ParagraphAlignment.Center;
            section.AddParagraph().AddLineBreaks(3);
            //
            Chart chart = new Chart();

            chart.Left = 0;
            //
            chart.Width  = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(12);
            Series series = chart.SeriesCollection.AddSeries();

            series.ChartType = ChartType.Column2D;
            series.Add(furnitures.Select(f => (double)f.Price).ToArray());
            series.HasDataLabel = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(Enumerable.Range(1, furnitures.Count()).Select(n => n.ToString()).ToArray());

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            //
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color = Colors.DarkGray;
            chart.PlotArea.LineFormat.Width = 1;

            _document.LastSection.Add(chart);
            par = _document.LastSection.AddParagraph();
            par.AddLineBreaks(2);
            par.AddTextLine("Легенда:");
            int i = 1;

            foreach (var f in furnitures)
            {
                par.AddTextLine(i.ToString() + " = " + "[" + f.VendorCode + "] " + f.Name);
                i++;
            }
        }
        private void Fill()
        {
            Section section = _document.AddSection();
            Image   img     = section.AddImage(_path + "/img/logo/logo.png");

            img.Height = "4cm";

            Paragraph paragraph = section.AddParagraph();

            paragraph.AddLineBreaks(count: 2);

            Table table = CreateTableWithHeading("Приобретенные товары:");
            Row   row   = table.AddRow();

            row.Height         = 25;
            row.Borders.Bottom = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            row.Cells[0].AddParagraph("Артикул:");
            row.Cells[1].AddParagraph("Название:");
            row.Cells[2].AddParagraph("Количество:");
            row.Cells[3].AddParagraph("Цена:");

            foreach (var od in _orderHeader.OrderDetails)
            {
                row        = table.AddRow();
                row.Height = 20;
                row.Cells[0].AddParagraph(od.VendorCode);
                row.Cells[1].AddParagraph(od.Furniture.Name);
                row.Cells[2].AddParagraph($"{od.Quantity} шт.");
                row.Cells[3].AddParagraph($"{(int)od.Furniture.Price} грн");
            }
            row             = table.AddRow();
            row.Borders.Top = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            //
            row = table.AddRow();
            row.Borders.Bottom = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            paragraph = row.Cells[3].AddParagraph();
            FormattedText text = paragraph.AddFormattedText("Итог:", TextFormat.Bold);

            text.Color = Colors.Black;
            row.Height = 25;
            //
            row = table.AddRow();
            row.Cells[3].AddParagraph($"{_orderHeader.GetSum()} грн");

            paragraph = section.AddParagraph();
            paragraph.AddLineBreaks(count: 4);
            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.FromCmyk(100, 30, 20, 50);
            paragraph.AddTextLines(
                $"Дата: {DateTime.Now.ToString("d")}",
                $"Покупатель: {_orderHeader.AppUser.Name}");
            paragraph.Format.Alignment = ParagraphAlignment.Right;

            paragraph = section.AddParagraph();
            paragraph.AddLineBreaks(count: 2);
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.AddTextLines("Будем рады Вас видеть, FurnitureShop!");
        }