예제 #1
0
	    public void Format(Body body, Scenario background)
		{
			var headerParagraph   = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" }));
		    var backgroundKeyword = GetLocalizedBackgroundKeyword();
			headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword)));

			var table = new Table();
			table.Append(GenerateTableProperties());
			var row = new TableRow();
			var cell = new TableCell();
			cell.Append(headerParagraph);

		    foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description))
		    {
		        cell.Append(CreateNormalParagraph(descriptionSentence));
		    }

			foreach (var step in background.Steps)
			{
                cell.Append(WordStepFormatter.GenerateStepParagraph(step));

                if (step.TableArgument != null)
                {
                    cell.Append(this.wordTableFormatter.CreateWordTableFromPicklesTable(step.TableArgument));
                }
			}

			cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line?
			row.Append(cell);
			table.Append(row);

			body.Append(table);
		}
예제 #2
0
        public void Format(Body body, Table table)
        {
            var wordTable = new WordTable();
            wordTable.Append(GenerateTableProperties());
            var headerRow = new TableRow();
            foreach (string cell in table.HeaderRow)
            {
                var wordCell = new TableCell();
                wordCell.Append(new Paragraph(new Run(new Text(cell))));
                headerRow.Append(wordCell);
            }
            wordTable.Append(headerRow);

            foreach (Parser.TableRow row in table.DataRows)
            {
                var wordRow = new TableRow();

                foreach (string cell in row)
                {
                    var wordCell = new TableCell();
                    wordCell.Append(new Paragraph(new Run(new Text(cell))));
                    wordRow.Append(wordCell);
                }

                wordTable.Append(wordRow);
            }

            body.Append(wordTable);
        }
예제 #3
0
        public DocumentFormat.OpenXml.Wordprocessing.Table CreateWordTableFromPicklesTable(Table table)
        {
            var wordTable = new DocumentFormat.OpenXml.Wordprocessing.Table();
            wordTable.Append(GenerateTableProperties());
            var headerRow = new TableRow();
            foreach (string cell in table.HeaderRow.Cells)
            {
                var wordCell = new TableCell();
                wordCell.Append(new Paragraph(new Run(new Text(cell))));
                headerRow.Append(wordCell);
            }

            wordTable.Append(headerRow);

            foreach (ObjectModel.TableRow row in table.DataRows)
            {
                var wordRow = new TableRow();

                foreach (string cell in row.Cells)
                {
                    var wordCell = new TableCell();
                    wordCell.Append(new Paragraph(new Run(new Text(cell))));
                    wordRow.Append(wordCell);
                }

                wordTable.Append(wordRow);
            }

            return wordTable;
        }
예제 #4
0
        public void Format(Body body, Table table)
        {
            var wordTable = new DocumentFormat.OpenXml.Wordprocessing.Table();
            wordTable.Append(GenerateTableProperties());
            var headerRow = new TableRow();
            foreach (string cell in table.HeaderRow)
            {
                var wordCell = new TableCell();
                wordCell.Append(new Paragraph(new Run(new Text(cell))));
                headerRow.Append(wordCell);
            }
            wordTable.Append(headerRow);

            foreach (ObjectModel.TableRow row in table.DataRows)
            {
                var wordRow = new TableRow();

                foreach (string cell in row)
                {
                    var wordCell = new TableCell();
                    wordCell.Append(new Paragraph(new Run(new Text(cell))));
                    wordRow.Append(wordCell);
                }

                wordTable.Append(wordRow);
            }

            body.Append(wordTable);
        }
예제 #5
0
		// Creates an TableCell instance and adds its children.
		public static void AddSpacerCell(this TableRow row, string width = "173")
		{
			TableCell tableCell1 = new TableCell();

			TableCellProperties tableCellProperties1 = new TableCellProperties();
			TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = width, Type = TableWidthUnitValues.Dxa };

			tableCellProperties1.Append(tableCellWidth1);

			Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "005A43FA", RsidParagraphProperties = "005A43FA", RsidRunAdditionDefault = "005A43FA" };

			ParagraphProperties paragraphProperties1 = new ParagraphProperties();
			Indentation indentation1 = new Indentation() { Left = "95", Right = "95" };

			paragraphProperties1.Append(indentation1);

			paragraph1.Append(paragraphProperties1);

			tableCell1.Append(tableCellProperties1);
			tableCell1.Append(paragraph1);
			row.Append(tableCell1);
		}
        public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
        {
            TableCell result = new TableCell();
            var cellProperties = new TableCellProperties();

            if (!Width.IsEmpty)
            {
                var cellWidth = UnitHelper.Convert(Width).To<TableCellWidth>();
                cellProperties.Append(cellWidth);
            }

            if (Colspan.HasValue)
            {
                var gridSpan = new GridSpan() { Val = Colspan };
                cellProperties.Append(gridSpan);
            }

            result.Append(cellProperties);

            var paraContent = new Paragraph();
            ForEachChild(x =>
            {
                if (x is TextFormattedElement)
                {
                    paraContent.Append(
                        new Run(x.ToOpenXmlElements(mainDocumentPart))
                    );

                }
                else
                {
                    paraContent.Append(x.ToOpenXmlElements(mainDocumentPart));
                }
            });
            result.Append(paraContent);
            return new List<OpenXmlElement> { result };
        }
예제 #7
0
        public static TableCell AddCell(OXMLParagraphWrap _paragraph)
        {
            var TC = new TableCell();

            var TCProperties = new TableCellProperties();
                var TCWidth = new TableCellWidth(){ Width = "0", Type = TableWidthUnitValues.Nil };  //говорим что ширину определяет Столбец
                var TCVertAlign = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };
            TCProperties.Append(TCWidth);
            TCProperties.Append(TCVertAlign);

            TC.Append(TCProperties);
            TC.Append(_paragraph.XMLParagraph);

            return TC;
        }
예제 #8
0
        private static void AddHeaderRow(DataTable table, Table wordTable, TableStyle tableStyle)
        {
            // Create a row.
            TableRow tRow = new TableRow();

            foreach (DataColumn iColumn in table.Columns) {

                // Create a cell.
                TableCell tCell = new TableCell();

                TableCellProperties tCellProperties = new TableCellProperties();

                // Set Cell Color
                Shading tCellColor = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = System.Drawing.ColorTranslator.ToHtml(tableStyle.HeaderBackgroundColor) };
                tCellProperties.Append(tCellColor);

                // Append properties to the cell
                tCell.Append(tCellProperties);

                ParagraphProperties paragProperties = new ParagraphProperties();
                Justification justification1 = new Justification() { Val = JustificationValues.Center };
                SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" };
                paragProperties.Append(spacingBetweenLines1);
                paragProperties.Append(justification1);

                var parag = new Paragraph();
                parag.Append(paragProperties);

                var run = new Run(new Text(iColumn.ColumnName));
                ApplyFontProperties(tableStyle, RowIdentification.Header, run);
                parag.Append(run);

                // Specify the table cell content.
                tCell.Append(parag);

                // Append the table cell to the table row.
                tRow.Append(tCell);
            }

            // Append the table row to the table.
            wordTable.Append(tRow);
        }
예제 #9
0
        public static void CreateWordFile(string FileName)
        {
            using (WordprocessingDocument doc = WordprocessingDocument.Create(FileName, WordprocessingDocumentType.Document))
            {
                //文档主对象
                MainDocumentPart mdp = doc.AddMainDocumentPart();
                mdp.Document = new Document();
                Body body = mdp.Document.AppendChild(new Body());
                //获取表数据
                DataTable TabDT = DBStructure.GetTables();
                if (TabDT != null && TabDT.Rows.Count > 0)
                {
                    Console.WriteLine("共计: " + TabDT.Rows.Count.ToString() + " 个表");
                    Console.WriteLine("序号\t表名\t\t\t\t表描述");
                    int j = 0;
                    foreach (DataRow dr in TabDT.Rows)
                    {
                        j++;
                        //逐个创建表
                        string    TabName        = dr["name"].ToString().Trim();
                        string    TabDescription = (dr["desctxt"] == DBNull.Value ? "" : dr["desctxt"].ToString().Trim());
                        DataTable ColsDT         = DBStructure.GetTableInfo(TabName);

                        if (ColsDT != null && ColsDT.Rows.Count > 0)
                        {
                            #region 插入空段落
                            Paragraph p = mdp.Document.Body.AppendChild(new Paragraph()
                            {
                                RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                            });
                            p.AppendChild(new Run(new Text("")));
                            #endregion

                            #region 添加表和表头
                            Table table1 = new Table();

                            TableProperties tableProperties = new TableProperties();
                            TableWidth      tableWidth      = new TableWidth()
                            {
                                Width = "0", Type = TableWidthUnitValues.Auto
                            };

                            TableBorders tableBorders = new TableBorders();
                            TopBorder    topBorder    = new TopBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            LeftBorder leftBorder = new LeftBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            BottomBorder bottomBorder = new BottomBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            RightBorder rightBorder = new RightBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };

                            tableBorders.Append(topBorder);
                            tableBorders.Append(leftBorder);
                            tableBorders.Append(bottomBorder);
                            tableBorders.Append(rightBorder);

                            TableLayout tableLayout = new TableLayout()
                            {
                                Type = TableLayoutValues.Fixed
                            };
                            TableLook tableLook = new TableLook()
                            {
                                Val = "0000"
                            };

                            tableProperties.Append(tableWidth);
                            tableProperties.Append(tableBorders);
                            tableProperties.Append(tableLayout);
                            tableProperties.Append(tableLook);

                            TableGrid tableGrid = new TableGrid();
                            int[]     ColWidths = new[] { 1800, 1000, 700, 700, 700, 700, 3100 };
                            for (int i = 0; i < 7; i++)
                            {
                                GridColumn gCol = new GridColumn()
                                {
                                    Width = ColWidths[i].ToString()
                                };
                                tableGrid.Append(gCol);
                            }

                            TableRow nameRow = new TableRow()
                            {
                                RsidTableRowAddition = "007557D9", RsidTableRowProperties = "00096DED"
                            };

                            TablePropertyExceptions tablePropertyExceptions_name = new TablePropertyExceptions();
                            TableCellMarginDefault  tableCellMarginDefault_name  = new TableCellMarginDefault();
                            TopMargin topMargin_name = new TopMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            BottomMargin bottomMargin_name = new BottomMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };

                            tableCellMarginDefault_name.Append(topMargin_name);
                            tableCellMarginDefault_name.Append(bottomMargin_name);

                            tablePropertyExceptions_name.Append(tableCellMarginDefault_name);

                            TableRowProperties tableRowProperties_name = new TableRowProperties();
                            CantSplit          cantSplit_name          = new CantSplit();
                            TableHeader        tableHeader_name        = new TableHeader();

                            tableRowProperties_name.Append(cantSplit_name);
                            tableRowProperties_name.Append(tableHeader_name);

                            TableCell tableCell_name = new TableCell();

                            TableCellProperties tableCellProperties_name = new TableCellProperties();
                            TableCellWidth      tableCellWidth_name      = new TableCellWidth()
                            {
                                Width = "8500", Type = TableWidthUnitValues.Dxa
                            };
                            GridSpan gridSpan_name = new GridSpan()
                            {
                                Val = 7
                            };

                            TableCellBorders tableCellBorders_name = new TableCellBorders();
                            TopBorder        topBorder_name        = new TopBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            BottomBorder bottomBorder_name = new BottomBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            RightBorder rightBorder_name = new RightBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            LeftBorder leftBorder_name = new LeftBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };

                            tableCellBorders_name.Append(topBorder_name);
                            tableCellBorders_name.Append(rightBorder_name);
                            tableCellBorders_name.Append(bottomBorder_name);
                            tableCellBorders_name.Append(leftBorder_name);
                            Shading shading_name = new Shading()
                            {
                                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                            };
                            TableCellVerticalAlignment tableCellVerticalAlignment_name = new TableCellVerticalAlignment()
                            {
                                Val = TableVerticalAlignmentValues.Center
                            };

                            tableCellProperties_name.Append(tableCellWidth_name);
                            tableCellProperties_name.Append(gridSpan_name);
                            tableCellProperties_name.Append(tableCellBorders_name);
                            tableCellProperties_name.Append(shading_name);
                            tableCellProperties_name.Append(tableCellVerticalAlignment_name);

                            Paragraph paragraph_name = new Paragraph()
                            {
                                RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                            };

                            Run run_name = new Run();

                            RunProperties runProperties_name = new RunProperties();
                            RunFonts      runFonts_name      = new RunFonts()
                            {
                                Hint = FontTypeHintValues.EastAsia
                            };

                            runProperties_name.Append(runFonts_name);
                            Text text_name = new Text();
                            text_name.Text = TabName + ":" + TabDescription;

                            run_name.Append(runProperties_name);
                            run_name.Append(text_name);

                            paragraph_name.Append(run_name);

                            tableCell_name.Append(tableCellProperties_name);
                            tableCell_name.Append(paragraph_name);

                            nameRow.Append(tablePropertyExceptions_name);
                            nameRow.Append(tableRowProperties_name);
                            nameRow.Append(tableCell_name);
                            table1.AppendChild(nameRow);
                            #endregion

                            //表头定义
                            TableRow headerRow = new TableRow()
                            {
                                RsidTableRowAddition = "007557D9", RsidTableRowProperties = "007557D9"
                            };
                            TablePropertyExceptions tablePropertyExceptions_header = new TablePropertyExceptions();
                            TableCellMarginDefault  tableCellMarginDefault_header  = new TableCellMarginDefault();
                            TopMargin topMargin_header = new TopMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            BottomMargin bottomMargin_header = new BottomMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            tableCellMarginDefault_header.Append(topMargin_header);
                            tableCellMarginDefault_header.Append(bottomMargin_header);
                            tablePropertyExceptions_header.Append(tableCellMarginDefault_header);
                            TableRowProperties tableRowProperties_header = new TableRowProperties();
                            CantSplit          cantSplit_header          = new CantSplit();
                            tableRowProperties_header.Append(cantSplit_header);

                            string[] HeaderArray = new string[] { "列名", "类型", "长度", "可空", "自增", "主键", "描述" };
                            int      HeadIndex   = 0;
                            foreach (string headstr in HeaderArray)
                            {
                                TableCell titleCell = new TableCell();

                                TableCellProperties tableCellProperties_header = new TableCellProperties();
                                TableCellWidth      tableCellWidth_header      = new TableCellWidth()
                                {
                                    Width = ColWidths[HeadIndex].ToString(), Type = TableWidthUnitValues.Dxa
                                };

                                TableCellBorders tableCellBorders_header = new TableCellBorders();
                                TopBorder        topBorder_header        = new TopBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                BottomBorder bottomBorder_header = new BottomBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                RightBorder rightBorder_header = new RightBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                LeftBorder leftBorder_header = new LeftBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };

                                tableCellBorders_header.Append(topBorder_header);
                                tableCellBorders_header.Append(bottomBorder_header);
                                tableCellBorders_header.Append(rightBorder_header);
                                tableCellBorders_header.Append(leftBorder_header);
                                Shading shading_header = new Shading()
                                {
                                    Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                                };

                                tableCellProperties_header.Append(tableCellWidth_header);
                                tableCellProperties_header.Append(tableCellBorders_header);
                                tableCellProperties_header.Append(shading_header);

                                Paragraph paragraph_header = new Paragraph()
                                {
                                    RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                                };

                                Run run_header = new Run();

                                RunProperties runProperties_header = new RunProperties();
                                RunFonts      runFonts_header      = new RunFonts()
                                {
                                    Hint = FontTypeHintValues.EastAsia
                                };

                                runProperties_header.Append(runFonts_header);
                                Text text_header = new Text();
                                text_header.Text = headstr;

                                run_header.Append(runProperties_header);
                                run_header.Append(text_header);

                                paragraph_header.Append(run_header);

                                titleCell.Append(tableCellProperties_header);
                                titleCell.Append(paragraph_header);


                                headerRow.Append(titleCell);
                                HeadIndex++;
                            }
                            headerRow.Append(tablePropertyExceptions_header);
                            headerRow.Append(tableRowProperties_header);
                            table1.AppendChild(headerRow);

                            foreach (DataRow subdr in ColsDT.Rows)
                            {
                                TableRow dataRow = new TableRow();
                                TablePropertyExceptions tablePropertyExceptions_data = new TablePropertyExceptions();
                                TableCellMarginDefault  tableCellMarginDefault_data  = new TableCellMarginDefault();
                                TopMargin topMargin_data = new TopMargin()
                                {
                                    Width = "0", Type = TableWidthUnitValues.Dxa
                                };
                                BottomMargin bottomMargin_data = new BottomMargin()
                                {
                                    Width = "0", Type = TableWidthUnitValues.Dxa
                                };
                                tableCellMarginDefault_data.Append(topMargin_data);
                                tableCellMarginDefault_data.Append(bottomMargin_data);
                                tablePropertyExceptions_data.Append(tableCellMarginDefault_data);
                                TableRowProperties tableRowProperties_data = new TableRowProperties();
                                CantSplit          cantSplit_data          = new CantSplit();
                                tableRowProperties_data.Append(cantSplit_data);

                                int DataIndex = 0;
                                foreach (string header in HeaderArray)
                                {
                                    TableCell dataCell = new TableCell();

                                    TableCellProperties tableCellProperties_data = new TableCellProperties();
                                    TableCellWidth      tableCellWidth_data      = new TableCellWidth()
                                    {
                                        Width = ColWidths[DataIndex].ToString(), Type = TableWidthUnitValues.Dxa
                                    };

                                    TableCellBorders tableCellBorders_data = new TableCellBorders();
                                    TopBorder        topBorder_data        = new TopBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    BottomBorder bottomBorder_data = new BottomBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    RightBorder rightBorder_data = new RightBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    LeftBorder leftBorder_data = new LeftBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };

                                    tableCellBorders_data.Append(topBorder_data);
                                    tableCellBorders_data.Append(bottomBorder_data);
                                    tableCellBorders_data.Append(rightBorder_data);
                                    tableCellBorders_data.Append(leftBorder_data);
                                    Shading shading_data = new Shading()
                                    {
                                        Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                                    };

                                    tableCellProperties_data.Append(tableCellWidth_data);
                                    tableCellProperties_data.Append(tableCellBorders_data);
                                    tableCellProperties_data.Append(shading_data);

                                    Paragraph paragraph_data = new Paragraph()
                                    {
                                        RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                                    };

                                    Run run_data = new Run();

                                    RunProperties runProperties_data = new RunProperties();
                                    RunFonts      runFonts_data      = new RunFonts()
                                    {
                                        Hint = FontTypeHintValues.EastAsia
                                    };

                                    runProperties_data.Append(runFonts_data);
                                    Text text_data = new Text();
                                    text_data.Text = subdr[header].ToString();

                                    run_data.Append(runProperties_data);
                                    run_data.Append(text_data);

                                    paragraph_data.Append(run_data);

                                    dataCell.Append(tableCellProperties_data);
                                    dataCell.Append(paragraph_data);

                                    dataRow.Append(dataCell);
                                    DataIndex++;
                                }
                                dataRow.Append(tablePropertyExceptions_data);
                                dataRow.Append(tableRowProperties_data);

                                table1.AppendChild(dataRow);
                            }
                            Console.WriteLine(string.Format("{0}\t{1}\t\t\t\t{2}", j, TabName, TabDescription));
                            body.Append(table1);
                            Paragraph p1 = new Paragraph(new Run(new Text("")));
                            body.Append(p1);
                        }
                    }
                }
            }
        }
        private static void AddImageToCell(TableCell cell, string relationshipId)
        {
            var element =
                new Drawing(
                    new DW.Inline(
                        new DW.Extent()
            {
                Cx = 990000L, Cy = 792000L
            },
                        new DW.EffectExtent()
            {
                LeftEdge   = 0L,
                TopEdge    = 0L,
                RightEdge  = 0L,
                BottomEdge = 0L
            },
                        new DW.DocProperties()
            {
                Id   = (UInt32Value)1U,
                Name = "Picture 1"
            },
                        new DW.NonVisualGraphicFrameDrawingProperties(
                            new A.GraphicFrameLocks()
            {
                NoChangeAspect = true
            }),
                        new A.Graphic(
                            new A.GraphicData(
                                new PIC.Picture(
                                    new PIC.NonVisualPictureProperties(
                                        new PIC.NonVisualDrawingProperties()
            {
                Id   = (UInt32Value)0U,
                Name = "New Bitmap Image.jpg"
            },
                                        new PIC.NonVisualPictureDrawingProperties()),
                                    new PIC.BlipFill(
                                        new A.Blip(
                                            new A.BlipExtensionList(
                                                new A.BlipExtension()
            {
                Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}"
            })
                                            )
            {
                Embed            = relationshipId,
                CompressionState =
                    A.BlipCompressionValues.Print
            },
                                        new A.Stretch(
                                            new A.FillRectangle())),
                                    new PIC.ShapeProperties(
                                        new A.Transform2D(
                                            new A.Offset()
            {
                X = 0L, Y = 0L
            },
                                            new A.Extents()
            {
                Cx = 990000L, Cy = 792000L
            }),
                                        new A.PresetGeometry(
                                            new A.AdjustValueList()
                                            )
            {
                Preset = A.ShapeTypeValues.Rectangle
            }))
                                )
            {
                Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture"
            })
                        )
            {
                DistanceFromTop    = (UInt32Value)0U,
                DistanceFromBottom = (UInt32Value)0U,
                DistanceFromLeft   = (UInt32Value)0U,
                DistanceFromRight  = (UInt32Value)0U
            });

            cell.Append(new Paragraph(new Run(element)));
        }
        // Creates an Table instance and adds its children.
        public static Table GenerateTable(GenerationData data)
        {
            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableWidth      tableWidth1      = new TableWidth()
            {
                Width = "0", Type = TableWidthUnitValues.Auto
            };
            TableIndentation tableIndentation1 = new TableIndentation()
            {
                Width = 10, Type = TableWidthUnitValues.Dxa
            };

            TableBorders tableBorders1 = new TableBorders();
            TopBorder    topBorder1    = new TopBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder1 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder1 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder1 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };

            tableBorders1.Append(topBorder1);
            tableBorders1.Append(leftBorder1);
            tableBorders1.Append(bottomBorder1);
            tableBorders1.Append(rightBorder1);
            tableBorders1.Append(insideHorizontalBorder1);
            tableBorders1.Append(insideVerticalBorder1);

            TableCellMarginDefault tableCellMarginDefault1 = new TableCellMarginDefault();
            TableCellLeftMargin    tableCellLeftMargin1    = new TableCellLeftMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };
            TableCellRightMargin tableCellRightMargin1 = new TableCellRightMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };

            tableCellMarginDefault1.Append(tableCellLeftMargin1);
            tableCellMarginDefault1.Append(tableCellRightMargin1);
            TableLook tableLook1 = new TableLook()
            {
                Val = "0000", FirstRow = false, LastRow = false, FirstColumn = false, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = false
            };

            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableIndentation1);
            tableProperties1.Append(tableBorders1);
            tableProperties1.Append(tableCellMarginDefault1);
            tableProperties1.Append(tableLook1);

            TableGrid  tableGrid1  = new TableGrid();
            GridColumn gridColumn1 = new GridColumn()
            {
                Width = "2550"
            };
            GridColumn gridColumn2 = new GridColumn()
            {
                Width = "5700"
            };
            GridColumn gridColumn3 = new GridColumn()
            {
                Width = "360"
            };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);

            TableRow tableRow1 = new TableRow()
            {
                RsidTableRowAddition = "009B2C1D", ParagraphId = "5B63C23B", TextId = "77777777"
            };

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth      tableCellWidth1      = new TableCellWidth()
            {
                Width = "800", Type = TableWidthUnitValues.Dxa
            };
            GridSpan gridSpan1 = new GridSpan()
            {
                Val = 3
            };

            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder        topBorder2        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder2 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder2 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder2 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders1.Append(topBorder2);
            tableCellBorders1.Append(leftBorder2);
            tableCellBorders1.Append(bottomBorder2);
            tableCellBorders1.Append(rightBorder2);

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(gridSpan1);
            tableCellProperties1.Append(tableCellBorders1);

            Paragraph paragraph1 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "459760A7", TextId = "77777777"
            };

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            Bold          bold1          = new Bold();
            FontSize      fontSize1      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties1.Append(bold1);
            runProperties1.Append(fontSize1);
            runProperties1.Append(fontSizeComplexScript1);
            Text text1 = new Text();

            text1.Text = "ADDITIONAL COURSES";

            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            FontSize      fontSize2      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties2.Append(fontSize2);
            runProperties2.Append(fontSizeComplexScript2);
            Text text2 = new Text()
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            text2.Text = "  ";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph1.Append(run1);
            paragraph1.Append(run2);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            tableRow1.Append(tableCell1);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(tableRow1);

            foreach (var course in data.AdditionalCourses)
            {
                TableRow generateRow = CreateAdditionalCourseRow(course);
                table1.Append(generateRow);
            }

            return(table1);
        }
예제 #12
0
        private TableCell CreateLastNoBorderCell()
        {
            TableCellProperties tableCellProperties = new TableCellProperties();

            TableCellWidth tableCellWidth = new TableCellWidth() { Type = TableWidthUnitValues.Auto };
            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Nil };
            LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Nil };
            BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Nil };
            RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Nil };

            tableCellBorders1.Append(topBorder1);
            tableCellBorders1.Append(leftBorder1);
            tableCellBorders1.Append(bottomBorder1);
            tableCellBorders1.Append(rightBorder1);

            tableCellProperties.Append(tableCellWidth);
            tableCellProperties.Append(tableCellBorders1);

            TableCell tableCell = new TableCell();
            tableCell.Append(tableCellProperties);
            tableCell.Append(CreateEmptyParagraph());
            return tableCell;
        }
        private Table GenerateBasiceReportDataTable()
        {
            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" };
            TablePositionProperties tablePositionProperties1 = new TablePositionProperties() { LeftFromText = 180, RightFromText = 180, VerticalAnchor = VerticalAnchorValues.Text, HorizontalAnchor = HorizontalAnchorValues.Margin, TablePositionXAlignment = HorizontalAlignmentValues.Center, TablePositionY = 103 };
            TableWidth tableWidth1 = new TableWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa };
            TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true };

            tableProperties1.Append(tableStyle1);
            tableProperties1.Append(tablePositionProperties1);
            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableLook1);

            TableGrid tableGrid1 = new TableGrid();
            GridColumn gridColumn1 = new GridColumn() { Width = "15026" };

            tableGrid1.Append(gridColumn1);

            TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "004E307B", RsidTableRowProperties = "00D273DB" };

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa };

            tableCellProperties1.Append(tableCellWidth1);

            Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "004E307B", RsidParagraphAddition = "004E307B", RsidParagraphProperties = "004E307B", RsidRunAdditionDefault = "004E307B" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            Justification justification1 = new Justification() { Val = JustificationValues.Center };

            paragraphProperties1.Append(justification1);

            paragraph1.Append(paragraphProperties1);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            tableRow1.Append(tableCell1);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(tableRow1);
            return table1;
        }
예제 #14
0
        private void GenerateChapterSix23()
        {
            var paraProp = new ParagraphProperties();
            var paragraph = new Paragraph();
            var runProp = new RunProperties();
            var run = new Run();

            #region chapterSix23
            var chapterSix23 = _sessionObjects.ChapterSixPartTwoThree;
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text(chapterSix23.SubHeader1));
            paraProp = GetParagraphProperties("StyleWithoutIndentation");
            GenerateParagraph(run, paraProp);

            #region table
            var table = new Table();
            table.Append(GenerateTableProperties());
            var tableGrid1 = new TableGrid();
            tableGrid1.Append(new GridColumn { Width = "1843" });
            tableGrid1.Append(new GridColumn { Width = "6716" });
            table.Append(tableGrid1);

            #region header
            #region row
            var tableRow = new TableRow();

            #region cell
            var tableCell = new TableCell();
            TableCellProperties tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            var justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text("№ Занятия"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text("Тема смостоятельного занятия"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion
            #endregion

            #region data
            for (var i = 0; i < chapterSix23.IndependentWork.Rows.Count; i++)
            {
                #region row
                tableRow = new TableRow();

                #region cell
                tableCell = new TableCell();
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                run.Append(new Text((i + 1).ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                #region cell
                tableCell = new TableCell();
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                run.Append(new Text(chapterSix23.IndependentWork.Rows[i].ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                table.Append(tableRow);
                #endregion
            }
            #endregion
            #endregion

            GenerateParagraph();

            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text(chapterSix23.SubHeader2));
            paraProp = GetParagraphProperties("StyleWithoutIndentation");
            GenerateParagraph(run, paraProp);

            foreach (var home in chapterSix23.HomeWork)
            {
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold()
                };
                run.Append(runProp);
                run.Append(new Text(home.Rows[0]["Header"].ToString()));
                paraProp = GetParagraphProperties("StyleWithoutIndentation");
                GenerateParagraph(run, paraProp);

                for (var i = 0; i < home.Rows.Count; i++)
                {
                    paraProp = GetParagraphProperties();

                    run = new Run();
                    var str = String.Format("{0}. {1}", i + 1, home.Rows[i]["Text"]);
                    run.Append(new Text(str));

                    paragraph = new Paragraph();
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    _body.Append(paragraph);
                }
            }
            #endregion
        }
예제 #15
0
        /// <summary>
        /// Gets a category header row.
        /// </summary>
        /// <remarks>
        /// This method is used in Document assembly to create the first row for a category on the job description page
        /// </remarks>
        /// <returns>An assembled <see cref="T:DocumentFormat.OpenXml.Wordprocessing.TableRow"/></returns>
        public TableRow GetCategoryHeaderRow()
        {
            TableRow tableRow1 = new TableRow();

            TableRowProperties tableRowProperties1 = new TableRowProperties();
            TableRowHeight     tableRowHeight1     = new TableRowHeight()
            {
                Val = (UInt32Value)360U
            };
            TableJustification tableJustification1 = new TableJustification()
            {
                Val = TableRowAlignmentValues.Center
            };

            tableRowProperties1.Append(tableRowHeight1);
            tableRowProperties1.Append(tableJustification1);

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth      tableCellWidth1      = new TableCellWidth()
            {
                Width = "535", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders1 = new TableCellBorders();
            BottomBorder     bottomBorder1     = new BottomBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders1.Append(bottomBorder1);
            Shading shading1 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(tableCellBorders1);
            tableCellProperties1.Append(shading1);

            Paragraph paragraph1 = new Paragraph();

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            KeepNext            keepNext1            = new KeepNext();
            Justification       justification1       = new Justification()
            {
                Val = JustificationValues.Center
            };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            Bold     bold1     = new Bold();
            FontSize fontSize1 = new FontSize()
            {
                Val = "20"
            };

            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSize1);

            paragraphProperties1.Append(keepNext1);
            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            Bold          bold2          = new Bold();
            FontSize      fontSize2      = new FontSize()
            {
                Val = "20"
            };

            runProperties1.Append(bold2);
            runProperties1.Append(fontSize2);
            Text text1 = new Text();

            text1.Text = Weight.ToString();

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth      tableCellWidth2      = new TableCellWidth()
            {
                Width = "545", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders2 = new TableCellBorders();
            BottomBorder     bottomBorder2     = new BottomBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders2.Append(bottomBorder2);
            Shading shading2 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(tableCellBorders2);
            tableCellProperties2.Append(shading2);

            Paragraph paragraph2 = new Paragraph();

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            KeepNext            keepNext2            = new KeepNext();

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            Bold     bold3     = new Bold();
            FontSize fontSize3 = new FontSize()
            {
                Val = "20"
            };

            paragraphMarkRunProperties2.Append(bold3);
            paragraphMarkRunProperties2.Append(fontSize3);

            paragraphProperties2.Append(keepNext2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            Bold          bold4          = new Bold();
            FontSize      fontSize4      = new FontSize()
            {
                Val = "20"
            };

            runProperties2.Append(bold4);
            runProperties2.Append(fontSize4);
            Text text2 = new Text();

            text2.Text = Letter + ":";

            run2.Append(runProperties2);
            run2.Append(text2);
            BookmarkStart bookmarkStart1 = new BookmarkStart()
            {
                Name = "_GoBack", Id = "0"
            };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd()
            {
                Id = "0"
            };

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);
            paragraph2.Append(bookmarkStart1);
            paragraph2.Append(bookmarkEnd1);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph2);

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth      tableCellWidth3      = new TableCellWidth()
            {
                Width = "4902", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders3 = new TableCellBorders();
            RightBorder      rightBorder1      = new RightBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders3.Append(rightBorder1);
            Shading shading3 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(tableCellBorders3);
            tableCellProperties3.Append(shading3);

            Paragraph paragraph3 = new Paragraph();

            ParagraphProperties paragraphProperties3 = new ParagraphProperties();
            KeepNext            keepNext3            = new KeepNext();

            ParagraphMarkRunProperties paragraphMarkRunProperties3 = new ParagraphMarkRunProperties();
            Bold     bold5     = new Bold();
            Caps     caps1     = new Caps();
            FontSize fontSize5 = new FontSize()
            {
                Val = "20"
            };
            Underline underline1 = new Underline()
            {
                Val = UnderlineValues.Single
            };

            paragraphMarkRunProperties3.Append(bold5);
            paragraphMarkRunProperties3.Append(caps1);
            paragraphMarkRunProperties3.Append(fontSize5);
            paragraphMarkRunProperties3.Append(underline1);

            paragraphProperties3.Append(keepNext3);
            paragraphProperties3.Append(paragraphMarkRunProperties3);

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            Bold          bold6          = new Bold();
            Caps          caps2          = new Caps();
            FontSize      fontSize6      = new FontSize()
            {
                Val = "20"
            };
            Underline underline2 = new Underline()
            {
                Val = UnderlineValues.Single
            };

            runProperties3.Append(bold6);
            runProperties3.Append(caps2);
            runProperties3.Append(fontSize6);
            runProperties3.Append(underline2);
            Text text3 = new Text();

            text3.Text = Title;

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run3);

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph3);

            TableCell tableCell4 = new TableCell();

            TableCellProperties tableCellProperties4 = new TableCellProperties();
            TableCellWidth      tableCellWidth4      = new TableCellWidth()
            {
                Width = "403", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders4 = new TableCellBorders();
            LeftBorder       leftBorder1       = new LeftBorder()
            {
                Val = BorderValues.Nil
            };
            RightBorder rightBorder2 = new RightBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders4.Append(leftBorder1);
            tableCellBorders4.Append(rightBorder2);
            Shading shading4 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties4.Append(tableCellWidth4);
            tableCellProperties4.Append(tableCellBorders4);
            tableCellProperties4.Append(shading4);

            Paragraph paragraph4 = new Paragraph();

            ParagraphProperties paragraphProperties4 = new ParagraphProperties();
            KeepLines           keepLines1           = new KeepLines();

            ParagraphMarkRunProperties paragraphMarkRunProperties4 = new ParagraphMarkRunProperties();
            FontSize fontSize7 = new FontSize()
            {
                Val = "16"
            };
            FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript()
            {
                Val = "16"
            };

            paragraphMarkRunProperties4.Append(fontSize7);
            paragraphMarkRunProperties4.Append(fontSizeComplexScript1);

            paragraphProperties4.Append(keepLines1);
            paragraphProperties4.Append(paragraphMarkRunProperties4);

            paragraph4.Append(paragraphProperties4);

            tableCell4.Append(tableCellProperties4);
            tableCell4.Append(paragraph4);

            TableCell tableCell5 = new TableCell();

            TableCellProperties tableCellProperties5 = new TableCellProperties();
            TableCellWidth      tableCellWidth5      = new TableCellWidth()
            {
                Width = "5135", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders5 = new TableCellBorders();
            LeftBorder       leftBorder2       = new LeftBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders5.Append(leftBorder2);
            Shading shading5 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties5.Append(tableCellWidth5);
            tableCellProperties5.Append(tableCellBorders5);
            tableCellProperties5.Append(shading5);

            Paragraph paragraph5 = new Paragraph();

            ParagraphProperties paragraphProperties5 = new ParagraphProperties();
            KeepLines           keepLines2           = new KeepLines();

            ParagraphMarkRunProperties paragraphMarkRunProperties5 = new ParagraphMarkRunProperties();
            FontSize fontSize8 = new FontSize()
            {
                Val = "16"
            };
            FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript()
            {
                Val = "16"
            };

            paragraphMarkRunProperties5.Append(fontSize8);
            paragraphMarkRunProperties5.Append(fontSizeComplexScript2);

            paragraphProperties5.Append(keepLines2);
            paragraphProperties5.Append(paragraphMarkRunProperties5);

            paragraph5.Append(paragraphProperties5);

            tableCell5.Append(tableCellProperties5);
            tableCell5.Append(paragraph5);

            tableRow1.Append(tableRowProperties1);
            tableRow1.Append(tableCell1);
            tableRow1.Append(tableCell2);
            tableRow1.Append(tableCell3);
            tableRow1.Append(tableCell4);
            tableRow1.Append(tableCell5);
            return(tableRow1);
        }
예제 #16
0
        public Table getTableWithSignature()
        {
            Table           signatureTable           = new Table();
            TableProperties signatureTableProperties = new TableProperties(
                new TableBorders(
                    new InsideHorizontalBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Space = 0, Size = 4
            }
                    ),
                new TableJustification()
            {
                Val = TableRowAlignmentValues.Right
            },
                new TableLayout()
            {
                Type = new EnumValue <TableLayoutValues>(TableLayoutValues.Fixed)
            }
                );

            signatureTable.AppendChild <TableProperties>(signatureTableProperties);

            TableRow sigTableRow1 = new TableRow();

            sigTableRow1.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 255
            }));
            TableCell sigTableCell11 = new TableCell();

            sigTableCell11.Append(_tablePropertiesGetter.getTableCellPropCentered("3969"));
            sigTableCell11.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell sigTableCell12 = new TableCell();

            sigTableCell12.AppendChild <TableCellProperties>(new TableCellProperties(new TableCellBorders(new BottomBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Nil)
            })));
            sigTableCell12.Append(_tablePropertiesGetter.getTableCellPropCentered("425"));
            sigTableCell12.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell sigTableCell13 = new TableCell();

            sigTableCell13.Append(_tablePropertiesGetter.getTableCellPropCentered("3260"));
            sigTableCell13.Append(_paragraphGetter.getSmallCenteredText(""));
            sigTableRow1.Append(sigTableCell11, sigTableCell12, sigTableCell13);


            TableRow sigTableRow2 = new TableRow();

            sigTableRow2.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 255
            }));
            TableCell sigTableCell21 = new TableCell();

            sigTableCell21.Append(_tablePropertiesGetter.getTableCellPropCentered("3969"));
            sigTableCell21.Append(_paragraphGetter.getSmallCenteredText(_localizer["podpis dyrektora/kierownika jednostki organizacyjnej promotora"]));
            TableCell sigTableCell22 = new TableCell();

            sigTableCell22.AppendChild <TableCellProperties>(new TableCellProperties(new TableCellBorders(new TopBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Nil)
            })));
            sigTableCell22.Append(_tablePropertiesGetter.getTableCellPropCentered("425"));
            sigTableCell22.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell sigTableCell23 = new TableCell();

            sigTableCell23.Append(_tablePropertiesGetter.getTableCellPropCentered("3260"));
            sigTableCell23.Append(_paragraphGetter.getSmallCenteredText(_localizer["podpis Dziekana"]));
            sigTableRow2.Append(sigTableCell21, sigTableCell22, sigTableCell23);

            signatureTable.Append(sigTableRow1, sigTableRow2);

            return(signatureTable);
        }
예제 #17
0
        public Table getTableWithProposalInformation(ProposalDocRecord record)
        {
            Table diplomaTable = new Table();

            diplomaTable.AppendChild <TableProperties>(_tablePropertiesGetter.getHorizontalBorderTableProperties());

            TableRow dipTableRow1 = new TableRow();

            dipTableRow1.Append(new TableRowProperties(new TableRowHeight()
            {
                HeightType = HeightRuleValues.Exact, Val = 180
            }));
            TableCell dipTableCell11 = new TableCell();

            dipTableCell11.Append(_tablePropertiesGetter.getTableCellPropFilled("1559", "000000"));
            dipTableCell11.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell dipTableCell12 = new TableCell();

            dipTableCell12.Append(_tablePropertiesGetter.getTableCellPropFilled("534", "CCCCCC"));
            dipTableCell12.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell dipTableCell13 = new TableCell();

            dipTableCell13.Append(_tablePropertiesGetter.getTableCellPropFilled("7087", "CCCCCC"));
            dipTableCell13.Append(_paragraphGetter.getSmallCenteredText(""));
            dipTableRow1.Append(dipTableCell11, dipTableCell12, dipTableCell13);


            TableRow dipTableRow2 = new TableRow();

            dipTableRow2.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell21 = new TableCell();

            dipTableCell21.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell21.Append(_paragraphGetter.getNormalRightText(_localizer["Tytuł pracy:"]));
            TableCell dipTableCell22 = new TableCell();

            dipTableCell22.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell22.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell23 = new TableCell();

            dipTableCell23.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell23.Append(_paragraphGetter.getNormalText(record.TopicPolish));
            dipTableRow2.Append(dipTableCell21, dipTableCell22, dipTableCell23);

            TableRow dipTableRow3 = new TableRow();

            dipTableRow3.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell31 = new TableCell();

            dipTableCell31.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell31.Append(_paragraphGetter.getNormalRightText(_localizer["Wersja angielska tytułu:"]));
            TableCell dipTableCell32 = new TableCell();

            dipTableCell32.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell32.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell33 = new TableCell();

            dipTableCell33.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell33.Append(_paragraphGetter.getItalicText(record.TopicEnglish));
            dipTableRow3.Append(dipTableCell31, dipTableCell32, dipTableCell33);

            TableRow dipTableRow4 = new TableRow();

            dipTableRow4.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell41 = new TableCell();

            dipTableCell41.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell41.Append(_paragraphGetter.getNormalRightText(_localizer["Dane wyjściowe:"]));
            TableCell dipTableCell42 = new TableCell();

            dipTableCell42.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell42.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell43 = new TableCell();

            dipTableCell43.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell43.Append(_paragraphGetter.getNormalText(record.OutputData));
            dipTableRow4.Append(dipTableCell41, dipTableCell42, dipTableCell43);

            TableRow dipTableRow5 = new TableRow();

            dipTableRow5.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell51 = new TableCell();

            dipTableCell51.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell51.Append(_paragraphGetter.getNormalRightText(_localizer["Zakres pracy:"]));
            TableCell dipTableCell52 = new TableCell();

            dipTableCell52.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell52.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell53 = new TableCell();

            dipTableCell53.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell53.Append(_paragraphGetter.getNormalText(record.Description));
            dipTableRow5.Append(dipTableCell51, dipTableCell52, dipTableCell53);

            TableRow dipTableRow6 = new TableRow();

            dipTableRow6.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell61 = new TableCell();

            dipTableCell61.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell61.Append(_paragraphGetter.getNormalRightText(_localizer["Termin oddania pracy:"]));
            TableCell dipTableCell62 = new TableCell();

            dipTableCell62.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell62.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell63 = new TableCell();

            dipTableCell63.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell63.Append(_paragraphGetter.getNormalText(
                                      record.Level.ToLower().Contains("mag") ?
                                      _systemSettingsGetter.GetSystemSettings().MasterThesisEndDate.ToString("yyyy'-'MM'-'dd") :
                                      _systemSettingsGetter.GetSystemSettings().BachelorThesisEndDate.ToString("yyyy'-'MM'-'dd")));
            dipTableRow6.Append(dipTableCell61, dipTableCell62, dipTableCell63);

            TableRow dipTableRow7 = new TableRow();

            dipTableRow7.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell71 = new TableCell();

            dipTableCell71.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell71.Append(_paragraphGetter.getNormalRightText(_localizer["Promotor:"]));
            TableCell dipTableCell72 = new TableCell();

            dipTableCell72.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell72.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell73 = new TableCell();

            dipTableCell73.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell73.Append(_paragraphGetter.getNormalText(record.Promoter));
            dipTableRow7.Append(dipTableCell71, dipTableCell72, dipTableCell73);

            TableRow dipTableRow8 = new TableRow();

            dipTableRow8.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell dipTableCell81 = new TableCell();

            dipTableCell81.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            dipTableCell81.Append(_paragraphGetter.getNormalRightText(_localizer["Jednostka organizacyjna promotora:"]));
            TableCell dipTableCell82 = new TableCell();

            dipTableCell82.Append(_tablePropertiesGetter.getTableCellPropCentered("534"));
            dipTableCell82.Append(_paragraphGetter.getNormalText(""));
            TableCell dipTableCell83 = new TableCell();

            dipTableCell83.Append(_tablePropertiesGetter.getTableCellPropCentered("7087"));
            dipTableCell83.Append(_paragraphGetter.getNormalText(record.Institute));
            dipTableRow8.Append(dipTableCell81, dipTableCell82, dipTableCell83);

            diplomaTable.Append(dipTableRow1, dipTableRow2, dipTableRow3, dipTableRow4, dipTableRow5, dipTableRow6, dipTableRow7, dipTableRow8);

            return(diplomaTable);
        }
예제 #18
0
        public Table getTableWithUniversityInformation(ProposalDocRecord record)
        {
            Table universityTable = new Table();

            universityTable.AppendChild <TableProperties>(_tablePropertiesGetter.getHorizontalBorderTableProperties());

            TableRow uniTableRow1 = new TableRow();

            uniTableRow1.Append(new TableRowProperties(new TableRowHeight()
            {
                HeightType = HeightRuleValues.Exact, Val = 180
            }));
            TableCell uniTableCell11 = new TableCell();

            uniTableCell11.Append(_tablePropertiesGetter.getTableCellPropFilled("1559", "000000"));
            uniTableCell11.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell12 = new TableCell();

            uniTableCell12.Append(_tablePropertiesGetter.getTableCellPropFilled("2802", "CCCCCC"));
            uniTableCell12.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell13 = new TableCell();

            uniTableCell13.Append(_tablePropertiesGetter.getTableCellPropBorderless("283"));
            uniTableCell13.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell14 = new TableCell();

            uniTableCell14.Append(_tablePropertiesGetter.getTableCellPropFilled("1559", "000000"));
            uniTableCell14.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell15 = new TableCell();

            uniTableCell15.Append(_tablePropertiesGetter.getTableCellPropFilled("2977", "CCCCCC"));
            uniTableCell15.Append(_paragraphGetter.getNormalText(""));
            uniTableRow1.Append(uniTableCell11, uniTableCell12, uniTableCell13, uniTableCell14, uniTableCell15);


            TableRow uniTableRow2 = new TableRow();

            uniTableRow2.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell uniTableCell21 = new TableCell();

            uniTableCell21.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell21.Append(_paragraphGetter.getNormalRightText(_localizer["Uczelnia:"]));
            TableCell uniTableCell22 = new TableCell();

            uniTableCell22.Append(_tablePropertiesGetter.getTableCellPropCentered("2802"));
            uniTableCell22.Append(_paragraphGetter.getNormalText(record.College));
            TableCell uniTableCell23 = new TableCell();

            uniTableCell23.Append(_tablePropertiesGetter.getTableCellPropBorderless("283"));
            uniTableCell23.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell24 = new TableCell();

            uniTableCell24.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell24.Append(_paragraphGetter.getNormalRightText(_localizer["Profil kształcenia:"]));
            TableCell uniTableCell25 = new TableCell();

            uniTableCell25.Append(_tablePropertiesGetter.getTableCellPropCentered("2977"));
            uniTableCell25.Append(_paragraphGetter.getNormalText(record.StudyProfile));
            uniTableRow2.Append(uniTableCell21, uniTableCell22, uniTableCell23, uniTableCell24, uniTableCell25);

            TableRow uniTableRow3 = new TableRow();

            uniTableRow3.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell uniTableCell31 = new TableCell();

            uniTableCell31.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell31.Append(_paragraphGetter.getNormalRightText(_localizer["Wydział:"]));
            TableCell uniTableCell32 = new TableCell();

            uniTableCell32.Append(_tablePropertiesGetter.getTableCellPropCentered("2802"));
            uniTableCell32.Append(_paragraphGetter.getNormalText(record.Faculty));
            TableCell uniTableCell33 = new TableCell();

            uniTableCell33.Append(_tablePropertiesGetter.getTableCellPropBorderless("283"));
            uniTableCell33.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell34 = new TableCell();

            uniTableCell34.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell34.Append(_paragraphGetter.getNormalRightText(_localizer["Forma studiów:"]));
            TableCell uniTableCell35 = new TableCell();

            uniTableCell35.Append(_tablePropertiesGetter.getTableCellPropCentered("2977"));
            uniTableCell35.Append(_paragraphGetter.getNormalText(record.Mode));
            uniTableRow3.Append(uniTableCell31, uniTableCell32, uniTableCell33, uniTableCell34, uniTableCell35);

            TableRow uniTableRow4 = new TableRow();

            uniTableRow4.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell uniTableCell41 = new TableCell();

            uniTableCell41.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell41.Append(_paragraphGetter.getNormalRightText(_localizer["Kierunek:"]));
            TableCell uniTableCell42 = new TableCell();

            uniTableCell42.Append(_tablePropertiesGetter.getTableCellPropCentered("2802"));
            uniTableCell42.Append(_paragraphGetter.getNormalText(record.Course));
            TableCell uniTableCell43 = new TableCell();

            uniTableCell43.Append(_tablePropertiesGetter.getTableCellPropBorderless("283"));
            uniTableCell43.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell44 = new TableCell();

            uniTableCell44.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell44.Append(_paragraphGetter.getNormalRightText(_localizer["Poziom studiów:"]));
            TableCell uniTableCell45 = new TableCell();

            uniTableCell45.Append(_tablePropertiesGetter.getTableCellPropCentered("2977"));
            uniTableCell45.Append(_paragraphGetter.getNormalText(record.Level));
            uniTableRow4.Append(uniTableCell41, uniTableCell42, uniTableCell43, uniTableCell44, uniTableCell45);

            TableRow uniTableRow5 = new TableRow();

            uniTableRow5.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell uniTableCell51 = new TableCell();

            uniTableCell51.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell51.Append(_paragraphGetter.getNormalRightText(_localizer["Specjalność:"]));
            TableCell uniTableCell52 = new TableCell();

            uniTableCell52.Append(_tablePropertiesGetter.getTableCellPropCentered("2802"));
            uniTableCell52.Append(_paragraphGetter.getNormalText(record.Specialization));
            TableCell uniTableCell53 = new TableCell();

            uniTableCell53.Append(_tablePropertiesGetter.getTableCellPropBorderless("283"));
            uniTableCell53.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell54 = new TableCell();

            uniTableCell54.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            uniTableCell54.Append(_paragraphGetter.getNormalText(""));
            TableCell uniTableCell55 = new TableCell();

            uniTableCell55.Append(_tablePropertiesGetter.getTableCellPropCentered("2977"));
            uniTableCell55.Append(_paragraphGetter.getNormalText(""));
            uniTableRow5.Append(uniTableCell51, uniTableCell52, uniTableCell53, uniTableCell54, uniTableCell55);

            universityTable.Append(uniTableRow1, uniTableRow2, uniTableRow3, uniTableRow4, uniTableRow5);

            return(universityTable);
        }
예제 #19
0
        public Table getTableWithStudentsInformation(ProposalDocRecord record)
        {
            Table studentsTable = new Table();

            studentsTable.AppendChild <TableProperties>(_tablePropertiesGetter.getHorizontalBorderTableProperties());

            TableRow stdTableRow1 = new TableRow();

            stdTableRow1.Append(new TableRowProperties(new TableRowHeight()
            {
                HeightType = HeightRuleValues.Exact, Val = 180
            }));
            TableCell stdTableCell11 = new TableCell();

            stdTableCell11.Append(_tablePropertiesGetter.getTableCellPropFilled("1559", "000000"));
            stdTableCell11.Append(_paragraphGetter.getSmallCenteredText(""));
            TableCell stdTableCell12 = new TableCell();

            stdTableCell12.Append(_tablePropertiesGetter.getTableCellPropFilled("3694", "CCCCCC"));
            stdTableCell12.Append(_paragraphGetter.getSmallCenteredText(_localizer["Imię i nazwisko"]));
            TableCell stdTableCell13 = new TableCell();

            stdTableCell13.Append(_tablePropertiesGetter.getTableCellPropFilled("1575", "CCCCCC"));
            stdTableCell13.Append(_paragraphGetter.getSmallCenteredText(_localizer["Nr albumu"]));
            TableCell stdTableCell14 = new TableCell();

            stdTableCell14.Append(_tablePropertiesGetter.getTableCellPropFilled("2351", "CCCCCC"));
            stdTableCell14.Append(_paragraphGetter.getSmallCenteredText(_localizer["Data i podpis"]));
            stdTableRow1.Append(stdTableCell11, stdTableCell12, stdTableCell13, stdTableCell14);

            var      students     = record.Students.GetEnumerator();
            TableRow stdTableRow2 = new TableRow();

            stdTableRow2.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell stdTableCell21 = new TableCell();

            stdTableCell21.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            stdTableCell21.Append(_paragraphGetter.getNormalRightText(_localizer["Student:"]));
            TableCell stdTableCell22 = new TableCell();

            stdTableCell22.Append(_tablePropertiesGetter.getTableCellPropCentered("3694"));
            stdTableCell22.Append(_paragraphGetter.getNormalText(students.MoveNext() ? students.Current.Id.ToString() : ""));
            TableCell stdTableCell23 = new TableCell();

            stdTableCell23.Append(_tablePropertiesGetter.getTableCellPropCentered("1575"));
            stdTableCell23.Append(_paragraphGetter.getNormalText(""));
            TableCell stdTableCell24 = new TableCell();

            stdTableCell24.Append(_tablePropertiesGetter.getTableCellPropCentered("2351"));
            stdTableCell24.Append(_paragraphGetter.getNormalText(""));
            stdTableRow2.Append(stdTableCell21, stdTableCell22, stdTableCell23, stdTableCell24);

            TableRow stdTableRow3 = new TableRow();

            stdTableRow3.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell stdTableCell31 = new TableCell();

            stdTableCell31.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            stdTableCell31.Append(_paragraphGetter.getNormalRightText(_localizer["Student:"]));
            TableCell stdTableCell32 = new TableCell();

            stdTableCell32.Append(_tablePropertiesGetter.getTableCellPropCentered("3694"));
            stdTableCell32.Append(_paragraphGetter.getNormalText(students.MoveNext() ? students.Current.Id.ToString() : ""));
            TableCell stdTableCell33 = new TableCell();

            stdTableCell33.Append(_tablePropertiesGetter.getTableCellPropCentered("1575"));
            stdTableCell33.Append(_paragraphGetter.getNormalText(""));
            TableCell stdTableCell34 = new TableCell();

            stdTableCell34.Append(_tablePropertiesGetter.getTableCellPropCentered("2351"));
            stdTableCell34.Append(_paragraphGetter.getNormalText(""));
            stdTableRow3.Append(stdTableCell31, stdTableCell32, stdTableCell33, stdTableCell34);

            TableRow stdTableRow4 = new TableRow();

            stdTableRow4.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell stdTableCell41 = new TableCell();

            stdTableCell41.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            stdTableCell41.Append(_paragraphGetter.getNormalRightText(_localizer["Student:"]));
            TableCell stdTableCell42 = new TableCell();

            stdTableCell42.Append(_tablePropertiesGetter.getTableCellPropCentered("3694"));
            stdTableCell42.Append(_paragraphGetter.getNormalText(students.MoveNext() ? students.Current.Id.ToString() : ""));
            TableCell stdTableCell43 = new TableCell();

            stdTableCell43.Append(_tablePropertiesGetter.getTableCellPropCentered("1575"));
            stdTableCell43.Append(_paragraphGetter.getNormalText(""));
            TableCell stdTableCell44 = new TableCell();

            stdTableCell44.Append(_tablePropertiesGetter.getTableCellPropCentered("2351"));
            stdTableCell44.Append(_paragraphGetter.getNormalText(""));
            stdTableRow4.Append(stdTableCell41, stdTableCell42, stdTableCell43, stdTableCell44);

            TableRow stdTableRow5 = new TableRow();

            stdTableRow5.Append(new TableRowProperties(new TableRowHeight()
            {
                Val = 300
            }));
            TableCell stdTableCell51 = new TableCell();

            stdTableCell51.Append(_tablePropertiesGetter.getTableCellPropCentered("1559"));
            stdTableCell51.Append(_paragraphGetter.getNormalRightText(_localizer["Student:"]));
            TableCell stdTableCell52 = new TableCell();

            stdTableCell52.Append(_tablePropertiesGetter.getTableCellPropCentered("3694"));
            stdTableCell52.Append(_paragraphGetter.getNormalText(students.MoveNext() ? students.Current.Id.ToString() : ""));
            TableCell stdTableCell53 = new TableCell();

            stdTableCell53.Append(_tablePropertiesGetter.getTableCellPropCentered("1575"));
            stdTableCell53.Append(_paragraphGetter.getNormalText(""));
            TableCell stdTableCell54 = new TableCell();

            stdTableCell54.Append(_tablePropertiesGetter.getTableCellPropCentered("2351"));
            stdTableCell54.Append(_paragraphGetter.getNormalText(""));
            stdTableRow5.Append(stdTableCell51, stdTableCell52, stdTableCell53, stdTableCell54);

            studentsTable.Append(stdTableRow1, stdTableRow2, stdTableRow3, stdTableRow4, stdTableRow5);

            return(studentsTable);
        }
예제 #20
0
        internal static Table CreateTable(params HeaderDescriptor[] headers)
        {
            Table           table       = CreateTable(new OpenXmlElement[] { });
            TableProperties lProperties = table.FirstChild as TableProperties;

            if (lProperties != null)
            {
                lProperties.TableStyle = new TableStyle()
                {
                    Val = new StringValue("TableGrid")
                };
            }

            TableGrid lGrid = new TableGrid();

            table.Append(lGrid);

            foreach (HeaderDescriptor lDescriptor in headers)
            {
                GridColumn lColumn = new GridColumn()
                {
                    Width = new StringValue()
                    {
                        Value = lDescriptor.ColumnWidth
                    }
                };
                lGrid.Append(lColumn);
            }

            TableRow lRow = new TableRow();

            table.Append(lRow);

            foreach (HeaderDescriptor lDescriptor in headers)
            {
                TableCellProperties lCellProperties = new TableCellProperties()
                {
                    // Apply 10% gray to table headers
                    Shading = new Shading()
                    {
                        Val   = new EnumValue <ShadingPatternValues>(ShadingPatternValues.Clear),
                        Color = new StringValue("auto"),
                        Fill  = new StringValue("E6E6E6")
                    }
                };

                if (!lDescriptor.AutoWrap)
                {
                    lCellProperties.NoWrap = new NoWrap();
                }

                if (lDescriptor.AutoResize)
                {
                    TableCellWidth lWidth = new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Auto
                    };
                    lCellProperties.TableCellWidth = lWidth;
                }
                else
                {
                    TableCellWidth lWidth = new TableCellWidth()
                    {
                        Type  = TableWidthUnitValues.Dxa,
                        Width = new StringValue((lDescriptor.CellWidth * DOCUMENT_INCH_IN_DXA).ToString())
                    };
                    lCellProperties.TableCellWidth = lWidth;
                }

                TableCell lCell = new TableCell()
                {
                    TableCellProperties = lCellProperties
                };

                Paragraph lHeaderParagraph = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableHeadingStyle
                }),
                    new Run(
                        new RunProperties()
                {
                    Bold = new Bold()
                },
                        new Text(lDescriptor.HeaderName)
                {
                    Space = SpaceProcessingModeValues.Preserve
                }));
                lCell.Append(lHeaderParagraph);
                lRow.Append(lCell);
            }

            return(table);
        }
예제 #21
0
        // Creates an Table instance and adds its children.
        public Table GenerateTable()
        {
            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableStyle      tableStyle1      = new TableStyle()
            {
                Val = "TableGrid"
            };
            TableWidth tableWidth1 = new TableWidth()
            {
                Width = "0", Type = TableWidthUnitValues.Auto
            };
            TableLook tableLook1 = new TableLook()
            {
                Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true
            };

            tableProperties1.Append(tableStyle1);
            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableLook1);

            TableGrid  tableGrid1  = new TableGrid();
            GridColumn gridColumn1 = new GridColumn()
            {
                Width = "2394"
            };
            GridColumn gridColumn2 = new GridColumn()
            {
                Width = "2394"
            };
            GridColumn gridColumn3 = new GridColumn()
            {
                Width = "2394"
            };
            GridColumn gridColumn4 = new GridColumn()
            {
                Width = "2394"
            };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);
            tableGrid1.Append(gridColumn4);

            TableRow tableRow1 = new TableRow()
            {
                RsidTableRowAddition = "00607D74", RsidTableRowProperties = "0055020F", ParagraphId = "2D079EFF", TextId = "77777777"
            };

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth      tableCellWidth1      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };
            Shading shading1 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2
            };

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(shading1);
            Paragraph paragraph1 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6ED85602", TextId = "77777777"
            };

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth      tableCellWidth2      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };
            Shading shading2 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2
            };

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(shading2);
            Paragraph paragraph2 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "7C687A4B", TextId = "77777777"
            };

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph2);

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth      tableCellWidth3      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };
            Shading shading3 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2
            };

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(shading3);
            Paragraph paragraph3 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "4F287AEB", TextId = "77777777"
            };

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph3);

            TableCell tableCell4 = new TableCell();

            TableCellProperties tableCellProperties4 = new TableCellProperties();
            TableCellWidth      tableCellWidth4      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };
            Shading shading4 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2
            };

            tableCellProperties4.Append(tableCellWidth4);
            tableCellProperties4.Append(shading4);
            Paragraph paragraph4 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "5F0063F5", TextId = "77777777"
            };

            tableCell4.Append(tableCellProperties4);
            tableCell4.Append(paragraph4);

            tableRow1.Append(tableCell1);
            tableRow1.Append(tableCell2);
            tableRow1.Append(tableCell3);
            tableRow1.Append(tableCell4);

            TableRow tableRow2 = new TableRow()
            {
                RsidTableRowAddition = "00607D74", RsidTableRowProperties = "00607D74", ParagraphId = "2558F9F0", TextId = "77777777"
            };

            TableCell tableCell5 = new TableCell();

            TableCellProperties tableCellProperties5 = new TableCellProperties();
            TableCellWidth      tableCellWidth5      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties5.Append(tableCellWidth5);

            Paragraph paragraph5 = new Paragraph()
            {
                RsidParagraphMarkRevision = "0055020F", RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "186B732E", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            Bold bold1 = new Bold();

            paragraphMarkRunProperties1.Append(bold1);

            paragraphProperties1.Append(paragraphMarkRunProperties1);

            paragraph5.Append(paragraphProperties1);

            tableCell5.Append(tableCellProperties5);
            tableCell5.Append(paragraph5);

            TableCell tableCell6 = new TableCell();

            TableCellProperties tableCellProperties6 = new TableCellProperties();
            TableCellWidth      tableCellWidth6      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties6.Append(tableCellWidth6);
            Paragraph paragraph6 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6D2E7DAE", TextId = "77777777"
            };

            tableCell6.Append(tableCellProperties6);
            tableCell6.Append(paragraph6);

            TableCell tableCell7 = new TableCell();

            TableCellProperties tableCellProperties7 = new TableCellProperties();
            TableCellWidth      tableCellWidth7      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties7.Append(tableCellWidth7);
            Paragraph paragraph7 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "2B98717A", TextId = "77777777"
            };

            tableCell7.Append(tableCellProperties7);
            tableCell7.Append(paragraph7);

            TableCell tableCell8 = new TableCell();

            TableCellProperties tableCellProperties8 = new TableCellProperties();
            TableCellWidth      tableCellWidth8      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties8.Append(tableCellWidth8);
            Paragraph paragraph8 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "12461324", TextId = "77777777"
            };

            tableCell8.Append(tableCellProperties8);
            tableCell8.Append(paragraph8);

            tableRow2.Append(tableCell5);
            tableRow2.Append(tableCell6);
            tableRow2.Append(tableCell7);
            tableRow2.Append(tableCell8);

            TableRow tableRow3 = new TableRow()
            {
                RsidTableRowAddition = "00607D74", RsidTableRowProperties = "00607D74", ParagraphId = "56FE196D", TextId = "77777777"
            };

            TableCell tableCell9 = new TableCell();

            TableCellProperties tableCellProperties9 = new TableCellProperties();
            TableCellWidth      tableCellWidth9      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties9.Append(tableCellWidth9);

            Paragraph paragraph9 = new Paragraph()
            {
                RsidParagraphMarkRevision = "0055020F", RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "617925F5", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            Color color1 = new Color()
            {
                Val = "FF0000"
            };

            paragraphMarkRunProperties2.Append(color1);

            paragraphProperties2.Append(paragraphMarkRunProperties2);
            BookmarkStart bookmarkStart1 = new BookmarkStart()
            {
                Name = "_GoBack", Id = "0"
            };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd()
            {
                Id = "0"
            };

            paragraph9.Append(paragraphProperties2);
            paragraph9.Append(bookmarkStart1);
            paragraph9.Append(bookmarkEnd1);

            tableCell9.Append(tableCellProperties9);
            tableCell9.Append(paragraph9);

            TableCell tableCell10 = new TableCell();

            TableCellProperties tableCellProperties10 = new TableCellProperties();
            TableCellWidth      tableCellWidth10      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties10.Append(tableCellWidth10);
            Paragraph paragraph10 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "7FB20390", TextId = "77777777"
            };

            tableCell10.Append(tableCellProperties10);
            tableCell10.Append(paragraph10);

            TableCell tableCell11 = new TableCell();

            TableCellProperties tableCellProperties11 = new TableCellProperties();
            TableCellWidth      tableCellWidth11      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties11.Append(tableCellWidth11);
            Paragraph paragraph11 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6B3FAA2A", TextId = "77777777"
            };

            tableCell11.Append(tableCellProperties11);
            tableCell11.Append(paragraph11);

            TableCell tableCell12 = new TableCell();

            TableCellProperties tableCellProperties12 = new TableCellProperties();
            TableCellWidth      tableCellWidth12      = new TableCellWidth()
            {
                Width = "2394", Type = TableWidthUnitValues.Dxa
            };

            tableCellProperties12.Append(tableCellWidth12);
            Paragraph paragraph12 = new Paragraph()
            {
                RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "046FFB08", TextId = "77777777"
            };

            tableCell12.Append(tableCellProperties12);
            tableCell12.Append(paragraph12);

            tableRow3.Append(tableCell9);
            tableRow3.Append(tableCell10);
            tableRow3.Append(tableCell11);
            tableRow3.Append(tableCell12);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(tableRow1);
            table1.Append(tableRow2);
            table1.Append(tableRow3);
            return(table1);
        }
예제 #22
0
        /// <summary>
        /// Adds a context table for the template. The context table lists all templates that are used by the current template, as
        /// well as all templates that this current template uses. Templates that use this template also indicate whether they are
        /// required or optional, depending on the conformance of the constraint that uses this template.
        /// </summary>
        /// <param name="template">The template in question</param>
        /// <param name="allConstraints">All constraints for the current template</param>
        private void AddTemplateContextTable()
        {
            TableRow  newRow        = new TableRow();
            TableCell usedByCell    = new TableCell();
            TableCell containedCell = new TableCell();

            var usedByTemplates = (from tc in this.tdb.TemplateConstraints
                                   join te in this.tdb.Templates on tc.TemplateId equals te.Id
                                   where tc.ContainedTemplateId == template.Id && tc.TemplateId != template.Id
                                   orderby tc.Conformance, te.Name
                                   select te)
                                  .Distinct().ToList();
            var containedTemplates = (from ac in allConstraints
                                      join ct in this.tdb.Templates on ac.ContainedTemplateId equals ct.Id
                                      where this.exportedTemplates.Exists(y => y.Id == ct.Id) && ac.ContainedTemplateId != null
                                      orderby ct.Name
                                      select ct)
                                     .Distinct().ToList();

            var usedByTemplatesSelectedForExport    = usedByTemplates.Where(e => this.exportedTemplates.Exists(y => y.Id == e.Id)).ToList();
            var containedTemplatesSelectedForExport = containedTemplates.Where(e => this.exportedTemplates.Exists(y => y.Id == e.Id)).ToList();

            int maxRows = containedTemplatesSelectedForExport.Count > usedByTemplatesSelectedForExport.Count ? containedTemplatesSelectedForExport.Count : usedByTemplatesSelectedForExport.Count;

            for (int i = 0; i < maxRows; i++)
            {
                Paragraph usedByPara = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }));
                Paragraph containedPara = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }));

                Template usedByTemplate    = i < usedByTemplatesSelectedForExport.Count ? usedByTemplatesSelectedForExport[i] : null;
                Template containedTemplate = i < containedTemplatesSelectedForExport.Count ? containedTemplatesSelectedForExport[i] : null;

                // Output the used by template
                if (usedByTemplate != null)
                {
                    List <TemplateConstraint> usedByConstraints = this.tdb.TemplateConstraints.Where(y =>
                                                                                                     y.TemplateId == usedByTemplate.Id &&
                                                                                                     y.ContainedTemplateId == template.Id).ToList();
                    bool isRequired = AreConstraintsRequiredByParents(usedByConstraints);

                    // Output a hyperlink if it is included in this doc, otherwise plain text
                    if (this.exportedTemplates.Exists(y => y.Id == usedByTemplate.Id))
                    {
                        usedByPara.Append(
                            DocHelper.CreateAnchorHyperlink(usedByTemplate.Name, usedByTemplate.Bookmark, Properties.Settings.Default.TableLinkStyle),
                            DocHelper.CreateRun(isRequired ? " (required)" : " (optional)"));
                    }
                    else
                    {
                        usedByPara.Append(
                            DocHelper.CreateRun(usedByTemplate.Name),
                            DocHelper.CreateRun(isRequired ? " (required)" : " (optional)"));
                    }

                    usedByCell.Append(usedByPara);
                }

                // Output the contained template
                if (containedTemplate != null)
                {
                    // Output a hyperlink if it is included in this doc, otherwise plain text
                    if (this.exportedTemplates.Exists(y => y.Id == containedTemplate.Id))
                    {
                        containedPara.Append(
                            DocHelper.CreateAnchorHyperlink(containedTemplate.Name, containedTemplate.Bookmark, Properties.Settings.Default.TableLinkStyle));
                    }
                    else
                    {
                        containedPara.Append(
                            DocHelper.CreateRun(containedTemplate.Name));
                    }

                    containedCell.Append(containedPara);
                }
            }

            // Make sure the cells have at least one paragraph in them
            if (containedCell.ChildElements.Count == 0)
            {
                containedCell.AppendChild(new Paragraph());
            }

            if (usedByCell.ChildElements.Count == 0)
            {
                usedByCell.AppendChild(new Paragraph());
            }

            // Only add the table to the document if there are conatined or used-by relationships
            if (maxRows > 0)
            {
                string[] headers = new string[] { TEMPLATE_CONTEXT_TABLE_USED_BY, TEMPLATE_CONTEXT_TABLE_CONTAINS };
                Table    t       = this.tables.AddTable(string.Format("{0} Contexts", template.Name), headers);

                t.Append(
                    new TableRow(usedByCell, containedCell));
            }
        }
예제 #23
0
        private void WriteVariables(Body body)
        {
            Paragraph p = CreateMidashi1Paragraph("3. " + Resources.VariableSummary); //変数の概要
            body.Append(p);

            ObservableCollection<QuestionVM> questions = studyUnit.AllQuestions;
            foreach (VariableVM variable in studyUnit.Variables)
            {
                StringBuilder buf = new StringBuilder();
                buf.Append(variable.Title);
                buf.Append(" ");
                buf.Append(variable.Label);
                buf.Append(" (");
                buf.Append(variable.Response.TypeName);
                buf.Append(" )");
                p = CreateParagraph(buf.ToString());
                body.Append(p);

                QuestionVM question = EDOUtils.Find<QuestionVM>(questions, variable.QuestionId);
                buf = new StringBuilder();
                buf.Append(Resources.CorrespondingQuestionSentence); //対応する質問文
                if (question != null)
                {
                    buf.Append(" " + question.Text);
                }

                //質問文の段落
                p = CreateParagraph(buf.ToString());
                body.Append(p);

                if (variable.Response.IsTypeChoices)
                {
                    p = CreateEmptyParagraph();
                    body.Append(p);

                    Table table = new Table();
                    body.Append(table);

                    TableProperties tableProperties = new TableProperties();
                    DocumentFormat.OpenXml.Wordprocessing.TableStyle tableStyle = new DocumentFormat.OpenXml.Wordprocessing.TableStyle() { Val = "TableGrid" };
                    TableWidth tableWidth = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto };
                    TableLook tableLook = new TableLook()
                    {
                        Val = "04A0",
                        FirstRow = true,
                        LastRow = false,
                        FirstColumn = true,
                        LastColumn = false,
                        NoHorizontalBand = false,
                        NoVerticalBand = true
                    };
                    tableProperties.Append(tableStyle);
                    tableProperties.Append(tableWidth);
                    tableProperties.Append(tableLook);
                    table.Append(tableProperties);

                    TableRow tableRow = new TableRow();
                    table.Append(tableRow);

                    TableCell tableCell1 = new TableCell();
                    tableCell1.Append(CreateParagraph(Resources.Code));
                    tableRow.Append(tableCell1);

                    TableCell tableCell2 = new TableCell();
                    tableCell2.Append(CreateParagraph(Resources.Category));
                    tableRow.Append(tableCell2);

                    TableCell tableCell3 = new TableCell();
                    tableCell3.Append(CreateParagraph(Resources.Total));
                    tableRow.Append(tableCell3);

                    ObservableCollection<CodeVM> codes = variable.Response.Codes;
                    foreach (CodeVM code in codes)
                    {
                        tableRow = new TableRow();
                        table.Append(tableRow);

                        tableCell1 = new TableCell();
                        tableCell1.Append(CreateParagraph(code.Value));
                        tableRow.Append(tableCell1);

                        tableCell2 = new TableCell();
                        tableCell2.Append(CreateParagraph(code.Label));
                        tableRow.Append(tableCell2);

                        tableCell3 = new TableCell();
                        tableCell3.Append(CreateEmptyParagraph());
                        tableRow.Append(tableCell3);
                    }

                }

                //空の段落
                p = CreateEmptyParagraph();
                body.Append(p);

            }
            p = CreateBreakPageParagraph();
            body.Append(p);
        }
예제 #24
0
        /// <summary>
        /// Gets a category header row.
        /// </summary>
        /// <remarks>
        /// This method is used in Document assembly to create the details row for a category on the job description page
        /// </remarks>
        /// <returns>An assembled <see cref="T:DocumentFormat.OpenXml.Wordprocessing.TableRow"/></returns>
        public TableRow GenerateDetailsRow()
        {
            TableRow           tableRow1           = new TableRow();
            TableRowProperties tableRowProperties1 = new TableRowProperties();
            CantSplit          cantSplit1          = new CantSplit();
            TableRowHeight     tableRowHeight1     = new TableRowHeight()
            {
                Val = (UInt32Value)1063U
            };
            TableJustification tableJustification1 = new TableJustification()
            {
                Val = TableRowAlignmentValues.Center
            };

            tableRowProperties1.Append(cantSplit1);
            tableRowProperties1.Append(tableRowHeight1);
            tableRowProperties1.Append(tableJustification1);

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth      tableCellWidth1      = new TableCellWidth()
            {
                Width = "535", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder        topBorder1        = new TopBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders1.Append(topBorder1);
            Shading shading1 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(tableCellBorders1);
            tableCellProperties1.Append(shading1);

            Paragraph paragraph1 = new Paragraph();

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            Justification       justification1       = new Justification()
            {
                Val = JustificationValues.Center
            };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            RunStyle runStyle1 = new RunStyle()
            {
                Val = "TimesLarge"
            };

            paragraphMarkRunProperties1.Append(runStyle1);

            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            paragraph1.Append(paragraphProperties1);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth      tableCellWidth2      = new TableCellWidth()
            {
                Width = "545", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders2 = new TableCellBorders();
            TopBorder        topBorder2        = new TopBorder()
            {
                Val = BorderValues.Nil
            };

            tableCellBorders2.Append(topBorder2);
            Shading shading2 = new Shading()
            {
                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9"
            };

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(tableCellBorders2);
            tableCellProperties2.Append(shading2);

            Paragraph paragraph2 = new Paragraph();

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            RunStyle runStyle2 = new RunStyle()
            {
                Val = "TimesLarge"
            };

            paragraphMarkRunProperties2.Append(runStyle2);

            paragraphProperties2.Append(paragraphMarkRunProperties2);

            paragraph2.Append(paragraphProperties2);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph2);

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth      tableCellWidth3      = new TableCellWidth()
            {
                Width = "4902", Type = TableWidthUnitValues.Dxa
            };
            TableCellBorders tableCellBorders3 = new TableCellBorders();
            TopBorder        topBorder3        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder3 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder3 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder3 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };

            tableCellBorders3.Append(topBorder3);
            tableCellBorders3.Append(leftBorder3);
            tableCellBorders3.Append(bottomBorder3);
            tableCellBorders3.Append(rightBorder3);

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(tableCellBorders3);
            foreach (PositionDescriptionItem p in PositionDescriptionItems)
            {
                Paragraph paragraph3 = new Paragraph();

                ParagraphProperties paragraphProperties3 = new ParagraphProperties();
                SpacingBetweenLines spacingBetweenLines3 = new SpacingBetweenLines()
                {
                    After = "100"
                };
                Indentation indentation1 = new Indentation()
                {
                    Left = "0", Hanging = "0"
                };

                ParagraphMarkRunProperties paragraphMarkRunProperties3 = new ParagraphMarkRunProperties();
                RunStyle runStyle3 = new RunStyle()
                {
                    Val = "TimesLarge"
                };
                Bold bold1 = new Bold()
                {
                    Val = false
                };
                Caps caps1 = new Caps()
                {
                    Val = false
                };
                FontSize fontSize1 = new FontSize()
                {
                    Val = "16"
                };
                FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript()
                {
                    Val = "16"
                };

                paragraphMarkRunProperties3.Append(runStyle3);
                paragraphMarkRunProperties3.Append(bold1);
                paragraphMarkRunProperties3.Append(caps1);
                paragraphMarkRunProperties3.Append(fontSize1);
                paragraphMarkRunProperties3.Append(fontSizeComplexScript1);
                paragraphProperties3.Append(spacingBetweenLines3);
                paragraphProperties3.Append(paragraphMarkRunProperties3);
                paragraphProperties3.Append(indentation1);
                ProofError proofError1 = new ProofError()
                {
                    Type = ProofingErrorValues.SpellStart
                };

                Run run1 = new Run();

                RunProperties runProperties1 = new RunProperties();
                RunStyle      runStyle4      = new RunStyle()
                {
                    Val = "TimesLarge"
                };
                Bold bold2 = new Bold()
                {
                    Val = false
                };
                Caps caps2 = new Caps()
                {
                    Val = false
                };
                FontSize fontSize2 = new FontSize()
                {
                    Val = "16"
                };
                FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript()
                {
                    Val = "16"
                };

                runProperties1.Append(runStyle4);
                runProperties1.Append(bold2);
                runProperties1.Append(caps2);
                runProperties1.Append(fontSize2);
                runProperties1.Append(fontSizeComplexScript2);
                Text text1 = new Text();
                text1.Text = p.Detail;

                run1.Append(runProperties1);
                run1.Append(text1);
                ProofError proofError2 = new ProofError()
                {
                    Type = ProofingErrorValues.SpellEnd
                };

                paragraph3.Append(paragraphProperties3);
                //paragraph3.Append(proofError1);
                paragraph3.Append(run1);
                //paragraph3.Append(proofError2);


                tableCell3.Append(paragraph3);
            } // To Here?
            tableCell3.Append(tableCellProperties3);
            TableCell tableCell4 = new TableCell();

            TableCellProperties tableCellProperties4 = new TableCellProperties();
            TableCellWidth      tableCellWidth4      = new TableCellWidth()
            {
                Width = "5538", Type = TableWidthUnitValues.Dxa
            };
            TableCellBorders tableCellBorders4 = new TableCellBorders();
            TopBorder        topBorder4        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder4 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder4 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder4 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U
            };

            tableCellBorders4.Append(topBorder4);
            tableCellBorders4.Append(leftBorder4);
            tableCellBorders4.Append(bottomBorder4);
            tableCellBorders4.Append(rightBorder4);
            GridSpan gridSpan1 = new GridSpan()
            {
                Val = 2
            };

            tableCellProperties4.Append(tableCellWidth4);
            tableCellProperties4.Append(gridSpan1);
            tableCellProperties4.Append(tableCellBorders4);
            int bulletListCount = 1;

            foreach (PerformanceStandardItem p in PerformanceStandardItems)
            {
                Paragraph           paragraph4           = new Paragraph();
                ParagraphProperties paragraphProperties4 = new ParagraphProperties();
                SpacingBetweenLines spacingBetweenLines4 = new SpacingBetweenLines()
                {
                    After = "100"
                };

                ParagraphMarkRunProperties paragraphMarkRunProperties4 = new ParagraphMarkRunProperties();
                FontSize fontSize3 = new FontSize()
                {
                    Val = "16"
                };
                FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript()
                {
                    Val = "16"
                };
                Indentation indentation4 = new Indentation()
                {
                    Left = "270", Hanging = "270"
                };

                paragraphMarkRunProperties4.Append(fontSize3);
                paragraphMarkRunProperties4.Append(fontSizeComplexScript3);
                paragraphProperties4.Append(indentation4);
                paragraphProperties4.Append(spacingBetweenLines4);
                paragraphProperties4.Append(paragraphMarkRunProperties4);
                ProofError proofError3 = new ProofError()
                {
                    Type = ProofingErrorValues.SpellStart
                };

                Run run2 = new Run();

                RunProperties runProperties2 = new RunProperties();
                FontSize      fontSize4      = new FontSize()
                {
                    Val = "16"
                };
                FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript()
                {
                    Val = "16"
                };

                runProperties2.Append(fontSize4);
                runProperties2.Append(fontSizeComplexScript4);
                Text text2 = new Text();
                text2.Text = $"{Letter}{bulletListCount}: {p.Detail}";
                bulletListCount++;
                run2.Append(runProperties2);
                run2.Append(text2);
                ProofError proofError4 = new ProofError()
                {
                    Type = ProofingErrorValues.SpellEnd
                };

                paragraph4.Append(paragraphProperties4);
                paragraph4.Append(proofError3);
                paragraph4.Append(run2);
                paragraph4.Append(proofError4);


                tableCell4.Append(paragraph4);
            }
            tableCell4.Append(tableCellProperties4);
            tableRow1.Append(tableRowProperties1);
            tableRow1.Append(tableCell1);
            tableRow1.Append(tableCell2);
            tableRow1.Append(tableCell3);
            tableRow1.Append(tableCell4);
            return(tableRow1);
        }
예제 #25
0
        private void GenerateChapterFourTable2()
        {
            var chapterFour = (ChapterFour)_sessionObjects.ChapterFour;
            var discipline = (Discipline)_additionalObjects.Discipline;

            var paraProp = new ParagraphProperties();
            var paragraph = new Paragraph();
            var runProp = new RunProperties();
            var run = new Run();
            var runs = new List<Run>();

            var table = new Table();
            table.Append(GenerateTableProperties());

            var tableGrid1 = new TableGrid();
            tableGrid1.Append(new GridColumn { Width = "450" });
            tableGrid1.Append(new GridColumn { Width = "3100" });
            tableGrid1.Append(new GridColumn { Width = "800" });
            tableGrid1.Append(new GridColumn { Width = "450" });
            tableGrid1.Append(new GridColumn { Width = "600" });
            tableGrid1.Append(new GridColumn { Width = "600" });
            tableGrid1.Append(new GridColumn { Width = "600" });
            tableGrid1.Append(new GridColumn { Width = "600" });
            tableGrid1.Append(new GridColumn { Width = "650" });
            tableGrid1.Append(new GridColumn { Width = "600" });
            tableGrid1.Append(new GridColumn { Width = "600" });

            table.Append(tableGrid1);

            #region Шапка

            #region row
            var tableRow = new TableRow();

            #region cell
            var tableCell = new TableCell();
            TableCellProperties tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            var justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Номер раздела"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Наименование раздела / темы"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Обрабатываемые"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("компетенции"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Семестр"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Неделя семестра"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new GridSpan(){ Val = 6 });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Часов по учебной (рабочей) программе"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            var tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Всего в уч. плане по разделу / теме"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new GridSpan(){ Val = 3 });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Аудиторная работа"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Самостоятельная"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("работа студента"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Экзамен"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Всего"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new GridSpan(){ Val = 2 });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("В том числе"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();
            TableRowProperties tableRowProperties1 = new TableRowProperties();
            tableRowProperties1.Append(new TableRowHeight() { Val = (UInt32Value)1775U });
            tableRow.Append(tableRowProperties1);

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Лекции"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new TextDirection() { Val = TextDirectionValues.BottomToTopLeftToRight });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("Практич. занятия"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion
            #endregion

            #region Данные

            var dstTable = chapterFour.DistributionStudyTime;
            var dstSummTable = chapterFour.DistributionStudyTimeSumm;
            var chSummTable = chapterFour.ChaptersSumm;
            for (var k = 0; k < chSummTable.Rows.Count; k++)
            {
                #region row Раздел
                tableRow = new TableRow();

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties { Bold = new Bold() };
                run.Append(runProp);
                run.Append(new Text(chSummTable.Rows[k]["ChapterIndex"].ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Left };
                Indentation indentation = new Indentation() { Left = "87" };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                paraProp.Append(indentation);
                run = new Run();
                runProp = new RunProperties {
                    Italic = new Italic(),
                    Bold = new Bold()
                };
                run.Append(runProp);
                run.Append(new Text(chSummTable.Rows[k]["ChapterName"].ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Left };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Left };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Left };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                for (var i = 2; i < chSummTable.Columns.Count; i++)
                {
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    runProp = new RunProperties { Bold = new Bold() };
                    run.Append(runProp);
                    var num = Helper.ConvertObjectToInt(chSummTable.Rows[k][i]);
                    var str = "";
                    if(num != 0)
                    {
                        str = num.ToString();
                    }
                    run.Append(new Text(str));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }

                table.Append(tableRow);
                #endregion

                var indexTheme = 0;
                for (var i = 0; i < dstTable.Rows.Count; i++)
                {
                    if (Helper.ConvertObjectToInt(dstTable.Rows[i]["Номер раздела"]) == Helper.ConvertObjectToInt(chSummTable.Rows[k]["ChapterIndex"]))
                    {
                        indexTheme++;

                        #region row Тема
                        tableRow = new TableRow();

                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        justification = new Justification() { Val = JustificationValues.Left };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(justification);
                        run = new Run();
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion

                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        indentation = new Indentation() { Left = "87" };
                        justification = new Justification() { Val = JustificationValues.Left };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(indentation);
                        paraProp.Append(justification);
                        run = new Run();
                        var str = String.Format("Тема {0}.{1}. {2}",
                            Helper.ConvertObjectToInt(chSummTable.Rows[k]["ChapterIndex"]),
                            indexTheme,
                            dstTable.Rows[i]["Наименование темы"]
                            );
                        run.Append(new Text(str));
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion

                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        #region компетенции
                        var competence = dstTable.Rows[i]["Компетенции"].ToString().Replace(" ", "").Split(',');
                        foreach (var c in competence)
                        {
                            paragraph = new Paragraph();
                            paraProp = GetParagraphProperties("TableStyle");
                            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                            justification = new Justification() { Val = JustificationValues.Center };
                            paraProp.Append(spacingBetweenLines);
                            paraProp.Append(justification);
                            run = new Run();
                            run.Append(new Text(c));
                            paragraph.Append(paraProp);
                            paragraph.Append(run);
                            tableCell.Append(paragraph);
                        }
                        if (competence.Length == 0)
                        {
                            paragraph = new Paragraph();
                            paraProp = GetParagraphProperties("TableStyle");
                            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                            justification = new Justification() { Val = JustificationValues.Center };
                            paraProp.Append(spacingBetweenLines);
                            paraProp.Append(justification);
                            run = new Run();
                            run.Append(new Text());
                            paragraph.Append(paraProp);
                            paragraph.Append(run);
                            tableCell.Append(paragraph);
                        }
                        #endregion

                        tableRow.Append(tableCell);
                        #endregion

                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        justification = new Justification() { Val = JustificationValues.Center };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(justification);
                        run = new Run();
                        run.Append(new Text(dstTable.Rows[i]["Семестр"].ToString()));
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion

                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        justification = new Justification() { Val = JustificationValues.Center };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(justification);
                        run = new Run();
                        run.Append(new Text(dstTable.Rows[i]["Неделя семестра"].ToString()));
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion

                        //dstSummTable
                        //обнаружил какой-то столбец ChapterIndex, уменьшил фор на 1
                        //dstSummTable.Columns.Count - 1
                        for (var j = 1; j < dstSummTable.Columns.Count - 1; j++)
                        {
                            #region cell
                            tableCell = new TableCell();
                            tableCellProperties1 = new TableCellProperties();
                            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                            tableCell.Append(tableCellProperties1);

                            paragraph = new Paragraph();
                            paraProp = GetParagraphProperties("TableStyle");
                            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                            justification = new Justification() { Val = JustificationValues.Center };
                            paraProp.Append(spacingBetweenLines);
                            paraProp.Append(justification);
                            run = new Run();
                            run.Append(new Text(dstSummTable.Rows[i][j].ToString()));
                            paragraph.Append(paraProp);
                            paragraph.Append(run);
                            tableCell.Append(paragraph);
                            tableRow.Append(tableCell);
                            #endregion
                        }

                        //dstTable
                        for (var j = 5; j < dstTable.Columns.Count; j++)
                        {
                            #region cell
                            tableCell = new TableCell();
                            tableCellProperties1 = new TableCellProperties();
                            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                            tableCell.Append(tableCellProperties1);

                            paragraph = new Paragraph();
                            paraProp = GetParagraphProperties("TableStyle");
                            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                            justification = new Justification() { Val = JustificationValues.Center };
                            paraProp.Append(spacingBetweenLines);
                            paraProp.Append(justification);
                            run = new Run();
                            run.Append(new Text(dstTable.Rows[i][j].ToString()));
                            paragraph.Append(paraProp);
                            paragraph.Append(run);
                            tableCell.Append(paragraph);
                            tableRow.Append(tableCell);
                            #endregion
                        }

                        //экзамен. пустая ячейка
                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        justification = new Justification() { Val = JustificationValues.Center };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(justification);
                        run = new Run();
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion

                        table.Append(tableRow);
                        #endregion
                    }
                }
            }

            #region Экзамены
            var chapterNum = chapterFour.Chapters.Rows.Count;
            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                if (discipline.Semesters[i].ValidationHours != 0)
                {
                    tableRow = new TableRow();

                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Left };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run(new Text(chapterNum.ToString()));
                    chapterNum++;
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion

                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Left };
                    var indentation = new Indentation() { Left = "87" };
                    paraProp.Append(indentation);
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    var str = "Подготовка к " + discipline.Semesters[i].Validation + "у";
                    run = new Run(new Text(str));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion

                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Left };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion

                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run(new Text(discipline.Semesters[i].Number.ToString()));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion

                    for (var z = 0; z < 6; z++)
                    {
                        #region cell
                        tableCell = new TableCell();
                        tableCellProperties1 = new TableCellProperties();
                        tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                        tableCell.Append(tableCellProperties1);

                        paragraph = new Paragraph();
                        paraProp = GetParagraphProperties("TableStyle");
                        spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                        justification = new Justification() { Val = JustificationValues.Left };
                        paraProp.Append(spacingBetweenLines);
                        paraProp.Append(justification);
                        run = new Run();
                        paragraph.Append(paraProp);
                        paragraph.Append(run);
                        tableCell.Append(paragraph);
                        tableRow.Append(tableCell);
                        #endregion
                    }

                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run(new Text(discipline.Semesters[i].ValidationHours.ToString()));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion

                    table.Append(tableRow);
                }
            }
            #endregion

            var dstAllSummTable = chapterFour.DistributionStudyTimeCheckSumm;
            for (var i = 0; i < dstAllSummTable.Rows.Count; i++)
            {
                #region row общее количество часов
                tableRow = new TableRow();

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1 = new TableCellProperties();
                Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9" };
                tableCellProperties1.Append(shading1);
                tableCellProperties1.Append(new GridSpan() { Val = 5 });
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold(),
                };
                run.Append(runProp);
                run.Append(new Text(dstAllSummTable.Rows[i][0].ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                for (var j = 1; j < dstAllSummTable.Columns.Count; j++)
                {
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1 = new TableCellProperties();
                    shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9" };
                    tableCellProperties1.Append(shading1);
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    runProp = new RunProperties
                    {
                        Bold = new Bold(),
                    };
                    run.Append(runProp);
                    var num = Helper.ConvertObjectToInt(dstAllSummTable.Rows[i][j]);
                    var str = "";
                    if (num != 0)
                    {
                        str = num.ToString();
                    }
                    run.Append(new Text(str));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }
                table.Append(tableRow);
                #endregion
            }

            #endregion

            _body.Append(table);

            GenerateParagraph();
        }
        public async Task AddAssignments(MemoryStream memoryStream, string bookmarkName)
        {
            for (int i = 0; i < Assignments.Count; i++)
            {
                string techniques = "";
                for (int y = 0; y < Assignments[i].Experiences.Count; y++)
                {
                    if (y == Assignments[i].Experiences.Count - 1)
                    {
                        techniques += Assignments[i].Experiences[y];
                    }
                    else
                    {
                        techniques += Assignments[i].Experiences[y] + "    ";
                    }
                }

                using (var document = WordprocessingDocument.Open(memoryStream, true))
                {
                    var doc = document.MainDocumentPart.Document;
                    //Create table
                    Table table = new Table();
                    //Create row, CantSplit row between pages
                    var tr = new TableRow(new TableRowProperties(new CantSplit()));
                    //Create tc
                    var tc1 = new TableCell(new TableCellProperties(new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = "2150"
                    }));
                    var tc2 = new TableCell();

                    //Append data-para-run to tc, use FontStyle method (Font,Style,bool)
                    tc1.Append(new Paragraph(new Run(FontStyle("Calibri", 11, true), new Text(Assignments[i].Title))));
                    tc1.Append(new Paragraph(new Run(FontStyle("Calibri", 9), new Text(await DateStringBuilder(Assignments[i].StartDate, Assignments[i].EndDate)))));
                    //tc1.Append(new Paragraph(new Run(FontStyle("Calibri", 9), new Text("Location"))));
                    tc2.Append(new Paragraph(new Run(FontStyle("Calibri", 13, true), new Text(Assignments[i].Role))));
                    tc2.Append(new Paragraph(new Run(FontStyle("Calibri", 11), new Text(Assignments[i].Description))));

                    //Create Paragraph, Run
                    var p = new Paragraph();
                    var r = new Run(FontStyle("Calibri", 13, true));
                    //Text color
                    var   rp = new RunProperties();
                    Color c  = new Color();
                    c.Val = "777777";
                    rp.Append(c);
                    r.Append(rp);

                    r.Append(new Text(techniques));
                    p.Append(r);
                    tc2.Append(p);

                    //Append tc to tr
                    tr.Append(tc1, tc2);
                    //Append tr to table
                    table.Append(tr);

                    var mainPart = document.MainDocumentPart;
                    var res      = from bm in mainPart.Document.Body.Descendants <BookmarkStart>()
                                   where bm.Name == bookmarkName
                                   select bm;
                    var bookmark = res.SingleOrDefault();

                    if (bookmark != null)
                    {
                        var parent = bookmark.Parent;
                        parent.InsertAfterSelf(table);
                    }
                    document.Close();
                }
            }
        }
예제 #27
0
        private static void ApplyFooter(WordprocessingDocument doc)
        {
            // Get the main document part.
            MainDocumentPart mainDocPart = doc.MainDocumentPart;

            FooterPart footerPart1 = mainDocPart.AddNewPart <FooterPart>("r98");



            Footer footer1 = new Footer();

            Table table = new Table();

            TableProperties props = new TableProperties(
                new TableWidth()
            {
                Width = "100%", Type = TableWidthUnitValues.Auto
            });

            props.BiDiVisual = new BiDiVisual();

            table.AppendChild <TableProperties>(props);
            var tr = new TableRow();
            //cell 1
            var tc = new TableCell();

            tc.Append(CreateParagraph("أملاه:	"));
            tc.Append(CreateParagraph("كتبه :	"));
            var tableWidth = new TableCellWidth
            {
                Type  = TableWidthUnitValues.Auto,
                Width = "50%"
            };

            tc.Append(new TableCellProperties(tableWidth));

            //cell 2
            var tc2 = new TableCell();

            tc2.Append(CreateParagraph(" راجع الأمـلاء  :  "));
            tc2.Append(CreateParagraph("راجع الكتابة   : "));
            tc2.Append(CreateParagraph("رئيس لجنة الإدارة         : "));

            var tableWidth2 = new TableCellWidth
            {
                Type  = TableWidthUnitValues.Auto,
                Width = "50%"
            };

            tc2.Append(new TableCellProperties(tableWidth2));


            tr.Append(tc);
            tr.Append(tc2);
            table.Append(tr);

            footer1.Append(table);


            footerPart1.Footer = footer1;



            SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants <SectionProperties>().FirstOrDefault();

            if (sectionProperties1 == null)
            {
                sectionProperties1 = new SectionProperties()
                {
                };
                mainDocPart.Document.Body.Append(sectionProperties1);
            }
            FooterReference footerReference1 = new FooterReference()
            {
                Type = DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues.Default, Id = "r98"
            };


            sectionProperties1.InsertAt(footerReference1, 0);
        }
예제 #28
0
        public TableCell ToTableCell()
        {
            TableCell tableCell = new TableCell();

            TableCellProperties tableCellProperties = new TableCellProperties();

            // Specify the width property of the table cell.
            TableCellWidth tableCellWidth = new TableCellWidth()
            {
                Width = Width.ToString(), Type = TableWidthUnitValues.Dxa
            };

            TableCellMargin tableCellMargin = new TableCellMargin();
            LeftMargin      leftMargin      = new LeftMargin()
            {
                Width = "100", Type = TableWidthUnitValues.Dxa
            };
            RightMargin rightMargin = new RightMargin()
            {
                Width = "100", Type = TableWidthUnitValues.Dxa
            };

            tableCellMargin.Append(leftMargin);
            tableCellMargin.Append(rightMargin);
            TableCellVerticalAlignment tableCellVerticalAlignment = new TableCellVerticalAlignment()
            {
                Val = TableVerticalAlignmentValues.Center
            };

            switch (TipoDeCelula)
            {
            case TipoDeCelula.HEADER:
                tableCellProperties.Append(new Shading()
                {
                    Val = ShadingPatternValues.Percent10, Color = "000000", Fill = "auto"
                });
                break;

            case TipoDeCelula.RESUME:
                tableCellProperties.Append(new Shading()
                {
                    Val = ShadingPatternValues.Percent10, Color = "000000", Fill = "auto"
                });
                break;

            default:     // TipoDeCelula.NORMAL
                break;
            }

            tableCellProperties.Append(tableCellWidth);
            tableCellProperties.Append(tableCellMargin);
            tableCellProperties.Append(tableCellVerticalAlignment);

            switch (Merge)
            {
            case TipoDeMerge.RESTART:
                tableCellProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                break;

            case TipoDeMerge.CONTINUE:
                tableCellProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Continue
                });
                break;

            default:     // TipoDeMerge.NENHUM
                break;
            }

            tableCell.Append(tableCellProperties);

            Paragraph           paragraph           = new Paragraph();
            ParagraphProperties paragraphProperties = new ParagraphProperties();

            switch (Alinhamento)
            {
            case TipoDeAlinhamento.ESQUERDO:
                paragraphProperties.Append(new ParagraphStyleId()
                {
                    Val = "LeftTextTable"
                });
                paragraphProperties.AppendChild(
                    new RunProperties(new Bold()
                {
                    Val = OnOffValue.FromBoolean(true)
                }));
                break;

            case TipoDeAlinhamento.CENTRO:
                paragraphProperties.Append(new ParagraphStyleId()
                {
                    Val = "CenteredTextTable"
                });
                paragraphProperties.AppendChild(
                    new RunProperties(new Bold()
                {
                    Val = OnOffValue.FromBoolean(true)
                }));
                break;

            case TipoDeAlinhamento.DIREITO:
                paragraphProperties.Append(new ParagraphStyleId()
                {
                    Val = "RightTextTable"
                });
                paragraphProperties.AppendChild(
                    new RunProperties(new Bold()
                {
                    Val = OnOffValue.FromBoolean(true)
                }));
                break;

            default:      //TipoDeAlinhamento.NENHUM:
                paragraphProperties.Append(new ParagraphStyleId()
                {
                    Val = "NormalTextTable"
                });
                paragraphProperties.AppendChild(
                    new RunProperties(new Bold()
                {
                    Val = OnOffValue.FromBoolean(true)
                }));
                break;
            }

            paragraph.AppendChild(paragraphProperties);

            foreach (OpenXmlElement run in _runList)
            {
                switch (TipoDeCelula)
                {
                case TipoDeCelula.HEADER:
                    if (!run.Elements <RunProperties>().Any())
                    {
                        run.AppendChild(new RunProperties());
                    }
                    run.Elements <RunProperties>().First().AppendChild(new Bold()
                    {
                        Val = OnOffValue.FromBoolean(true)
                    });
                    break;

                case TipoDeCelula.RESUME:
                    if (!run.Elements <RunProperties>().Any())
                    {
                        run.AppendChild(new RunProperties());
                    }
                    run.Elements <RunProperties>().First().AppendChild(new Italic()
                    {
                        Val = OnOffValue.FromBoolean(true)
                    });
                    run.Elements <RunProperties>().First().AppendChild(new Bold()
                    {
                        Val = OnOffValue.FromBoolean(true)
                    });
                    break;
                }

                paragraph.AppendChild(run);
            }

            // Write some text in the cell.
            tableCell.Append(paragraph);

            return(tableCell);
        }
예제 #29
0
        private Table CreateTable(int? rowCount, int? columnCount)
        {
            //枠線、罫線ありの表を指定の行列分生成する
            int realRowCount = GetRealRowCount(rowCount);
            int realColumnCount = GetRealColumnCount(columnCount);
            Table table = CreateDefaultTable();
            for (int r = 0; r < realRowCount; r++)
            {
                TableRow tableRow = new TableRow();
                table.Append(tableRow);

                for (int c = 0; c < realColumnCount; c++)
                {
                    TableCellProperties tableCellProperties = new TableCellProperties();
                    TableCellWidth tableCellWidth = new TableCellWidth() { Width = BOX_CELL_WIDTH.ToString(), Type = TableWidthUnitValues.Dxa };
                    tableCellProperties.Append(tableCellWidth);

                    TableCell tableCell = new TableCell();
                    tableCell.Append(tableCellProperties);
                    tableCell.Append(new Paragraph());
                    tableRow.Append(tableCell);
                }
            }
            return table;
        }
예제 #30
0
        public static void CreateTable(string fileName)
        {
            // Use the file name and path passed in as an argument
            // to open an existing Word 2007 document.
            using (WordprocessingDocument doc = WordprocessingDocument.Open(fileName, true))
            {
                // Create an empty table.
                Table table = new Table();

                // Create a TableProperties object and specify its border information.
                TableProperties tblProp = new TableProperties(
                    new TableBorders(
                        new TopBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                },
                        new BottomBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                },
                        new LeftBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                },
                        new RightBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                },
                        new InsideHorizontalBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                },
                        new InsideVerticalBorder()
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Dashed),
                    Size = 24
                }
                        )
                    );

                // Append the TableProperties object to the empty table.
                table.AppendChild <TableProperties>(tblProp);

                // Create a row.
                TableRow tr = new TableRow();

                // Create a cell.
                TableCell tc1 = new TableCell();

                // Specify the width property of the table cell.
                tc1.Append(new TableCellProperties(
                               new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "2400"
                }));

                // Specify the table cell content.
                tc1.Append(new Paragraph(new Run(new Text("some text"))));

                // Append the table cell to the table row.
                tr.Append(tc1);

                // Create a second table cell by copying the OuterXml value of the first table cell.
                TableCell tc2 = new TableCell(tc1.OuterXml);

                // Append the table cell to the table row.
                tr.Append(tc2);

                // Append the table row to the table.
                table.Append(tr);

                // Append the table to the document.
                doc.MainDocumentPart.Document.Body.Append(table);
            }
        }
        private static TableRow CreateAdditionalCourseRow(AdditionalCoursesItem additionalCourse)
        {
            TableRow tableRow2 = new TableRow()
            {
                RsidTableRowAddition = "009B2C1D", ParagraphId = "78EC2050", TextId = "77777777"
            };

            TableRowProperties tableRowProperties1 = new TableRowProperties();
            GridAfter          gridAfter1          = new GridAfter()
            {
                Val = 1
            };
            WidthAfterTableRow widthAfterTableRow1 = new WidthAfterTableRow()
            {
                Width = "360", Type = TableWidthUnitValues.Dxa
            };

            tableRowProperties1.Append(gridAfter1);
            tableRowProperties1.Append(widthAfterTableRow1);

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth      tableCellWidth2      = new TableCellWidth()
            {
                Width = "2550", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders2 = new TableCellBorders();
            TopBorder        topBorder3        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder3 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder3 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder3 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders2.Append(topBorder3);
            tableCellBorders2.Append(leftBorder3);
            tableCellBorders2.Append(bottomBorder3);
            tableCellBorders2.Append(rightBorder3);

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(tableCellBorders2);

            Paragraph paragraph2 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "1D1F29ED", TextId = "111BDF87"
            };

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            FontSize      fontSize3      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties3.Append(fontSize3);
            runProperties3.Append(fontSizeComplexScript3);
            Text text3 = new Text()
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            text3.Text = $"{additionalCourse.AmountOfDays} {GetDay(additionalCourse.AmountOfDays)} / {additionalCourse.Year} ";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph2.Append(run3);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph2);

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth      tableCellWidth3      = new TableCellWidth()
            {
                Width = "5700", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders3 = new TableCellBorders();
            TopBorder        topBorder4        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder4 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)1U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder4 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder4 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders3.Append(topBorder4);
            tableCellBorders3.Append(leftBorder4);
            tableCellBorders3.Append(bottomBorder4);
            tableCellBorders3.Append(rightBorder4);

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(tableCellBorders3);

            Paragraph paragraph3 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "4F98306E", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines()
            {
                After = "100", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };
            Indentation indentation1 = new Indentation()
            {
                Left = "144"
            };

            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(indentation1);

            Run run4 = new Run();

            RunProperties runProperties4 = new RunProperties();
            Bold          bold2          = new Bold();
            FontSize      fontSize4      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties4.Append(bold2);
            runProperties4.Append(fontSize4);
            runProperties4.Append(fontSizeComplexScript4);
            Text text4 = new Text();

            text4.Text = additionalCourse.CourseName.ToUpper();

            run4.Append(runProperties4);
            run4.Append(text4);

            paragraph3.Append(paragraphProperties1);
            paragraph3.Append(run4);

            Paragraph paragraph4 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "1C86C2CE", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines()
            {
                After = "100", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };
            Indentation indentation2 = new Indentation()
            {
                Left = "144"
            };

            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(indentation2);

            Run run5 = new Run();

            RunProperties runProperties5 = new RunProperties();
            FontSize      fontSize5      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript5 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties5.Append(fontSize5);
            runProperties5.Append(fontSizeComplexScript5);
            Text text5 = new Text();

            text5.Text = additionalCourse.Instructor;

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph4.Append(paragraphProperties2);
            paragraph4.Append(run5);

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph3);
            tableCell3.Append(paragraph4);

            tableRow2.Append(tableRowProperties1);
            tableRow2.Append(tableCell2);
            tableRow2.Append(tableCell3);

            return(tableRow2);
        }
예제 #32
0
        /// <summary>
        /// Fills in the body element with the provided data.
        /// </summary>
        /// <param name="dataSet">Dataset with the datatables to use to fill the document tables with.  Table names in the dataset should match the table names in the document.</param>
        /// <param name="values">Values to fill the document.  Keys should match the MERGEFIELD names.</param>
        /// <returns>The filled-in document.</returns>
        public static void ProcessBody(WordOpenXmlDocument document, Body body, DataSet dataSet, IDictionary <string, string> values)
        {
            ConvertComplexFieldsToSimpleFields(body);

            #region Process All Tables

            string[] switches = null;
            foreach (var field in body.Descendants <SimpleField>())
            {
                string fieldName = GetFieldName(field, out switches);
                if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_"))
                {
                    var tableRow = GetFirstParent <TableRow>(field);
                    if (tableRow == null)
                    {
                        // can happen because table contains multiple fields, and after 1 pass, the initial row is already deleted
                        continue;
                    }

                    var table = GetFirstParent <Table>(tableRow);
                    if (table == null)
                    {
                        // can happen because table contains multiple fields, and after 1 pass, the initial row is already deleted
                        continue;
                    }

                    string tableName = GetTableNameFromFieldName(fieldName);

                    if (dataSet == null || !dataSet.Tables.Contains(tableName) || dataSet.Tables[tableName].Rows.Count == 0)
                    {
                        // don't remove table here: will be done in next pass
                        continue;
                    }

                    var dataTable = dataSet.Tables[tableName];

                    var cellPropertiesList      = new List <TableCellProperties>();
                    var cellColumnNamesList     = new List <string>();
                    var paragraphPropertiesList = new List <string>();
                    var cellFieldsList          = new List <SimpleField>();

                    foreach (var tableCell in tableRow.Descendants <TableCell>())
                    {
                        cellPropertiesList.Add(tableCell.GetFirstChild <TableCellProperties>());
                        var paragraph = tableCell.GetFirstChild <Paragraph>();
                        if (paragraph != null)
                        {
                            var pp = paragraph.GetFirstChild <ParagraphProperties>();
                            if (pp != null)
                            {
                                paragraphPropertiesList.Add(pp.OuterXml);
                            }
                            else
                            {
                                paragraphPropertiesList.Add(null);
                            }
                        }
                        else
                        {
                            paragraphPropertiesList.Add(null);
                        }

                        string      columnName  = string.Empty;
                        SimpleField columnField = null;
                        foreach (var cellField in tableCell.Descendants <SimpleField>())
                        {
                            columnField = cellField;
                            columnName  = GetColumnNameFromFieldName(GetFieldName(cellField, out switches));
                            break;  // supports only 1 cellfield per table
                        }

                        cellColumnNamesList.Add(columnName);
                        cellFieldsList.Add(columnField);
                    }

                    // keep reference to row properties
                    var rowProperties = tableRow.GetFirstChild <TableRowProperties>();

                    foreach (DataRow dataRow in dataTable.Rows)
                    {
                        var row = new TableRow();

                        if (rowProperties != null)
                        {
                            row.Append(new TableRowProperties(rowProperties.OuterXml));
                        }

                        for (int i = 0; i < cellPropertiesList.Count; i++)
                        {
                            var cellProperties = new TableCellProperties(cellPropertiesList[i].OuterXml);
                            var cell           = new TableCell();
                            cell.Append(cellProperties);
                            var p = new Paragraph(new ParagraphProperties(paragraphPropertiesList[i]));
                            cell.Append(p);   // cell must contain at minimum a paragraph !

                            if (!string.IsNullOrEmpty(cellColumnNamesList[i]))
                            {
                                if (!dataTable.Columns.Contains(cellColumnNamesList[i]))
                                {
                                    throw new Exception(string.Format("Unable to complete template: column name '{0}' is unknown in parameter tables !", cellColumnNamesList[i]));
                                }

                                if (!dataRow.IsNull(cellColumnNamesList[i]))
                                {
                                    string val = dataRow[cellColumnNamesList[i]].ToString();
                                    p.Append(GetRunElementForText(val, cellFieldsList[i]));
                                }
                            }
                            row.Append(cell);
                        }
                        table.Append(row);
                    }

                    // finally : delete template-row (and thus also the mergefields in the table)
                    tableRow.Remove();
                }
            }

            #endregion Process All Tables

            #region Clean Empty Tables

            foreach (var field in body.Descendants <SimpleField>())
            {
                string fieldName = GetFieldName(field, out switches);
                if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_"))
                {
                    var tableRow = GetFirstParent <TableRow>(field);
                    if (tableRow == null)
                    {
                        continue;   // can happen: is because table contains multiple fields, and after 1 pass, the initial row is already deleted
                    }

                    var table = GetFirstParent <Table>(tableRow);
                    if (table == null)
                    {
                        continue;   // can happen: is because table contains multiple fields, and after 1 pass, the initial row is already deleted
                    }

                    string tableName = GetTableNameFromFieldName(fieldName);
                    if (dataSet == null || !dataSet.Tables.Contains(tableName) || dataSet.Tables[tableName].Rows.Count == 0)
                    {
                        // if there's a 'dt' switch: delete Word-table
                        if (switches.Contains("dt"))
                        {
                            table.Remove();
                        }
                    }
                }
            }

            #endregion Clean Empty Tables

            #region Process Remaining Fields In Main Document & Save

            FillWordFieldsInElement(values, body);
            document.Save();  // save main document back in package

            #endregion Process Remaining Fields In Main Document & Save
        }
예제 #33
0
        public static void WDAddTable(string fileName, string[] data1, string[] data2, string[] data3, string[] data4)
        {
            using (var document = WordprocessingDocument.Open(fileName, true))
            {
                var doc = document.MainDocumentPart.Document;

                //DocumentFormat.OpenXml.Wordprocessing.Table table = doc.Body.Elements<DocumentFormat.OpenXml.Wordprocessing.Table>().Where<>.
                DocumentFormat.OpenXml.Wordprocessing.Table table = doc.Body.Elements <DocumentFormat.OpenXml.Wordprocessing.Table>().ElementAtOrDefault(2);

                //    new DocumentFormat.OpenXml.Wordprocessing.Table().First() ;

                //Table table =
                //  doc.MainDocumentPart.Document.Body.Elements<Table>().First();

                TableProperties props = new TableProperties(
                    new TableBorders(
                        new DocumentFormat.OpenXml.Wordprocessing.TopBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                },
                        new DocumentFormat.OpenXml.Wordprocessing.BottomBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                },
                        new DocumentFormat.OpenXml.Wordprocessing.LeftBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                },
                        new DocumentFormat.OpenXml.Wordprocessing.RightBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                },
                        new InsideHorizontalBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                },
                        new InsideVerticalBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.None),
                    Size = 9
                }));
                table.AppendChild <TableProperties>(props);

                for (var i = 0; i <= data1.GetUpperBound(0); i++)
                {
                    var tr = new TableRow(new TableWidth {
                        Type = TableWidthUnitValues.Auto
                    });
                    var tc2 = new TableCell();
                    var tc3 = new TableCell();
                    var tc4 = new TableCell();
                    //for (var j = 0; j <= data.GetUpperBound(1); j++)
                    //{
                    var tc = new TableCell();
                    // Assume you want columns that are automatically sized.
                    if (i == 0)
                    {
                        tc.Append(new TableCellProperties(
                                      new TableCellWidth {
                            Type = TableWidthUnitValues.Auto
                        },
                                      new DocumentFormat.OpenXml.Wordprocessing.Bold(),
                                      new DocumentFormat.OpenXml.Wordprocessing.RunFonts()
                        {
                            Ascii = "Arial"
                        },
                                      new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        },
                                      new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data1[i])),
                                                    new DocumentFormat.OpenXml.Wordprocessing.RunFonts()
                        {
                            Ascii = "Arial"
                        })
                                      ));

                        tr.Append(tc);



                        tc2.Append(new TableCellProperties(
                                       new TableCellWidth {
                            Type = TableWidthUnitValues.Dxa, Width = "350"
                        },
                                       new DocumentFormat.OpenXml.Wordprocessing.Bold(),
                                       new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        }
                                       ));

                        tc3.Append(new TableCellProperties(
                                       new TableCellWidth {
                            Type = TableWidthUnitValues.Dxa, Width = "600"
                        },
                                       new DocumentFormat.OpenXml.Wordprocessing.Bold(),
                                       new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        }
                                       ));
                    }
                    else
                    {
                        tc.Append(new TableCellProperties(
                                      new TableCellWidth {
                            Type = TableWidthUnitValues.Auto
                        },
                                      new DocumentFormat.OpenXml.Wordprocessing.RunFonts()
                        {
                            Ascii = "Arial"
                        },
                                      new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        },
                                      new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data1[i])),
                                                    new DocumentFormat.OpenXml.Wordprocessing.RunFonts()
                        {
                            Ascii = "Arial"
                        })
                                      ));

                        tr.Append(tc);



                        tc2.Append(new TableCellProperties(
                                       new TableCellWidth {
                            Type = TableWidthUnitValues.Dxa, Width = "350"
                        },
                                       new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        }
                                       ));

                        tc3.Append(new TableCellProperties(
                                       new TableCellWidth {
                            Type = TableWidthUnitValues.Dxa, Width = "600"
                        },
                                       new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                        {
                            Val = "9"
                        }
                                       ));
                    }
                    //tc.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data1[i]))),
                    //    new TableCellProperties(
                    //                              new TableCellWidth { Type = TableWidthUnitValues.Dxa, Width = "500" },
                    //                               new DocumentFormat.OpenXml.Wordprocessing.FontSize() { Val = "9" }
                    //                               )
                    //    );
                    //tr.Append(tc);


                    tc2.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data2[i]))));
                    // Assume you want columns that are automatically sized.
                    tr.Append(tc2);


                    tc3.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data3[i]))));
                    // Assume you want columns that are automatically sized.

                    tr.Append(tc3);

                    tc4.Append(new TableCellProperties(
                                   new TableCellWidth {
                        Type = TableWidthUnitValues.Auto
                    },
                                   new DocumentFormat.OpenXml.Wordprocessing.Bold(),
                                   new DocumentFormat.OpenXml.Wordprocessing.RunFonts()
                    {
                        Ascii = "Arial"
                    },
                                   new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                    {
                        Val = "9"
                    },
                                   new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data4[i])))
                                   ));

                    tr.Append(tc4);
                    // }
                    table.Append(tr);
                }
                //  doc.Body.Append(table);
                doc.Save();
            }
        }
예제 #34
0
        private TableCell PrepareCell(string text, int width, bool centre = true, int mergeCount = 0)
        {
            var tc = new TableCell();

            TableCellProperties props = new TableCellProperties(
                new TableCellWidth {
                Width = width.ToString()
            },
                new TableCellMargin(
                    new BottomMargin {
                Width = "30"
            },
                    new TopMargin {
                Width = "30"
            },
                    new LeftMargin {
                Width = "30"
            },
                    new RightMargin {
                Width = "30"
            }
                    ),
                new TableCellVerticalAlignment {
                Val = TableVerticalAlignmentValues.Center
            }
                );

            if (mergeCount > 0)
            {
                props.Append(new GridSpan {
                    Val = mergeCount
                });
            }
            ;
            tc.AppendChild <TableCellProperties>(props);

            if (centre)
            {
                ParagraphProperties pprop         = new ParagraphProperties();
                Justification       CenterHeading = new Justification()
                {
                    Val = JustificationValues.Center
                };
                pprop.Append(CenterHeading);
                tc.AppendChild <ParagraphProperties>(pprop);
            }
            ;

            RunProperties runProperties = new RunProperties();
            FontSize      fs            = new FontSize();

            fs.Val = "20";
            runProperties.AppendChild(fs);
            Run run = new Run();

            run.AppendChild(runProperties);
            run.AppendChild(new Text(text));

            tc.Append(new Paragraph(run));

            return(tc);
        }
예제 #35
0
        public static void Find_table(List <List <string> > List1, string path1, string path2)
        {
            List <string> Tables  = new List <string>();
            int           flazhok = 0;
            int           fcount  = 0;
            int           k       = 0;

            byte[]        byteArray = File.ReadAllBytes(path1);
            List <string> M         = new List <string>();
            int           u         = 0;
            int           m         = 0;

            using (MemoryStream mem = new MemoryStream())
            {
                mem.Write(byteArray, 0, (int)byteArray.Length);



                using (WordprocessingDocument outDoc = WordprocessingDocument.Open(mem, true))
                {
                    var doc = outDoc.MainDocumentPart.Document;

                    MainDocumentPart mainPart = outDoc.MainDocumentPart;


                    DocDefaults defaults = doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <DocDefaults>().FirstOrDefault();

                    RunFonts runFont = defaults.RunPropertiesDefault.RunPropertiesBaseStyle.RunFonts;
                    runFont.Ascii = "Calibri";
                    //runFont.AsciiTheme = "Times New Roman";
                    string   font = runFont.Ascii;
                    FontSize fs   = new FontSize();
                    fs.Val = "8";
                    string[] tblTag = new string[0];//Табличные теги

                    for (int f1 = 0; f1 < List1.Count; f1++)
                    {
                        flazhok = 0;
                        Array.Resize(ref tblTag, tblTag.Length + 1);

                        fcount = 0;
                        int i = 0;



                        tblTag[i] = List1[k][fcount].ToString();
                        m         = k;
                        fcount++;
                        i++;



                        var ccWithTable1 = mainPart.Document.Body.Descendants <SdtElement>();


                        bool     b           = true;
                        SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().FirstOrDefault();

                        int index = 0;



                        foreach (var tt in ccWithTable1)
                        {
                            if (tt.SdtProperties.GetFirstChild <Tag>().Val == tblTag[index])
                            {
                                ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where
                                                  (r => r.SdtProperties.GetFirstChild <Tag>().Val == tblTag[index]).Single();

                                Tables.Add(tblTag[index]);
                                flazhok = 1;
                                break;
                            }
                        }
                        int count = 0;
                        int countt = 0;
                        int r2 = 3; int n = 0;
                        var tr2 = new TableRow(); var tr3 = new TableRow();
                        if (flazhok == 1)
                        {
                            int struct2 = 0;
                            for (int u23 = 1; u23 < List1[k].Count; u23++)
                            {
                                if (u23 >= 15 + struct2)
                                {
                                    countt++;
                                    struct2 += 15;
                                }
                            }

                            int   f5 = 0; int f6 = 0;
                            Table theTable = ccWithTable.Descendants <Table>().FirstOrDefault();

                            TableRow row8 = theTable.Elements <TableRow>().ElementAt(r2);



                            theTable.InsertAfter <TableRow>(tr2, row8);
                            int county = 0;
                            int u2     = 1;
                            int u233   = 1;
                            int u234   = 1;

                            fs.Val = "16";

                            for (int u23 = 0; u23 < countt; u23++)
                            {
                                if (u23 != 0)
                                {
                                    u233 = u2 + 1;
                                    u234 = u233 - 1;
                                }
                                county = 0;
                                for (u2 = 1; u2 < List1[0].Count(); u2++)
                                {
                                    u2 = u233;
                                    if (u2 > 15)
                                    {
                                        if (county == 0)
                                        {
                                            {
                                                u233 = u233 - 1;
                                            }
                                        }
                                    }
                                    county++;
                                    u233++;
                                    b = true;

                                    if (u2 >= u234 + 15)
                                    {
                                        break;
                                    }

                                    else
                                    {
                                        b = false;



                                        int i3 = 0;
                                        int i8 = 3;
                                        int y  = 0;
                                        int b3 = 0;

                                        int c = 0;
                                        M.Clear();
                                        //TableRow row2 = theTable.Elements<TableRow>().ElementAt(i8);

                                        TableCell cell = tr2.Elements <TableCell>().FirstOrDefault();



                                        int[] gridSpan1 = null;
                                        gridSpan1 = new int[] { 1, 7 };
                                        TableCellProperties tcp3 = new TableCellProperties(new GridSpan()
                                        {
                                            Val = gridSpan1[b3]
                                        }); b3++;



                                        TableCell cell2 = new TableCell();

                                        cell2.Append(new Paragraph
                                                         (new Run(new Text(""))));
                                        tr2.AppendChild(cell2);

                                        /*
                                         *   Paragraph p3 = cell2.Elements<Paragraph>().First();
                                         *   Run t2 = p3.Elements<Run>().First();
                                         *   RunProperties rPr2 = new RunProperties(
                                         *  new RunFonts()
                                         *  {
                                         *      Ascii = font,
                                         *      HighAnsi = font
                                         *  },
                                         *
                                         *                 new FontSize()
                                         *                 {
                                         *                     Val = fs.Val
                                         *                 });
                                         *
                                         *   t2.PrependChild<RunProperties>(rPr2);
                                         *
                                         */



                                        if (b == false)
                                        {
                                            if (u2 >= u234 + 15 - 1 && u2 != List1[0].Count - 1)
                                            {
                                                n   = 14;
                                                tr2 = new TableRow();
                                                r2++;
                                                row8 = theTable.Elements <TableRow>().ElementAt(r2);

                                                theTable.InsertAfter <TableRow>(tr2, row8);
                                            }
                                        }
                                        else
                                        {
                                            if (u2 != List1[0].Count() - 1)
                                            {
                                                if (u2 >= 16 + n)
                                                {
                                                    n   = n + 15;
                                                    tr2 = new TableRow();
                                                    r2++;
                                                    row8 = theTable.Elements <TableRow>().ElementAt(r2);

                                                    theTable.InsertAfter <TableRow>(tr2, row8);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        int n18 = 0;
                        int tyacheika = 1; int count7 = 0;
                        Dictionary <int, int> d3 = new Dictionary <int, int>();

                        for (tyacheika = 1; tyacheika < List1[0].Count(); tyacheika++)
                        {
                            d3.Add(tyacheika + n18, n18 + 15 + tyacheika - 1);

                            n18 += 14;
                        }


                        Table theTable2         = ccWithTable.Descendants <Table>().FirstOrDefault();
                        Dictionary <int, int> d = new Dictionary <int, int>();
                        int g = 0;
                        TableCellProperties tcp1 = new TableCellProperties();
                        List <int>          l    = new List <int>();
                        int n15 = 0;

                        int yy     = 1;
                        int prt    = 1;
                        int lcount = 1;
                        int t16    = 0;
                        int t17    = 0;

                        bool flag = true;
                        int  ff = 0;  int ff2 = 0;
                        int  yacheika1 = 1;
                        int  perv      = 0;
                        int  count55   = 0;
                        int  yperv     = 0;
                        bool flazhok2  = true;
                        prt = yacheika1;
                        int ccount = 0;
                        prt = yy;
                        bool nk   = true;
                        int  nor2 = 0;
                        int  nor  = 0;
                        for (int yacheika12 = 1; yacheika12 < List1[0].Count(); yacheika12++)
                        {
                            if (perv >= 16)
                            {
                                break;
                            }
                            g   = 0;
                            t16 = 0;
                            if (flazhok2 == false)
                            {
                                g          = ff;
                                yacheika12 = ff2;
                                n15        = nor;
                                t16        = t17;
                            }


                            if (flag == false)
                            {
                                perv++;
                                yacheika12 = perv;
                                count55    = 0;
                            }

                            for (yacheika1 = yacheika12; yacheika1 < List1[0].Count(); yacheika1++)
                            {
                                yacheika12++;
                                if (yacheika1 == 10)
                                {
                                }
                                if (count55 == 0)
                                {
                                    perv = yacheika1;
                                }
                                count55++;
                                flag = true;
                                if (g > 15)
                                {
                                    break;
                                }
                                flazhok2 = true;

                                t16++;
                                t17 = t16;
                                ff  = g;

                                ff2 = yacheika1;

                                if (n15 + 15 + yacheika1 >= List1[0].Count())
                                {
                                    flag = false;
                                    break;
                                }
                                string k4 = List1[0][yacheika1 + n15];
                                string k5 = List1[0][n15 + 15 + yacheika1];
                                string oneone = ""; string twotwo = "";
                                string one1 = List1[0][yacheika1 + n15];
                                string one2 = List1[0][n15 + 15 + yacheika1 - 1];
                                bool   ka   = true;



                                if (n15 + 15 + yacheika1 <= List1[0].Count() - 1)
                                {
                                    if (List1[0][yacheika1 + n15] != List1[0][n15 + 15 + yacheika1])
                                    {
                                        n15     += 15;
                                        nor      = n15;
                                        nk       = false;
                                        flazhok2 = false;
                                        yperv    = perv;
                                        break;
                                    }


                                    g++;


                                    if (n15 + 15 + yacheika1 <= List1[0].Count() - 1)
                                    {
                                        foreach (var pair in d3)
                                        {
                                            if (pair.Key <= yacheika1 + n15 && yacheika1 + n15 <= pair.Value)
                                            {
                                                oneone = pair.Key.ToString();
                                                break;
                                            }
                                        }


                                        foreach (var pair1 in d3)
                                        {
                                            if (pair1.Key <= n15 + 15 + yacheika1 - 1 && n15 + 15 + yacheika1 - 1 <= pair1.Value)
                                            {
                                                twotwo = pair1.Key.ToString();
                                                break;
                                            }
                                        }

                                        bool flag33 = true;
                                        if (List1[0][Convert.ToInt32(oneone)] != List1[0][Convert.ToInt32(twotwo)])
                                        {
                                            flag33 = false;


                                            nk = true;

                                            n15 += 15;
                                            nor  = n15;

                                            flazhok2 = false;

                                            break;
                                        }

                                        if (List1[0][yacheika1 + n15] == List1[0][n15 + 15 + yacheika1])
                                        {
                                            if (flag33 != false)
                                            {
                                                l.Add(t16 - 1 + 4);


                                                l.Add(t16 + 5 - 1);
                                                n15 += 14;

                                                nor = n15;
                                                nk  = true;
                                            }
                                        }
                                    }
                                }
                            }


                            n15 = 0;

                            for (int i1 = 0; i1 < l.Count; i1++)
                            {
                                if (!d.ContainsKey(l[i1]))
                                {
                                    d.Add(l[i1], l[i1]);
                                }
                            }

                            bool       kas  = true;
                            List <int> list = new List <int>(d.Keys);
                            bool       yp   = true;
                            if (list.Count != 0)
                            {
                                for (int i1 = 0; i1 < list.Count(); i1++)
                                {
                                    if (list[i1] >= 18)
                                    {
                                        if (list[i1] >= 18)
                                        {            /*
                                                      * list.Remove(list[i1]);
                                                      * */
                                            yp = false;
                                        }
                                    }
                                }

                                /*
                                 * kas = false;
                                 * l.Clear();
                                 * list.Clear();
                                 * d.Clear();
                                 * */



                                if (kas == true)
                                {
                                    if (perv < 16)
                                    {
                                        int yacheika = 0;
                                        //  List<int> list = new List<int>(d.Keys);
                                        yacheika = yacheika1;


                                        /*
                                         * if (yp == false)
                                         * {*/

                                        tcp1 = new TableCellProperties(

                                            new VerticalMerge()
                                        {
                                            Val = MergedCellValues.Restart
                                        }
                                            );
                                        theTable2.Elements <TableRow>().ElementAt(list[0]).ElementAt(perv - 1).Append(tcp1);

                                        for (int t = 1; t < list.Count; t++)
                                        {
                                            TableCellProperties tcp11 = new TableCellProperties(

                                                new VerticalMerge()
                                            {
                                                Val = MergedCellValues.Continue
                                            }
                                                );


                                            theTable2.Elements <TableRow>().ElementAt(list[t]).ElementAt(perv - 1).Append(tcp11);
                                        }
                                    }

                                    /*
                                     * else
                                     * {
                                     *
                                     *  for (int t = 1; t < list.Count; t++)
                                     *  {
                                     *      TableCellProperties tcp11 = new TableCellProperties(
                                     *
                                     *      new VerticalMerge()
                                     *      {
                                     *          Val = MergedCellValues.Continue
                                     *      }
                                     *       );
                                     *      theTable2.Elements<TableRow>().ElementAt(list[t]).ElementAt(perv - 1).Append(tcp11);
                                     *
                                     *  }
                                     * // }
                                     * /*
                                     *
                                     *
                                     *                                                  for (int t = 1; t < list.Count - 1; t++)
                                     *  {
                                     *      TableCellProperties tcp11 = new TableCellProperties(
                                     *
                                     *      new VerticalMerge()
                                     *      {
                                     *          Val = MergedCellValues.Continue
                                     *      }
                                     *       );
                                     *
                                     */
                                    // theTable2.Elements<TableRow>().ElementAt(list[t]).ElementAt(perv - 1).Append(tcp11);
                                }



                                l.Clear();

                                d.Clear();
                            }
                        }

                        //  theTable2.Elements<TableRow>().ElementAt(theTable2.Elements<TableRow>().Count() - 1).Remove();
                    }
                }



                /*
                 * TableCellProperties tcp10 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Restart
                 * }
                 * );
                 * int t = d[l[0]];
                 * theTable.Elements<TableRow>().ElementAt(d[l[1]]).Elements<TableCell>().ElementAt(yacheika).Append(tcp10);
                 *
                 *
                 */

                //TableRow r23 = theTable.Elements<TableRow>().ElementAt(row1);

                /*
                 *          if (flag != false)
                 *          {
                 *              if (list.Count != 0)
                 *              {
                 *                  TableCellProperties tcp1 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 *     Val = MergedCellValues.Restart
                 * }
                 *  );
                 *                  theTable.Elements<TableRow>().ElementAt(list[0]).ElementAt(yacheika1).Append(tcp1);
                 *
                 *                  for (int i11 = 1; i11 < d.Count; i11++)
                 *                  {
                 *                      TableCellProperties tcp11 = new TableCellProperties(
                 *
                 *     new VerticalMerge()
                 *     {
                 *         Val = MergedCellValues.Continue
                 *     }
                 *      );
                 *
                 *
                 *                      theTable.Elements<TableRow>().ElementAt(list[i11]).ElementAt(yacheika1).Append(tcp11);
                 *
                 *                  }
                 *              }
                 *
                 *          }
                 *          d.Clear();
                 *
                 *      }
                 *
                 *  }
                 *
                 *
                 *  /*
                 * TableCellProperties tcp11 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Restart
                 * }
                 * );
                 *  theTable.Elements<TableRow>().ElementAt(d[l[1]]).Elements<TableCell>().ElementAt(yacheika).Append(tcp11);
                 *
                 *
                 *
                 *  TableCellProperties tcp12 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Continue
                 * }
                 * );
                 *  theTable.Elements<TableRow>().ElementAt(d[l[2]]).ElementAt(yacheika).Append(tcp12);
                 * }
                 */



                /*
                 *
                 *                   for (int u2 = 1; u2 < List1[k].Count; u2++)
                 *                {
                 *
                 *                  if (theTable.Elements<TableRow>().ElementAt(u2-1) == theTable.Elements<TableRow>().ElementAt(u2))
                 *                      {
                 *                          TableCellProperties tcp10 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Restart
                 * }
                 * );
                 *
                 *                          TableCell cl = new TableCell();
                 *                          cl = tr2.Elements<TableCell>().ElementAt(u2);
                 *
                 *                          theTable.Elements<TableRow>().ElementAt(u2).Elements<TableCell>().ElementAt(u2).Append(tcp10);
                 *                         cl= theTable.Elements<TableRow>().ElementAt(u2).Elements<TableCell>().ElementAt(u2);
                 *                      }
                 *                  }
                 *
                 *              }
                 *
                 *
                 *
                 */



                /*
                 *
                 * for (int u3 = 5; u3 < theTable.Elements<TableRow>().Count(); u3++)
                 * {
                 *  TableRow tr5 = theTable.Elements<TableRow>().ElementAt(u3);
                 * string d= theTable.Elements<TableRow>().ElementAt(u3).InnerText;
                 * for (int u4 = 0; u4 < tr5.Elements<TableCell>().Count(); u4++)
                 * {
                 *
                 *     TableRow tr = theTable.Elements<TableRow>().ElementAt(u3);
                 *     TableCell tc12 = tr.Elements<TableCell>().ElementAt(u4);
                 *     string text = theTable.Elements<TableRow>().ElementAt(u3).ElementAt(u4).InnerText;
                 *     string text2 = theTable.Elements<TableRow>().ElementAt(u3 - 1).ElementAt(u4).InnerText;
                 *
                 *     if (text == text2)
                 *     {
                 *
                 *         count++;
                 *     }}}
                 *
                 *
                 *
                 *
                 *
                 *
                 * int schet = 0;
                 * for (int u3 = 5; u3 < theTable.Elements<TableRow>().Count(); u3++)
                 * {
                 *  TableRow tr5 = theTable.Elements<TableRow>().ElementAt(u3);
                 * string d= theTable.Elements<TableRow>().ElementAt(u3).InnerText;
                 * for (int u4 = 0; u4 < tr5.Elements<TableCell>().Count(); u4++)
                 * {
                 *
                 *     TableRow tr = theTable.Elements<TableRow>().ElementAt(u3);
                 *     TableCell tc12 = tr.Elements<TableCell>().ElementAt(u4);
                 *     string text = theTable.Elements<TableRow>().ElementAt(u3).ElementAt(u4).InnerText;
                 *     string text2 = theTable.Elements<TableRow>().ElementAt(u3 - 1).ElementAt(u4).InnerText;
                 *
                 *     if (text == text2)
                 *     {
                 *
                 *         count++;
                 *
                 *
                 *         string c1 = theTable.Elements<TableRow>().ElementAt(u3).Elements<TableCell>().ElementAt(u4).InnerText;
                 *
                 *
                 *
                 *
                 *
                 *
                 *
                 *
                 *
                 *
                 *         TableCellProperties tcp10 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Restart
                 * }
                 * );
                 *
                 *
                 *         theTable.Elements<TableRow>().ElementAt(u3 - 2).ElementAt(u4).Append(tcp10);
                 *
                 *
                 *
                 *
                 *
                 *
                 *         TableCellProperties tcp1 = new TableCellProperties(
                 *
                 * new VerticalMerge()
                 * {
                 * Val = MergedCellValues.Continue
                 * }
                 * );
                 *         theTable.Elements<TableRow>().ElementAt(u3).ElementAt(u4).Append(tcp1);
                 *         // tc12 = theTable.Elements<TableRow>().ElementAt(u3).Elements<TableCell>().ElementAt(u4);
                 *
                 *
                 *     }
                 * }
                 *
                 *
                 *
                 */



                try
                {
                    File.Delete(path2);


                    using (FileStream fileStream = new FileStream(path2,
                                                                  System.IO.FileMode.CreateNew))
                    {
                        mem.WriteTo(fileStream);
                    }
                }


                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public ITableCell CreateTableCell(IList <IRun> cellContents, TableCellPropertiesModel cellModel)
        {
            if (cellContents == null)
            {
                throw new ArgumentNullException("cellContents must not be null");
            }
            if (cellContents.Count == 0)
            {
                throw new ArgumentNullException("cellContents must not be an empty list");
            }
            if (cellContents.Any(e => e == null))
            {
                throw new ArgumentNullException("All elements of cellContents must be not null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            var platformCellTable = PlatformTableCell.New();

            if (cellModel != null)
            {
                AutoMapper.Mapper.Map(cellModel, platformCellTable.Properties);
            }

            TableCell tc = platformCellTable.ContentItem as TableCell;

            var tableCellProperties = platformCellTable.Properties.ContentItem as TableCellProperties;

            tableCellProperties.Append(new TableCellVerticalAlignment {
                Val = (DocumentFormat.OpenXml.Wordprocessing.TableVerticalAlignmentValues)(int) cellModel.TableVerticalAlignementValues
            });

            // Modification de la rotation du texte dans la cellule
            if (cellModel.TextDirectionValues.HasValue)
            {
                tableCellProperties.Append(new TextDirection {
                    Val = cellModel.TextDirectionValues.ToOOxml()
                });
            }

            Paragraph           par = new Paragraph();
            ParagraphProperties pr  = new ParagraphProperties();

            //new SpacingBetweenLines() { After = cellModel.SpacingAfter, Before = cellModel.SpacingBefore, Line = "240" });

            if (cellModel.Justification.HasValue)
            {
                pr.Append(new Justification()
                {
                    Val = cellModel.Justification.Value.ToOOxml()
                });
            }

            if (cellModel.ParagraphSolidarity)
            {
                pr.Append(new KeepNext());
            }
            par.Append(pr);

            for (int i = 0; i < cellContents.Count; i++)
            {
                par.Append(cellContents[i].ContentItem as Run);
            }

            tc.Append(par);

            return(new PlatformTableCell(tc));
        }
예제 #37
0
        private static void AddTable(string fileName, string[,] data)
        {
            using (var document = WordprocessingDocument.Open(fileName, true))
            {

                var doc = document.MainDocumentPart.Document;

                Table table = new Table();

                TableProperties props = new TableProperties(
                    new TableBorders(
                    new TopBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    },
                    new BottomBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    },
                    new LeftBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    },
                    new RightBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    },
                    new InsideHorizontalBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    },
                    new InsideVerticalBorder
                    {
                        Val = new EnumValue<BorderValues>(BorderValues.Single),
                        Size = 12
                    }));

                table.AppendChild<TableProperties>(props);

                for (var i = 0; i <= data.GetUpperBound(0); i++)
                {
                    var tr = new TableRow();
                    for (var j = 0; j <= data.GetUpperBound(1); j++)
                    {
                        var tc = new TableCell();
                        tc.Append(new Paragraph(new Run(new Text(data[i, j]))));

                        // Assume you want columns that are automatically sized.
                        tc.Append(new TableCellProperties(
                            new TableCellWidth { Type = TableWidthUnitValues.Auto }));

                        tr.Append(tc);
                    }
                    table.Append(tr);
                }
                doc.Body.Append(table);
                doc.Save();
            }
        }
예제 #38
0
        public void Export(string targetPath)
        {
            using (this.m_Document = WordprocessingDocument.CreateFromTemplate(this.TemplatePath))
            {
                var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().UseGridTables().UsePipeTables().Build();
                var markdown = Markdown.Parse(this.Source, pipeline);

                foreach (Block block in markdown)
                {
                    if (block is HeadingBlock)
                    {
                        HeadingBlock b = block as HeadingBlock;
                        string       s = "";
                        foreach (Inline run in b.Inline)
                        {
                            s += this.Source.Substring(run.Span.Start, run.Span.Length);
                        }

                        this.m_Document.MainDocumentPart.Document.Body.Append(this.MakeHeaderParagprah(s.ToString(), b.Level));
                    }

                    if (block is ParagraphBlock)
                    {
                        this.m_Document.MainDocumentPart.Document.Body.Append(this.ParseParagaph(block as ParagraphBlock));
                    }

                    if (block is ListBlock)
                    {
                        this.m_Document.MainDocumentPart.Document.Body.Append(this.ParseList(block as ListBlock));
                    }

                    if (block is Markdig.Extensions.Tables.Table)
                    {
                        //TODO Header row

                        Markdig.Extensions.Tables.Table b = block as Markdig.Extensions.Tables.Table;
                        Table table = this.MakeTable();

                        foreach (Block rowBlock in b)
                        {
                            Markdig.Extensions.Tables.TableRow mdRow = rowBlock as Markdig.Extensions.Tables.TableRow;
                            TableRow row = this.MakeTableRow();

                            foreach (Block cellBlock in mdRow)
                            {
                                Markdig.Extensions.Tables.TableCell mdCell = cellBlock as Markdig.Extensions.Tables.TableCell;
                                TableCell cell = this.MakTableCell();

                                foreach (Block content in mdCell)
                                {
                                    if (content is ParagraphBlock)
                                    {
                                        cell.Append(this.ParseParagaph(content as ParagraphBlock));
                                    }
                                }
                                if (mdCell.Count == 0)
                                {
                                    cell.Append(this.MakeParagraph());
                                }
                                row.Append(cell);
                            }
                            table.Append(row);
                        }

                        this.m_Document.MainDocumentPart.Document.Body.Append(table);
                    }

                    if (block is BlockQuote)
                    {
                    }

                    if (block is CodeBlock)
                    {
                    }
                }

                this.m_Document.PackageProperties.Creator     = this.DocumentInfo.First(di => di.Name == "Creator").Value;
                this.m_Document.PackageProperties.Category    = this.DocumentInfo.First(di => di.Name == "Category").Value;
                this.m_Document.PackageProperties.Description = this.DocumentInfo.First(di => di.Name == "Description").Value;
                this.m_Document.PackageProperties.Subject     = this.DocumentInfo.First(di => di.Name == "Subject").Value;
                this.m_Document.PackageProperties.Title       = this.DocumentInfo.First(di => di.Name == "Title").Value;

                //// Save changes to the main document part.
                this.m_Document.MainDocumentPart.Document.Save();

                var doc2 = this.m_Document.SaveAs(targetPath) as WordprocessingDocument;

                doc2.MainDocumentPart.DocumentSettingsPart.Settings.PrependChild <UpdateFieldsOnOpen>(new UpdateFieldsOnOpen()
                {
                    Val = new OnOffValue(true)
                });
                doc2.MainDocumentPart.DocumentSettingsPart.Settings.Save();

                this.m_Document.Close();
                doc2.Close();
            }
        }
        private void Generate()
        {
            Table table = this.CreateTable();

            var documentTemplates = this.templates.Where(y => y.PrimaryContextType == "ClinicalDocument").OrderBy(y => y.Name);
            var sectionTemplates  = this.templates.Where(y => y.PrimaryContextType == "Section").OrderBy(y => y.Name);

            foreach (var documentTemplate in documentTemplates)
            {
                TableRow row = new TableRow(new TableRowProperties());
                table.Append(row);

                TableCell docTypeCell = new TableCell(new TableCellProperties());
                row.Append(docTypeCell);

                Paragraph docTypePara = new Paragraph();
                docTypeCell.Append(docTypePara);

                this.hyperlinkTracker.AddHyperlink(docTypePara, documentTemplate.Name, documentTemplate.Bookmark, Properties.Settings.Default.LinkStyle);
                docTypePara.Append(new Break(), DocHelper.CreateRun(documentTemplate.Oid));

                var requiredSections = (from tc in documentTemplate.ChildConstraints
                                        join tcr in this.tdb.TemplateConstraintReferences on tc.Id equals tcr.TemplateConstraintId
                                        join st in this.templates on tcr.ReferenceIdentifier equals st.Oid
                                        join ptc in documentTemplate.ChildConstraints on tc.ParentConstraintId equals ptc.Id
                                        where
                                        tc.Context == "section" &&
                                        tcr.ReferenceType == ConstraintReferenceTypes.Template &&
                                        ptc.Context == "component" &&
                                        (ptc.Conformance == "SHALL" || ptc.Conformance == "SHALL NOT")
                                        select st).ToList();

                var optionalSections = (from tc in documentTemplate.ChildConstraints
                                        join tcr in this.tdb.TemplateConstraintReferences on tc.Id equals tcr.TemplateConstraintId
                                        join st in this.templates on tcr.ReferenceIdentifier equals st.Oid
                                        join ptc in documentTemplate.ChildConstraints on tc.ParentConstraintId equals ptc.Id
                                        where
                                        tc.Context == "section" &&
                                        tcr.ReferenceType == ConstraintReferenceTypes.Template &&
                                        ptc.Context == "component" &&
                                        (ptc.Conformance.StartsWith("SHOULD") || ptc.Conformance.StartsWith("MAY"))
                                        select st).ToList();

                TableCell requiredSectionsCell = new TableCell(new TableCellProperties());
                row.Append(requiredSectionsCell);

                Paragraph requiredSectionsPara = new Paragraph();
                requiredSectionsCell.Append(requiredSectionsPara);

                for (int i = 0; i < requiredSections.Count; i++)
                {
                    this.hyperlinkTracker.AddHyperlink(requiredSectionsPara, requiredSections[i].Name, requiredSections[i].Bookmark, Properties.Settings.Default.LinkStyle);

                    if (i != requiredSections.Count - 1)
                    {
                        requiredSectionsPara.Append(new Break());
                    }
                }

                if (requiredSections.Count == 0)
                {
                    requiredSectionsPara.Append(DocHelper.CreateRun("N/A"));
                }

                TableCell optionalSectionsCell = new TableCell(new TableCellProperties());
                row.Append(optionalSectionsCell);

                Paragraph optionalSectionsPara = new Paragraph();
                optionalSectionsCell.Append(optionalSectionsPara);

                for (int i = 0; i < optionalSections.Count; i++)
                {
                    this.hyperlinkTracker.AddHyperlink(optionalSectionsPara, optionalSections[i].Name, optionalSections[i].Bookmark, Properties.Settings.Default.LinkStyle);

                    if (i != optionalSections.Count - 1)
                    {
                        optionalSectionsPara.Append(new Break());
                    }
                }

                if (optionalSections.Count == 0)
                {
                    optionalSectionsPara.Append(DocHelper.CreateRun("N/A"));
                }
            }
        }
예제 #40
0
        public TableRow GenerateTableRow(CellProps[] cellProps, UInt32Value height)
        {
            TableRow tableRow1 = new TableRow();
            TableRowProperties tableRowProperties1 = generateTableRowProperties(height);
            tableRow1.Append(tableRowProperties1);

            foreach (CellProps cp in cellProps) {
                if (cp.span == 0) continue;
                TableCell tableCell1 = new TableCell();
                TableCellProperties tableCellProperties1 = new TableCellProperties();

                TableCellBorders tableCellBorders1 = generateTableCellBordersPlain();
                Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };
                NoWrap noWrap1 = new NoWrap();
                TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };
                HideMark hideMark1 = new HideMark();

                if (cp.span > 1) {
                    GridSpan span = new GridSpan() { Val = (Int32Value)cp.span };
                    tableCellProperties1.Append(span);
                }

                tableCellProperties1.Append(tableCellBorders1);
                tableCellProperties1.Append(shading1);
                tableCellProperties1.Append(noWrap1);
                tableCellProperties1.Append(tableCellVerticalAlignment1);
                tableCellProperties1.Append(hideMark1);

                Paragraph paragraph1 = new Paragraph();

                ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                Justification justification1 = new Justification() { Val = cp.align };

                ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
                FontSize fontSize1 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "18" };

                paragraphMarkRunProperties1.Append(fontSize1);
                paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

                paragraphProperties1.Append(justification1);
                paragraphProperties1.Append(paragraphMarkRunProperties1);

                Run run1 = new Run();

                RunProperties runProperties1 = new RunProperties();
                FontSize fontSize2 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "18" };

                runProperties1.Append(fontSize2);
                runProperties1.Append(fontSizeComplexScript2);

                run1.Append(runProperties1);
                if (cp.text != null) {
                    Text text1 = new Text();
                    text1.Text = cp.text;
                    run1.Append(text1);
                }

                paragraph1.Append(paragraphProperties1);
                paragraph1.Append(run1);

                tableCell1.Append(tableCellProperties1);
                tableCell1.Append(paragraph1);
                tableRow1.Append(tableCell1);

            }

            return tableRow1;
        }
예제 #41
0
        private void GenerateChapterFourTable1()
        {
            var chapterFour = (ChapterFour)_sessionObjects.ChapterFour;
            var discipline = (Discipline)_additionalObjects.Discipline;

            var paraProp = new ParagraphProperties();
            var paragraph = new Paragraph();
            var runProp = new RunProperties();
            var run = new Run();
            var runs = new List<Run>();

            var table = new Table();
            table.Append(GenerateTableProperties());

            var tableGrid1 = new TableGrid();
            for (var i = 0; i < chapterFour.AuditoriumHours.Columns.Count + 1; i++)
            {
                var gridColumn1 = new GridColumn();
                if (i == 0)
                {
                    gridColumn1.Width = "4536";

                }
                else
                {
                    gridColumn1.Width = "1200";
                }
                tableGrid1.Append(gridColumn1);
            }
            table.Append(tableGrid1);

            #region Шапка
            #region row
            var tableRow = new TableRow();

            #region cell
            var tableCell = new TableCell();
            TableCellProperties tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            var justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text("Вид учебной работы"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text("Всего зачетных единиц / часов"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new GridSpan() { Val = 2 });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
                Italic = new Italic()
            };
            run.Append(runProp);
            run.Append(new Text("Семестр"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            var tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for(var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold(),
                    Italic = new Italic()
                };
                run.Append(runProp);
                run.Append(new Text(discipline.Semesters[i].Number.ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Italic = new Italic()
                };
                run.Append(runProp);
                run.Append(new Text("з.е. / час."));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion
            #endregion

            #region Аудиторные занятия
            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            run.Append(new Text("Аудиторные занятия (всего)"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            var str = GetStringHoursAndCreditUnits(discipline.TotalHours - discipline.IndependentWork);
            run.Append(new Text(str));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold()
                };
                run.Append(runProp);
                str = GetStringHoursAndCreditUnits( discipline.Semesters[i].TotalHours - discipline.Semesters[i].Independent );
                run.Append(new Text(str));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion

            for (var i = 1; i < chapterFour.AuditoriumHours.Rows.Count; i++)
            {
                var dataRow = chapterFour.AuditoriumHours.Rows[i];
                var data = new string[dataRow.ItemArray.Length + 1];

                data[0] = dataRow.ItemArray[0].ToString();
                var summ = 0;
                for (var j = 1; j < dataRow.ItemArray.Length; j++)
                {
                    var integer = Int32.Parse(dataRow.ItemArray[j].ToString());
                    data[j + 1] = GetStringHoursAndCreditUnits(integer);
                    summ += integer;
                }
                data[1] = GetStringHoursAndCreditUnits(summ);

                #region row
                tableRow = new TableRow();

                for (var j = 0; j < data.Length; j++)
                {
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    run.Append(new Text(data[j]));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }

                table.Append(tableRow);
                #endregion
            }
            #endregion

            #region Самостоятельная работа
            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            run.Append(new Text("Самостоятельная работа (всего)"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            str = GetStringHoursAndCreditUnits(discipline.IndependentWork);
            run.Append(new Text(str));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold()
                };
                run.Append(runProp);
                str = GetStringHoursAndCreditUnits(discipline.Semesters[i].Independent);
                run.Append(new Text(str));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion

            for (var i = 1; i < chapterFour.IndependentHours.Rows.Count; i++)
            {
                var dataRow = chapterFour.IndependentHours.Rows[i];
                var data = new string[dataRow.ItemArray.Length + 1];

                data[0] = dataRow.ItemArray[0].ToString();
                var summ = 0;
                for (var j = 1; j < dataRow.ItemArray.Length; j++)
                {
                    var integer = Int32.Parse(dataRow.ItemArray[j].ToString());
                    data[j + 1] = GetStringHoursAndCreditUnits(integer);
                    summ += integer;
                }
                data[1] = GetStringHoursAndCreditUnits(summ);

                #region row
                tableRow = new TableRow();

                for (var j = 0; j < data.Length; j++)
                {
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    run.Append(new Text(data[j]));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }

                table.Append(tableRow);
                #endregion
            }
            #endregion

            #region Аттестация
            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            run.Append(new Text("Вид промежуточной аттестации (зачет, экзамен)"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            paragraph.Append(paraProp);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold()
                };
                run.Append(runProp);
                run.Append(new Text(discipline.Semesters[i].Validation));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion

            for (var i = 1; i < chapterFour.Validation.Rows.Count; i++)
            {
                var dataRow = chapterFour.Validation.Rows[i];
                var data = new string[dataRow.ItemArray.Length + 1];

                data[0] = dataRow.ItemArray[0].ToString();
                var summ = 0;
                for (var j = 1; j < dataRow.ItemArray.Length; j++)
                {
                    var integer = Helper.ConvertObjectToInt(dataRow.ItemArray[j].ToString());
                    data[j + 1] = GetStringHoursAndCreditUnits(integer);
                    summ += integer;
                }
                data[1] = GetStringHoursAndCreditUnits(summ);

                #region row
                tableRow = new TableRow();

                for (var j = 0; j < data.Length; j++)
                {
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);

                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    run.Append(new Text(data[j]));
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }

                table.Append(tableRow);
                #endregion
            }
            #endregion

            #region общее количество часов

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9" };
            tableCellProperties1.Append(shading1);
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            run.Append(new Text("Общая трудоемкость дисциплины"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9" };
            tableCellProperties1.Append(shading1);
            tableCell.Append(tableCellProperties1);

            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            str = GetStringHoursAndCreditUnits(discipline.TotalHours);
            run.Append(new Text(str));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < discipline.Semesters.Count; i++)
            {
                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "D9D9D9" };
                tableCellProperties1.Append(shading1);
                tableCell.Append(tableCellProperties1);

                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold()
                };
                run.Append(runProp);
                str = GetStringHoursAndCreditUnits(discipline.Semesters[i].TotalHours);
                run.Append(new Text(str));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion

            #endregion

            _body.Append(table);
        }
예제 #42
0
        /// <summary>
        /// Generates the Word Document and performs the Mail Merge
        /// </summary>
        /// <returns>True or false(with exception) if the generation was successful or not</returns>
        public TemplateGenerationResult GenerateDocument()
        {
            try
            {
                // Don't continue if the template file name is not found
                if (!File.Exists(_templateFileName))
                {
                   // System.IO.File.AppendAllText(@"c:\temp\errors.txt","In GenerateDocument:   " +  _templateFileName);
                    throw new Exception(message: "TemplateFileName (" + _templateFileName + ") does not exist");

                }

                // If the file is a DOTX file convert it to docx
                if (_templateFileName.ToUpper().EndsWith("DOTX"))
                {
                    TemplateGenerationResult resultValue = ConvertTemplate();

                    if (!resultValue.Value)
                    {
                        return resultValue;
                    }
                }
                else
                {
                    // Otherwise make a copy of the Word Document to the targetFileName
                    File.Copy(_templateFileName, _targetFileName);
                }

                using (WordprocessingDocument docGenerated = WordprocessingDocument.Open(_targetFileName, true))
                {
                    docGenerated.ChangeDocumentType(WordprocessingDocumentType.Document);

                    foreach (FieldCode field in docGenerated.MainDocumentPart.RootElement.Descendants<FieldCode>())
                    {
                        var fieldNameStart = field.Text.LastIndexOf(FieldDelimeter, System.StringComparison.Ordinal);
                        //var index = field.Text.LastIndexOf(" ", System.StringComparison.Ordinal) + 1;
                        var fieldname = field.Text.Substring(fieldNameStart + FieldDelimeter.Length).Trim();
                        fieldname = fieldname.Replace("\\* MERGEFORMAT", "").Trim();
                        var fieldValue = _values[fieldname];

                        // Go through all of the Run elements and replace the Text Elements Text Property
                        foreach (Run run in docGenerated.MainDocumentPart.Document.Descendants<Run>())
                        {
                            foreach (Text txtFromRun in run.Descendants<Text>().Where(a => a.Text == "«" + fieldname + "»"))
                            {
                                txtFromRun.Text = fieldValue;
                            }
                        }
                    }

                    if(_transactionDetailsList.Any())
                    {
                        var table = new Table();

                        var props = new TableProperties(
                            new TableBorders(
                            new TopBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            },
                            new BottomBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            },
                            new LeftBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            },
                            new RightBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            },
                            new InsideHorizontalBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            },
                            new InsideVerticalBorder
                            {
                                Val = new EnumValue<BorderValues>(BorderValues.Single),
                                Size = 6,
                                Color = "grey"
                            }));

                        //table.AppendChild<TableProperties>(props);
                        var uniqueRegions = _transactionDetailsList.Select(t => t.Region).Distinct();
                        var enumerable = uniqueRegions as List<string> ?? uniqueRegions.ToList();
                        foreach (var uniqueRegion in uniqueRegions)
                        {
                            var transactionDetailsListOfARegion = _transactionDetailsList.Where(t => t.Region == uniqueRegion);
                            var detailsListOfARegion = transactionDetailsListOfARegion as List<TransactionDetail> ?? transactionDetailsListOfARegion.ToList();
                            var firstOrDefault = detailsListOfARegion.FirstOrDefault();

                            var regionTr = new TableRow();
                            var regionTc = new TableCell();
                            var regionTcContent = new TableCell();
                            regionTc.Append(new Paragraph(new Run(new Text("Region: "))));
                            regionTcContent.Append(new Paragraph(new Run(new Text(uniqueRegion))));
                            regionTr.Append(regionTc);
                            regionTr.Append(regionTcContent);
                            table.Append(regionTr);

                            var bidNumberTr = new TableRow();
                            var bidNumberTc = new TableCell();
                            var bidNumberTcContent = new TableCell();
                            bidNumberTc.Append(new Paragraph(new Run(new Text("Bid Contract: "))));
                            if (firstOrDefault != null)
                                bidNumberTcContent.Append(new Paragraph(new Run(new Text(firstOrDefault.BidNumber))));
                            bidNumberTr.Append(bidNumberTc);
                            bidNumberTr.Append(bidNumberTcContent);
                            table.Append(bidNumberTr);

                            var bidDateTr = new TableRow();
                            var bidDateTc = new TableCell();
                            var bidDateTcContent = new TableCell();
                            bidDateTc.Append(new Paragraph(new Run(new Text("Bid Date: "))));
                            if (firstOrDefault != null)
                                bidDateTcContent.Append(new Paragraph(new Run(new Text(firstOrDefault.BidStratingDate))));
                            bidDateTr.Append(bidDateTc);
                            bidDateTr.Append(bidDateTcContent);
                            table.Append(bidDateTr);

                            var transactionTh = new TableRow();

                            var rowNoTh = new TableCell();
                            rowNoTh.Append(new Paragraph(new Run(new Text("No."))));
                            //zoneTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(rowNoTh);

                            var zoneTh = new TableCell();
                            zoneTh.Append(new Paragraph(new Run(new Text("Zone"))));
                            //zoneTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(zoneTh);

                            var woredaTh = new TableCell();
                            woredaTh.Append(new Paragraph(new Run(new Text("Woreda"))));
                            //woredaTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(woredaTh);

                            var warehouseTh = new TableCell();
                            warehouseTh.Append(new Paragraph(new Run(new Text("Warehouse (Origin)"))));
                            //warehouseTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(warehouseTh);

                            var distanceTh = new TableCell();
                            distanceTh.Append(new Paragraph(new Run(new Text("Distance From Origin"))));
                            //warehouseTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(distanceTh);

                            var tariffTh = new TableCell();
                            tariffTh.Append(new Paragraph(new Run(new Text("Tariff/Qtl (in birr)"))));
                            //tariffTh.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto}));
                            transactionTh.Append(tariffTh);
                            table.Append(transactionTh);
                            var rowNoCount = 1;
                            foreach (var transaction in detailsListOfARegion)
                            {
                                var transactionTr = new TableRow();

                                var rowNoTc = new TableCell();
                                rowNoTc.Append(new Paragraph(new Run(new Text(rowNoCount.ToString()))));
                                //zoneTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(rowNoTc);

                                var zoneTc = new TableCell();
                                zoneTc.Append(new Paragraph(new Run(new Text(transaction.Zone))));
                                //zoneTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(zoneTc);

                                var woredaTc = new TableCell();
                                woredaTc.Append(new Paragraph(new Run(new Text(transaction.Woreda))));
                                //woredaTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(woredaTc);

                                var warehouseTc = new TableCell();
                                warehouseTc.Append(new Paragraph(new Run(new Text(transaction.Warehouse))));
                                //warehouseTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(warehouseTc);

                                var distanceTc = new TableCell();
                                distanceTc.Append(new Paragraph(new Run(new Text(transaction.DistanceFromOrigin))));
                                //warehouseTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(distanceTc);

                                var tariffTc = new TableCell();
                                tariffTc.Append(new Paragraph(new Run(new Text(transaction.Tariff.ToString()))));
                                //tariffTc.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Auto }));
                                transactionTr.Append(tariffTc);
                                table.Append(transactionTr);

                                rowNoCount++;
                            }
                            var spacingTr = new TableRow();
                            var spacingTc = new TableCell();
                            spacingTc.Append(new Paragraph(new Run(new Text(" "))));
                            spacingTr.Append(spacingTc);
                            table.Append(spacingTr);
                            //table.Append(spacingTr);
                        }
                        docGenerated.MainDocumentPart.Document.Append(table);
                    }

                    // If the Document has settings remove them so the end user doesn't get prompted to use the data source
                    DocumentSettingsPart settingsPart = docGenerated.MainDocumentPart.GetPartsOfType<DocumentSettingsPart>().First();

                    var oxeSettings = settingsPart.Settings.Where(a => a.LocalName == "mailMerge").FirstOrDefault();

                    if (oxeSettings != null)
                    {
                        settingsPart.Settings.RemoveChild(oxeSettings);

                        settingsPart.Settings.Save();
                    }

                    docGenerated.MainDocumentPart.Document.Save();
                }

                return new TemplateGenerationResult { Value = true, ResultPath = _targetFileName};
            }
            catch (Exception ex)
            {
               // System.IO.File.AppendAllText(@"c:\temp\errors.txt", "In DocumentGeneration::generateDocument():   " + ex.Message.ToString(CultureInfo.InvariantCulture));
                return new TemplateGenerationResult { Value = false, Exception = "DocumentGeneration::generateDocument() - " + ex.ToString() };
            }
        }
예제 #43
0
        private void GenerateChapterTwo()
        {
            var titlePage = _sessionObjects.TitlePage;

            var paragraph = new Paragraph();
            var runProp = new RunProperties();
            var run = new Run();
            var runs = new List<Run>();

            run.Append(new Text("2. Место учебной дисциплины в структуре основной образовательной программы"));
            var paraProp = GetParagraphProperties("Header1");
            GenerateParagraph(run, paraProp);

            paragraph = new Paragraph();
            paragraph.Append(GetParagraphProperties());
            run = new Run();
            var str = String.Format("Учебная дисциплина «{0}» – дисциплина ", titlePage.Discipline);
            run.Append(new Text(str) { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            runProp = new RunProperties { Color = new Color { Val = "FF0000" } };
            run.Append(runProp);
            run.Append(new Text("{описать к какому блоку и циклу принадлежит дисциплина}" ){ Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            str = String.Format(" федерального государственного образовательного стандарта подготовки {0}ов по направлению «", titlePage.Qualification);
            run.Append(new Text(str) { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            runProp = new RunProperties { Color = new Color { Val = "FF0000" } };
            run.Append(runProp);
            run.Append(new Text("{написать направление}") { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            str = String.Format("».", titlePage.Qualification);
            run.Append(new Text(str) { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            _body.Append(paragraph);

            var discipline = _additionalObjects.Discipline;
            var num = 0;
            if(discipline.Semesters.Count != 0)
            {
                for(var i = 0; i < discipline.Semesters.Count; i++)
                {
                    num += discipline.Semesters[i].Number;
                }
            }
            var courseNumber = Math.Ceiling( (double)(num / 2) );
            paragraph = new Paragraph();
            paragraph.Append(GetParagraphProperties());
            run = new Run();
            str = String.Format("Дисциплина изучается на {0} курсе, базируется на знаниях студентов, полученных в процессе изучения дисциплин: ", courseNumber);
            run.Append(new Text(str) { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            runProp = new RunProperties { Color = new Color { Val = "FF0000" } };
            run.Append(runProp);
            run.Append(new Text("{название дисциплин}") { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            str = String.Format(" и может служить основой для изучения следующих учебных дисциплин: ");
            run.Append(new Text(str) { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);
            run = new Run();
            runProp = new RunProperties { Color = new Color { Val = "FF0000" } };
            run.Append(runProp);
            run.Append(new Text("{название дисциплин}") { Space = SpaceProcessingModeValues.Preserve });
            paragraph.Append(run);

            GenerateParagraph();

            #region table
            var chapterFour = _sessionObjects.ChapterFour;
            var numOfColumn = 10;
            if (chapterFour.Chapters.Rows.Count != 0)
            {
                numOfColumn = chapterFour.Chapters.Rows.Count;
            }

            var table = new Table();
            table.Append(GenerateTableProperties());
            var tableGrid1 = new TableGrid();
            var gridColumn = new GridColumn { Width = "3969" };
            tableGrid1.Append(gridColumn);
            for (var i = 0; i < numOfColumn; i++)
            {
                var gridColumn1 = new GridColumn{ Width = "400" };
                tableGrid1.Append(gridColumn1);
            }
            table.Append(tableGrid1);

            #region Шапка
            #region row
            var tableRow = new TableRow();

            #region cell
            var tableCell = new TableCell();
            TableCellProperties tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            var spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            var justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold()
            };
            run.Append(runProp);
            run.Append(new Text("Наименование обеспечиваемых (последующих) дисциплин"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            #region cell
            tableCell = new TableCell();
            tableCellProperties1 = new TableCellProperties();
            tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
            tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
            tableCellProperties1.Append(new GridSpan() { Val = numOfColumn });
            tableCell.Append(tableCellProperties1);
            paragraph = new Paragraph();
            paraProp = GetParagraphProperties("TableStyle");
            spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            justification = new Justification() { Val = JustificationValues.Center };
            paraProp.Append(spacingBetweenLines);
            paraProp.Append(justification);
            run = new Run();
            runProp = new RunProperties
            {
                Bold = new Bold(),
            };
            run.Append(runProp);
            run.Append(new Text("№ разделов данной дисциплины, необходимых для изучения обеспечиваемых (последующих) дисциплин"));
            paragraph.Append(paraProp);
            paragraph.Append(run);
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            table.Append(tableRow);
            #endregion

            #region row
            tableRow = new TableRow();

            #region cell
            tableCell = new TableCell();
            var tableCellProp = new TableCellProperties { VerticalMerge = new VerticalMerge() };
            tableCell.Append(tableCellProp);
            paragraph = new Paragraph();
            tableCell.Append(paragraph);
            tableRow.Append(tableCell);
            #endregion

            for (var i = 0; i < numOfColumn; i++)
            {
                #region cell
                tableCell = new TableCell();
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                runProp = new RunProperties
                {
                    Bold = new Bold(),
                };
                run.Append(runProp);
                run.Append(new Text((i + 1).ToString()));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion
            }

            table.Append(tableRow);
            #endregion
            #endregion

            #region данные
            for (var i = 0; i < 3; i++)
            {
                #region row
                tableRow = new TableRow();

                #region cell
                tableCell = new TableCell();
                tableCellProperties1 = new TableCellProperties();
                tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
                tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });

                tableCell.Append(tableCellProperties1);
                paragraph = new Paragraph();
                paraProp = GetParagraphProperties("TableStyle");
                spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                justification = new Justification() { Val = JustificationValues.Center };
                paraProp.Append(spacingBetweenLines);
                paraProp.Append(justification);
                run = new Run();
                run.Append(new Text("Название дисциплины 1"));
                paragraph.Append(paraProp);
                paragraph.Append(run);
                tableCell.Append(paragraph);
                tableRow.Append(tableCell);
                #endregion

                for (var j = 0; j < numOfColumn; j++)
                {
                    var rand = new Random(2);
                    #region cell
                    tableCell = new TableCell();
                    tableCellProperties1 = new TableCellProperties();
                    tableCellProperties1.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
                    tableCellProperties1.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
                    tableCell.Append(tableCellProperties1);
                    paragraph = new Paragraph();
                    paraProp = GetParagraphProperties("TableStyle");
                    spacingBetweenLines = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
                    justification = new Justification() { Val = JustificationValues.Center };
                    paraProp.Append(spacingBetweenLines);
                    paraProp.Append(justification);
                    run = new Run();
                    runProp = new RunProperties { Bold = new Bold() };
                    run.Append(runProp);
                    if (rand.Next() == 1)
                    {
                        run.Append(new Text("X"));
                    }
                    paragraph.Append(paraProp);
                    paragraph.Append(run);
                    tableCell.Append(paragraph);
                    tableRow.Append(tableCell);
                    #endregion
                }
                table.Append(tableRow);
                #endregion
            }
            #endregion

            _body.Append(table);
            #endregion

            run = new Run();
            run.Append(new Break { Type = BreakValues.Page });
            GenerateParagraph();
        }
예제 #44
0
 private TableCell CreateBorderCell(int cellWidth)
 {
     //ボーダーつきのセルを生成する(幅指定あり)
     TableCellProperties tableCellProperties = new TableCellProperties();
     EnumValue<TableWidthUnitValues> type = cellWidth == 0 ? TableWidthUnitValues.Auto : TableWidthUnitValues.Dxa;
     TableCellWidth tableCellWidth = new TableCellWidth() { Width = cellWidth.ToString(), Type = type };
     tableCellProperties.Append(tableCellWidth);
     TableCell tableCell = new TableCell();
     tableCell.Append(tableCellProperties);
     tableCell.Append(CreateEmptyParagraph());
     return tableCell;
 }
        private TableCell BuildCell(string text, int gridSpan = 1, VerticalMerge vm = null, bool bold = false)
        {
            TableCell cell = new TableCell();
            Paragraph p = new Paragraph();
            ParagraphProperties paragraphProperties = new ParagraphProperties();

            Justification justification = new Justification() { Val = JustificationValues.Center };
            paragraphProperties.Append(justification);

            if (bold)
            {
                ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();
                Bold boldStyle = new Bold();

                paragraphMarkRunProperties.Append(boldStyle);
                paragraphProperties.Append(paragraphMarkRunProperties);
            }
            p.Append(paragraphProperties);

            if (!string.IsNullOrEmpty(text))
            {
                Run r = new Run();
                RunProperties runProperties = new RunProperties();

                if (bold)
                {
                    Bold boldStyle = new Bold();

                    runProperties.Append(boldStyle);
                }

                r.Append(runProperties);

                Text t = new Text { Text = text };
                r.AppendChild<Text>(t);

                p.AppendChild<Run>(r);
            }

            TableCellProperties cellProperty = new TableCellProperties();
            TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };

            cellProperty.Append(tableCellVerticalAlignment1);

            if (gridSpan > 1)
            {
                GridSpan gs = new GridSpan { Val = gridSpan };
                cellProperty.Append(gs);
            }

            if (vm != null)
            {
                cellProperty.Append(vm);
            }

            cell.Append(cellProperty);
            cell.Append(p);

            return cell;
        }
예제 #46
0
        private TableCell CreateCenterCell(List<string> contents)
        {
            TableCellProperties tableCellProperties = new TableCellProperties();
            //セルの幅の均等割はTableWidthUnitValues.Autoじゃなく、TableWidthUnitValues.Nilを使うのが正解?
            TableCellWidth tableCellWidth = new TableCellWidth() { Width = "0", Type = TableWidthUnitValues.Nil };
            tableCellProperties.Append(tableCellWidth);

            TableCell tableCell = new TableCell();
            tableCell.Append(tableCellProperties);

            foreach (string content in contents)
            {
                tableCell.Append(CreateCenterParagraph(content));
            }

            return tableCell;
        }
		internal void Process(TableCell cell, DocxTableProperties docxProperties, DocxNode node)
		{
			TableCellProperties cellProperties = new TableCellProperties();

            ProcessColSpan(node, cellProperties);
            ProcessWidth(node, cellProperties);
			
			if (HasRowSpan)
			{
				cellProperties.Append(new VerticalMerge() { Val = MergedCellValues.Restart });
			}
			
			//Processing border should be after colspan
            ProcessBorders(node, docxProperties, cellProperties);

            string backgroundColor = node.ExtractStyleValue(DocxColor.backGroundColor);
			
			if (!string.IsNullOrEmpty(backgroundColor))
			{
				DocxColor.ApplyBackGroundColor(backgroundColor, cellProperties);
			}

            ProcessVerticalAlignment(node, cellProperties);
			
			if (cellProperties.HasChildren)
			{
				cell.Append(cellProperties);
			}
		}
예제 #48
0
        /// <summary>
        ///     Add content row to the table.
        /// </summary>
        private static TableRow AddContentRow(QueryResult queryResult, DataRow contentRow)
        {
            TableCell tc;
            TableRow  tr          = new TableRow( );
            int       dataColIndx = 0;

            foreach (ResultColumn col in queryResult.Columns)
            {
                if (!col.IsHidden)
                {
                    object cellValue = contentRow[dataColIndx];
                    if (cellValue != null)
                    {
                        if (col.ColumnType is AutoIncrementType)
                        {
                            string displayPattern = null;

                            if (contentRow.Table.Columns[dataColIndx].ExtendedProperties.ContainsKey("DisplayPattern"))
                            {
                                displayPattern = ( string )contentRow.Table.Columns[dataColIndx].ExtendedProperties["DisplayPattern"];
                            }

                            var intStringVal = cellValue as string;

                            int temp;

                            if (intStringVal != null)
                            {
                                temp = int.Parse(intStringVal);
                            }
                            else
                            {
                                temp = ( int )cellValue;
                            }

                            if (string.IsNullOrEmpty(displayPattern))
                            {
                                AddContentRow_NonString(tr, col, temp);
                            }
                            else
                            {
                                AddContentRow_String(tr, col, temp.ToString(displayPattern));
                            }
                        }
                        else if (col.ColumnType is DateTimeType || col.ColumnType is TimeType || col.ColumnType is DateType || col.ColumnType is Int32Type || col.ColumnType is NumericType <decimal> || col.ColumnType is NumericType <Single> )
                        {
                            AddContentRow_NonString(tr, col, cellValue);
                        }
                        else if (col.ColumnType is StructureLevelsType)
                        {
                            //Get the structure view cell value
                            string   cellText = ExportDataHelper.GetStructureLevelCellValue(( string )contentRow[dataColIndx], true);
                            string[] views    = cellText.Split(new[]
                            {
                                Environment.NewLine
                            }, StringSplitOptions.None);
                            int i = 1;

                            tc = new TableCell( );
                            Paragraph paragraph = new Paragraph( );
                            Run       run       = new Run( );
                            foreach (string structureView in views)
                            {
                                run.Append(new DocumentFormat.OpenXml.Wordprocessing.Text(structureView));
                                if (i != views.Length)
                                {
                                    //Insert a break for new line.
                                    run.Append(new Break( ));
                                }
                                else
                                {
                                    paragraph.Append(run);
                                    tc.Append(paragraph);
                                    tr.Append(tc);
                                }
                                i++;
                            }
                        }
                        else
                        {
                            AddContentRow_String(tr, col, cellValue);
                        }
                    }
                    else
                    {
                        tc = new TableCell(new Paragraph(new Run(
                                                             new DocumentFormat.OpenXml.Wordprocessing.Text(""))));
                        tr.Append(tc);
                    }
                }
                dataColIndx++;
            }
            return(tr);
        }
예제 #49
0
        public TableRow GenerateTableFooterRow(CellProps[] cellProps, UInt32Value height)
        {
            // Add table row properties
            TableRow tableRow1 = new TableRow();
            TableRowProperties tableRowProperties1 = generateTableRowProperties(height);
            tableRow1.Append(tableRowProperties1);

            foreach (CellProps cp in cellProps) {
                if (cp.span == 0) continue;
                TableCell tableCell1 = new TableCell();
                TableCellProperties tableCellProperties1 = new TableCellProperties();
                TableCellBorders tableCellBorders1;

                if (cp.boxed) {
                    tableCellBorders1 = generateTableCellBordersBox();
                } else {
                    tableCellBorders1 = generateTableCellBordersPlain();
                }

                Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };
                NoWrap noWrap1 = new NoWrap();
                TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };
                HideMark hideMark1 = new HideMark();

                tableCellProperties1.Append(tableCellBorders1);
                tableCellProperties1.Append(shading1);
                tableCellProperties1.Append(noWrap1);
                tableCellProperties1.Append(tableCellVerticalAlignment1);
                tableCellProperties1.Append(hideMark1);

                Paragraph paragraph1 = new Paragraph();

                ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                Justification justification1 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
                Bold bold1 = new Bold();
                BoldComplexScript boldComplexScript1 = new BoldComplexScript();
                Color color1 = new Color() { Val = "333399" };
                FontSize fontSize1 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "18" };

                paragraphMarkRunProperties1.Append(bold1);
                paragraphMarkRunProperties1.Append(boldComplexScript1);
                paragraphMarkRunProperties1.Append(color1);
                paragraphMarkRunProperties1.Append(fontSize1);
                paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

                paragraphProperties1.Append(justification1);
                paragraphProperties1.Append(paragraphMarkRunProperties1);

                Run run1 = new Run();

                RunProperties runProperties1 = new RunProperties();
                Bold bold2 = new Bold();
                BoldComplexScript boldComplexScript2 = new BoldComplexScript();
                Color color2 = new Color() { Val = "333399" };
                FontSize fontSize2 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "18" };

                runProperties1.Append(bold2);
                runProperties1.Append(boldComplexScript2);
                runProperties1.Append(color2);
                runProperties1.Append(fontSize2);
                runProperties1.Append(fontSizeComplexScript2);
                run1.Append(runProperties1);

                if (cp.text != null) {
                    Text text1 = new Text();
                    text1.Text = cp.text;
                    run1.Append(text1);
                }

                paragraph1.Append(paragraphProperties1);
                paragraph1.Append(run1);

                tableCell1.Append(tableCellProperties1);
                tableCell1.Append(paragraph1);
                tableRow1.Append(tableCell1);
            }
            return tableRow1;
        }
예제 #50
0
        private static void AddTable(string fileName, string[,] data)
        {
            using (var document = WordprocessingDocument.Open(fileName, true))
            {
                var doc = document.MainDocumentPart.Document;

                Table table = new Table();

                TableProperties props = new TableProperties(
                    new TableBorders(
                        new TopBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                },
                        new BottomBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                },
                        new LeftBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                },
                        new RightBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                },
                        new InsideHorizontalBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                },
                        new InsideVerticalBorder
                {
                    Val  = new EnumValue <BorderValues>(BorderValues.Single),
                    Size = 12
                }));

                table.AppendChild <TableProperties>(props);

                for (var i = 0; i <= data.GetUpperBound(0); i++)
                {
                    var tr = new TableRow();
                    for (var j = 0; j <= data.GetUpperBound(1); j++)
                    {
                        var tc = new TableCell();
                        tc.Append(new Paragraph(new Run(new Text(data[i, j]))));

                        // Assume you want columns that are automatically sized.
                        tc.Append(new TableCellProperties(
                                      new TableCellWidth {
                            Type = TableWidthUnitValues.Auto
                        }));

                        tr.Append(tc);
                    }
                    table.Append(tr);
                }
                doc.Body.Append(table);
                doc.Save();
            }
        }
예제 #51
0
파일: CreateTable.cs 프로젝트: y0y0alice/OA
        // Creates an Table instance and adds its children.
        public static Table GenerateTable(Document doc, System.Data.DataTable datetable)
        {
            Table table = new Table();
            //
            PageSize pagesize = doc.Body.Descendants<PageSize>().First();
            PageMargin pagemargin = doc.Body.Descendants<PageMargin>().First();
            //
            var AvailableSumWidth = (int)(pagesize.Width - pagemargin.Right - pagemargin.Left);

            TableBorders tborder = new Func<TableBorders>(delegate()
            {
                TableBorders tableBorders1 = new TableBorders();
                TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

                tableBorders1.Append(topBorder1);
                tableBorders1.Append(leftBorder1);
                tableBorders1.Append(bottomBorder1);
                tableBorders1.Append(rightBorder1);
                tableBorders1.Append(insideHorizontalBorder1);
                tableBorders1.Append(insideVerticalBorder1);
                return tableBorders1;
            })();

            table.AppendChild<TableProperties>(new TableProperties(
               new TableStyle() { Val = "a7" },
               tborder,
               new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto },
               new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }
            ));

            int sumColumn = datetable.Columns.Count;

            int averwidth = AvailableSumWidth / sumColumn;

            Double set_colSumW = 0;
            int remainSumW = 0;
            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) { set_colSumW += Convert.ToDouble(col_w); remainSumW += averwidth; }
            }

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) item.ExtendedProperties.Add("WordWidth", Math.Floor((remainSumW * Convert.ToDouble(col_w) / set_colSumW)));
                else item.ExtendedProperties.Add("WordWidth", averwidth);
            }

            for (int i = 0; i < sumColumn; i++)
            {
                int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);
                table.AppendChild<GridColumn>(new GridColumn() { Width = col_w.ToString() });
            }
            List<System.Data.DataRow> lstCol = new List<System.Data.DataRow>();
            System.Data.DataRow dr = datetable.NewRow();
            List<object> lstObj = new List<object>();

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                lstObj.Add(item.ColumnName);
            }

            dr.ItemArray = lstObj.ToArray();
            datetable.Rows.InsertAt(dr, 0);

            foreach (System.Data.DataRow item in datetable.Rows)
            {
                TableRow tableRow = new TableRow() { RsidTableRowAddition = "00D24D12", RsidTableRowProperties = "00D24D12" };
                for (int i = 0; i < sumColumn; i++)
                {
                    int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);

                    string cellValue = item[i].ToString();
                    TableCell tableCell1 = new TableCell();

                    TableCellProperties tableCellProperties1 = new TableCellProperties();
                    TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = col_w.ToString(), Type = TableWidthUnitValues.Dxa };

                    tableCellProperties1.Append(tableCellWidth1);

                    Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00D24D12", RsidParagraphProperties = "003246FB", RsidRunAdditionDefault = "00D24D12" };

                    Run run1 = new Run();

                    RunProperties runProperties1 = new RunProperties();
                    RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

                    runProperties1.Append(runFonts1);
                    Text text1 = new Text();
                    text1.Text = cellValue;

                    run1.Append(runProperties1);
                    run1.Append(text1);
                    BookmarkStart bookmarkStart1 = new BookmarkStart();
                    BookmarkEnd bookmarkEnd1 = new BookmarkEnd();

                    paragraph1.Append(run1);
                    paragraph1.Append(bookmarkStart1);
                    paragraph1.Append(bookmarkEnd1);

                    tableCell1.Append(tableCellProperties1);
                    tableCell1.Append(paragraph1);

                    tableRow.Append(tableCell1);
                }
                table.Append(tableRow);
            }
            return table;
        }
예제 #52
0
 public static byte[] WordDokumanOlustur(string sablon, DataSet dataset, Dictionary <string, string> degerler)
 {
     byte[]   buffer   = File.ReadAllBytes(sablon);
     string[] switches = (string[])null;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         memoryStream.Write(buffer, 0, buffer.Length);
         using (WordprocessingDocument docx = WordprocessingDocument.Open((Stream)memoryStream, true))
         {
             DocumentMerge.ConvertFieldCodes((OpenXmlElement)docx.MainDocumentPart.Document);
             foreach (SimpleField field in docx.MainDocumentPart.Document.Descendants <SimpleField>())
             {
                 string fieldName = DocumentMerge.GetFieldName(field, out switches);
                 if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_"))
                 {
                     TableRow firstParent1 = DocumentMerge.GetFirstParent <TableRow>((OpenXmlElement)field);
                     if (firstParent1 != null)
                     {
                         Table firstParent2 = DocumentMerge.GetFirstParent <Table>((OpenXmlElement)firstParent1);
                         if (firstParent2 != null)
                         {
                             string nameFromFieldName = DocumentMerge.GetTableNameFromFieldName(fieldName);
                             if (dataset != null && dataset.Tables.Contains(nameFromFieldName) && dataset.Tables[nameFromFieldName].Rows.Count != 0)
                             {
                                 DataTable dataTable = dataset.Tables[nameFromFieldName];
                                 List <TableCellProperties> list1 = new List <TableCellProperties>();
                                 List <string>      list2         = new List <string>();
                                 List <string>      list3         = new List <string>();
                                 List <SimpleField> list4         = new List <SimpleField>();
                                 foreach (TableCell tableCell in firstParent1.Descendants <TableCell>())
                                 {
                                     list1.Add(tableCell.GetFirstChild <TableCellProperties>());
                                     Paragraph firstChild1 = tableCell.GetFirstChild <Paragraph>();
                                     if (firstChild1 != null)
                                     {
                                         ParagraphProperties firstChild2 = firstChild1.GetFirstChild <ParagraphProperties>();
                                         if (firstChild2 != null)
                                         {
                                             list3.Add(firstChild2.OuterXml);
                                         }
                                         else
                                         {
                                             list3.Add((string)null);
                                         }
                                     }
                                     else
                                     {
                                         list3.Add((string)null);
                                     }
                                     string      str         = string.Empty;
                                     SimpleField simpleField = (SimpleField)null;
                                     using (IEnumerator <SimpleField> enumerator = tableCell.Descendants <SimpleField>().GetEnumerator())
                                     {
                                         if (enumerator.MoveNext())
                                         {
                                             SimpleField current = enumerator.Current;
                                             simpleField = current;
                                             str         = DocumentMerge.GetColumnNameFromFieldName(DocumentMerge.GetFieldName(current, out switches));
                                         }
                                     }
                                     list2.Add(str);
                                     if (str != "")
                                     {
                                         list4.Add(simpleField);
                                     }
                                 }
                                 TableRowProperties firstChild = firstParent1.GetFirstChild <TableRowProperties>();
                                 foreach (DataRow dataRow in (InternalDataCollectionBase)dataTable.Rows)
                                 {
                                     TableRow tableRow = new TableRow();
                                     if (firstChild != null)
                                     {
                                         tableRow.Append(new OpenXmlElement[1]
                                         {
                                             (OpenXmlElement) new TableRowProperties(firstChild.OuterXml)
                                         });
                                     }
                                     for (int index = 0; index < list1.Count; ++index)
                                     {
                                         TableCellProperties tableCellProperties = new TableCellProperties(list1[index].OuterXml);
                                         TableCell           tableCell           = new TableCell();
                                         tableCell.Append(new OpenXmlElement[1]
                                         {
                                             (OpenXmlElement)tableCellProperties
                                         });
                                         Paragraph paragraph = new Paragraph(new OpenXmlElement[1]
                                         {
                                             (OpenXmlElement) new ParagraphProperties(list3[index])
                                         });
                                         tableCell.Append(new OpenXmlElement[1]
                                         {
                                             (OpenXmlElement)paragraph
                                         });
                                         try
                                         {
                                             if (!string.IsNullOrEmpty(list2[index]))
                                             {
                                                 if (!dataTable.Columns.Contains(list2[index]))
                                                 {
                                                     throw new Exception(string.Format("Unable to complete template: column name '{0}' is unknown in parameter tables !", (object)list2[index]));
                                                 }
                                                 if (!dataRow.IsNull(list2[index]))
                                                 {
                                                     string text = dataRow[list2[index]].ToString();
                                                     paragraph.Append(new OpenXmlElement[1]
                                                     {
                                                         (OpenXmlElement)DocumentMerge.GetRunElementForText(text, list4[index])
                                                     });
                                                 }
                                             }
                                         }
                                         catch
                                         {
                                         }
                                         tableRow.Append(new OpenXmlElement[1]
                                         {
                                             (OpenXmlElement)tableCell
                                         });
                                     }
                                     firstParent2.Append(new OpenXmlElement[1]
                                     {
                                         (OpenXmlElement)tableRow
                                     });
                                 }
                                 firstParent1.Remove();
                             }
                         }
                     }
                 }
             }
             foreach (SimpleField field in docx.MainDocumentPart.Document.Descendants <SimpleField>())
             {
                 string fieldName = DocumentMerge.GetFieldName(field, out switches);
                 if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_"))
                 {
                     TableRow firstParent1 = DocumentMerge.GetFirstParent <TableRow>((OpenXmlElement)field);
                     if (firstParent1 != null)
                     {
                         Table firstParent2 = DocumentMerge.GetFirstParent <Table>((OpenXmlElement)firstParent1);
                         if (firstParent2 != null)
                         {
                             string nameFromFieldName = DocumentMerge.GetTableNameFromFieldName(fieldName);
                             if ((dataset == null || !dataset.Tables.Contains(nameFromFieldName) || dataset.Tables[nameFromFieldName].Rows.Count == 0) && Enumerable.Contains <string>((IEnumerable <string>)switches, "dt"))
                             {
                                 firstParent2.Remove();
                             }
                         }
                     }
                 }
             }
             DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)docx.MainDocumentPart.Document);
             ((OpenXmlPartRootElement)docx.MainDocumentPart.Document).Save();
             foreach (HeaderPart headerPart in docx.MainDocumentPart.HeaderParts)
             {
                 DocumentMerge.ConvertFieldCodes((OpenXmlElement)headerPart.Header);
                 DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)headerPart.Header);
                 ((OpenXmlPartRootElement)headerPart.Header).Save();
             }
             foreach (FooterPart footerPart in docx.MainDocumentPart.FooterParts)
             {
                 DocumentMerge.ConvertFieldCodes((OpenXmlElement)footerPart.Footer);
                 DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)footerPart.Footer);
                 ((OpenXmlPartRootElement)footerPart.Footer).Save();
             }
         }
         memoryStream.Seek(0L, SeekOrigin.Begin);
         return(memoryStream.ToArray());
     }
 }
예제 #53
0
 private TableCell CreateBorderCell(string text)
 {
     int cellWidth = CalcTextWidth(text.Length);
     TableCellProperties tableCellProperties = new TableCellProperties();
     EnumValue<TableWidthUnitValues> type = cellWidth == 0 ? TableWidthUnitValues.Auto : TableWidthUnitValues.Dxa;
     TableCellWidth tableCellWidth = new TableCellWidth() { Width = cellWidth.ToString(), Type = type };
     tableCellProperties.Append(tableCellWidth);
     TableCell tableCell = new TableCell();
     tableCell.Append(tableCellProperties);
     tableCell.Append(CreateTextParagraph(text));
     return tableCell;
 }
예제 #54
0
        private void SaveHistoryButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter   = "Word Document|*.docx",
                Title    = "Сохранить историю болезней",
                FileName = "История болезней. Пациент " + patient.ToString()
            };

            saveFileDialog.ShowDialog();
            //  try
            //   {
            if (saveFileDialog.FileName != "")
            {
                using (FileStream fileStream = saveFileDialog.OpenFile() as FileStream)
                {
                    using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fileStream, WordprocessingDocumentType.Document, true))
                    {
                        MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
                        mainPart.Document = new Document();
                        Body body = new Body();
                        mainPart.Document.Body = body;
                        body.Append(new Paragraph(new Run(new Text("История болезней"))
                        {
                            RunProperties = new RunProperties()
                            {
                                Bold = new Bold()
                                {
                                    Val = new OnOffValue(true)
                                },
                                Caps = new Caps()
                                {
                                    Val = new OnOffValue(true)
                                },
                                FontSize = new FontSize()
                                {
                                    Val = "48"
                                }
                            }
                        })
                        {
                            ParagraphProperties = new ParagraphProperties()
                            {
                                Justification = new Justification()
                                {
                                    Val = JustificationValues.Center
                                }
                            }
                        });
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Фамилия: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Fename.ToString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Имя: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Name.ToString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Отчество: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Patronymic.ToString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Дата рождения: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Birthdate.ToShortDateString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Пол: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Gender ? "Мужской" : "Женский")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("СНИЛС: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.SNILS.ToString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new OpenXmlElement[] {
                            new Run(new Text("Номер полиса: ")
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            },
                            new Run(new Text(patient.Policy.ToString())
                            {
                                Space = SpaceProcessingModeValues.Preserve
                            })
                        }));
                        body.Append(new Paragraph(new Run(new Break()
                        {
                            Type = BreakValues.Page
                        })));
                        foreach (Reception reception in patient.Receptions)
                        {
                            body.Append(new Paragraph(new Run(new Text("Прием " + reception.Date.ToShortDateString()))
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    },
                                    Caps = new Caps()
                                    {
                                        Val = new OnOffValue(true)
                                    },
                                    FontSize = new FontSize()
                                    {
                                        Val = "36"
                                    }
                                }
                            })
                            {
                                ParagraphProperties = new ParagraphProperties()
                                {
                                    Justification = new Justification()
                                    {
                                        Val = JustificationValues.Center
                                    }
                                }
                            });
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Врач: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Employee.ToString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Температура: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Temperature.ToString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Давление: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Pressure.ToString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Диагноз: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Diagnosis.ToString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new Run(new Text("Симптомы:"))
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            }));
                            body.Append(new Paragraph(new Run(new Text(reception.Symptoms == null ? "Нет" : reception.Symptoms.ToString().Length == 0 ? "Нет" : reception.Symptoms.ToString()))));
                            body.Append(new Paragraph(new Run(new Text("Рекомендации:"))
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            }));
                            body.Append(new Paragraph(new Run(new Text(reception.Recommendations == null ? "Нет" : reception.Recommendations.ToString().Length == 0 ? "Нет" : reception.Recommendations.ToString()))));
                            if (reception.ReceptionsMedicines.Count > 0)
                            {
                                body.Append(new Paragraph(new Run(new Text("Медикаменты:"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                }));
                                Table           table           = new Table();
                                TableProperties tableProperties = new TableProperties(
                                    new TableBorders(
                                        new TopBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new BottomBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new LeftBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new RightBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new InsideHorizontalBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new InsideVerticalBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                }
                                        )
                                    );
                                table.AppendChild(tableProperties);
                                TableRow  headerTableRow = new TableRow();
                                TableCell nameHeaderCell = new TableCell(new Paragraph(new Run(new Text("Название"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                })
                                {
                                    ParagraphProperties = new ParagraphProperties()
                                    {
                                        Justification = new Justification()
                                        {
                                            Val = JustificationValues.Center
                                        }
                                    }
                                });
                                nameHeaderCell.Append(new TableCellProperties()
                                {
                                    TableCellVerticalAlignment = new TableCellVerticalAlignment()
                                    {
                                        Val = TableVerticalAlignmentValues.Center
                                    },
                                    TableCellWidth = new TableCellWidth()
                                    {
                                        Width = "3400"
                                    }
                                });
                                headerTableRow.Append(nameHeaderCell);
                                TableCell descriptionHeaderCell = new TableCell(new Paragraph(new Run(new Text("Описание"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                })
                                {
                                    ParagraphProperties = new ParagraphProperties()
                                    {
                                        Justification = new Justification()
                                        {
                                            Val = JustificationValues.Center
                                        }
                                    }
                                });
                                descriptionHeaderCell.Append(new TableCellProperties()
                                {
                                    TableCellVerticalAlignment = new TableCellVerticalAlignment()
                                    {
                                        Val = TableVerticalAlignmentValues.Center
                                    },
                                    TableCellWidth = new TableCellWidth()
                                    {
                                        Width = "9600"
                                    }
                                });
                                headerTableRow.Append(descriptionHeaderCell);
                                table.Append(headerTableRow);
                                foreach (ReceptionMedicine recMed in reception.ReceptionsMedicines)
                                {
                                    TableRow  medicineTableRow      = new TableRow();
                                    TableCell medicineNameTableCell = new TableCell(new Paragraph(new Run(new Text(recMed.Medicine.Name))));
                                    medicineTableRow.Append(medicineNameTableCell);
                                    TableCell medicineDescriptionTableCell = new TableCell(new Paragraph(new Run(new Text(recMed.Medicine.Description))));
                                    medicineTableRow.Append(medicineDescriptionTableCell);
                                    table.Append(medicineTableRow);
                                }
                                body.Append(table);
                            }
                            body.Append(new Paragraph(new Run(new Text())));
                        }
                    }
                    fileStream.Close();
                }
            }

            /* }
             * catch (Exception exc)
             * {
             *   MessageBox.Show("Ошибка создания документа " + exc.Message);
             * }*/
        }
예제 #55
0
        private TableCell CreateChoicesCell(List<CodeVM> codes, int firstCodesCount)
        {
            TableCellProperties tableCellProperties = new TableCellProperties();

            TableCellWidth tableCellWidth = new TableCellWidth() { Width = "0", Type = TableWidthUnitValues.Auto };
            tableCellProperties.Append(tableCellWidth);

            TableCell tableCell = new TableCell();
            tableCell.Append(tableCellProperties);

            foreach (CodeVM code in codes)
            {
                string text = ToChoiceString(code);
                Paragraph paragraph = CreateTextParagraph(text);
                tableCell.Append(paragraph);
            }

            int diff = firstCodesCount - codes.Count;
            if (diff != 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    tableCell.Append(CreateEmptyParagraph());
                }
            }

            return tableCell;
        }
예제 #56
0
        private void SaveRecomendationsButton_Click(object sender, EventArgs e)
        {
            if (!Save())
            {
                return;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter   = "Word Document|*.docx",
                Title    = "Сохранить рекомендации",
                FileName = reception.Date.ToShortDateString() + " " + reception.Patient.ToString() + " рекомендации"
            };

            saveFileDialog.ShowDialog();
            try
            {
                if (saveFileDialog.FileName != "")
                {
                    using (FileStream fileStream = saveFileDialog.OpenFile() as FileStream)
                    {
                        using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fileStream, WordprocessingDocumentType.Document, true))
                        {
                            MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
                            mainPart.Document = new Document();
                            Body body = new Body();
                            mainPart.Document.Body = body;
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Врач: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Employee.ToString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new OpenXmlElement[] {
                                new Run(new Text("Дата: ")
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                },
                                new Run(new Text(reception.Date.ToShortDateString())
                                {
                                    Space = SpaceProcessingModeValues.Preserve
                                })
                            }));
                            body.Append(new Paragraph(new Run(new Text("Рекомендации:"))
                            {
                                RunProperties = new RunProperties()
                                {
                                    Bold = new Bold()
                                    {
                                        Val = new OnOffValue(true)
                                    }
                                }
                            }));
                            body.Append(new Paragraph(new Run(new Text(reception.Recommendations == null ? "Нет" : reception.Recommendations.ToString().Length == 0 ? "Нет" : reception.Recommendations.ToString()))));
                            if (reception.ReceptionsMedicines.Count > 0)
                            {
                                body.Append(new Paragraph(new Run(new Text("Медикаменты:"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                }));
                                Table           table           = new Table();
                                TableProperties tableProperties = new TableProperties(
                                    new TableBorders(
                                        new TopBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new BottomBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new LeftBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new RightBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new InsideHorizontalBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                },
                                        new InsideVerticalBorder()
                                {
                                    Val =
                                        new EnumValue <BorderValues>(BorderValues.Single),
                                    Size = 1
                                }
                                        )
                                    );
                                table.AppendChild(tableProperties);
                                TableRow  headerTableRow = new TableRow();
                                TableCell nameHeaderCell = new TableCell(new Paragraph(new Run(new Text("Название"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                })
                                {
                                    ParagraphProperties = new ParagraphProperties()
                                    {
                                        Justification = new Justification()
                                        {
                                            Val = JustificationValues.Center
                                        }
                                    }
                                });
                                nameHeaderCell.Append(new TableCellProperties()
                                {
                                    TableCellVerticalAlignment = new TableCellVerticalAlignment()
                                    {
                                        Val = TableVerticalAlignmentValues.Center
                                    },
                                    TableCellWidth = new TableCellWidth()
                                    {
                                        Width = "3400"
                                    }
                                });
                                headerTableRow.Append(nameHeaderCell);
                                TableCell descriptionHeaderCell = new TableCell(new Paragraph(new Run(new Text("Описание"))
                                {
                                    RunProperties = new RunProperties()
                                    {
                                        Bold = new Bold()
                                        {
                                            Val = new OnOffValue(true)
                                        }
                                    }
                                })
                                {
                                    ParagraphProperties = new ParagraphProperties()
                                    {
                                        Justification = new Justification()
                                        {
                                            Val = JustificationValues.Center
                                        }
                                    }
                                });
                                descriptionHeaderCell.Append(new TableCellProperties()
                                {
                                    TableCellVerticalAlignment = new TableCellVerticalAlignment()
                                    {
                                        Val = TableVerticalAlignmentValues.Center
                                    },
                                    TableCellWidth = new TableCellWidth()
                                    {
                                        Width = "9600"
                                    }
                                });
                                headerTableRow.Append(descriptionHeaderCell);
                                table.Append(headerTableRow);
                                foreach (ReceptionMedicine recMed in reception.ReceptionsMedicines)
                                {
                                    TableRow  medicineTableRow      = new TableRow();
                                    TableCell medicineNameTableCell = new TableCell(new Paragraph(new Run(new Text(recMed.Medicine.Name))));
                                    medicineTableRow.Append(medicineNameTableCell);
                                    TableCell medicineDescriptionTableCell = new TableCell(new Paragraph(new Run(new Text(recMed.Medicine.Description))));
                                    medicineTableRow.Append(medicineDescriptionTableCell);
                                    table.Append(medicineTableRow);
                                }
                                body.Append(table);
                            }
                        }
                        fileStream.Close();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Ошибка создания документа " + exc.Message);
            }
        }
예제 #57
0
        private TableCell CreateNoBorderCell(string text)
        {
            TableCellProperties tableCellProperties = new TableCellProperties();
            int cellWidth = CalcTextWidth(text.Length);

            TableCellWidth tableCellWidth = new TableCellWidth() { Width = cellWidth.ToString(), Type = TableWidthUnitValues.Dxa };
            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Nil };
            LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Nil };
            BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Nil };
            RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Nil };

            tableCellBorders1.Append(topBorder1);
            tableCellBorders1.Append(leftBorder1);
            tableCellBorders1.Append(bottomBorder1);
            tableCellBorders1.Append(rightBorder1);

            tableCellProperties.Append(tableCellWidth);
            tableCellProperties.Append(tableCellBorders1);

            TableCell tableCell = new TableCell();
            tableCell.Append(tableCellProperties);
            tableCell.Append(CreateTextParagraph(text));
            return tableCell;
        }
예제 #58
0
파일: main.cs 프로젝트: staherianYMCA/test
        static void Main(string[] args)
        {
            try
            {
                string
                    currentDirectory = System.IO.Directory.GetCurrentDirectory();

                currentDirectory = currentDirectory.Substring(0, currentDirectory.LastIndexOf("bin", currentDirectory.Length - 1));

                string
                    inputFileName = currentDirectory + "Word_tst.docx";

                #if TEST_STREAM
                Stream
                    stream = File.Open(inputFileName, FileMode.Open);
                #endif

                WordprocessingDocument
                    wordprocessingDocument = WordprocessingDocument.Open(
                    #if TEST_STREAM
                    stream
                    #else
                    inputFileName
                    #endif
                    , true);

                #if TEST_PARAGRAPH
                Body
                    body = wordprocessingDocument.MainDocumentPart.Document.Body;

                Paragraph
                    para = body.AppendChild(new Paragraph());

                Run
                    run = para.AppendChild(new Run());

                RunProperties
                    runProperties = run.AppendChild(new RunProperties(new Bold()));

                run.AppendChild(new Text("Test Open XML SDK"));
                #endif

                #if TEST_BOOKMARK
                IDictionary <String, BookmarkStart>
                bookmarkMap = new Dictionary <String, BookmarkStart>();

                foreach (BookmarkStart bookmarkStart in wordprocessingDocument.MainDocumentPart.RootElement.Descendants <BookmarkStart>())
                {
                    if (bookmarkStart.Name == "_GoBack")
                    {
                        continue;
                    }

                    bookmarkMap[bookmarkStart.Name] = bookmarkStart;
                }

                foreach (BookmarkStart bookmarkStart in bookmarkMap.Values)
                {
                    TableCell
                                       cell;

                    if ((cell = bookmarkStart.Parent.Parent as TableCell) != null)
                    {
                        TableRow
                            row;

                        if ((row = cell.Parent as TableRow) != null)
                        {
                            Table
                                table;

                            int
                                cellCount = row.Descendants <TableCell>().Count();

                            if ((table = row.Parent as Table) != null)
                            {
                                TableRow
                                    newTableRow = new TableRow();

                                for (int i = 0; i < cellCount; ++i)
                                {
                                    TableCell
                                        newTableCell = new TableCell();

                                    newTableCell.Append(new Paragraph(new Run(new Text(i.ToString()))));

                                    newTableRow.Append(newTableCell);
                                }

                                table.Append(newTableRow);
                            }
                        }
                    }

                    /*
                     * Run
                     *  bookmarkText = bookmarkStart.InsertAfterSelf(new Run(new Text("1234567890")));*/
                }
                #endif

                #if TEST_TABLE
                Table
                    table = new Table();

                TableProperties
                    tblProp = new TableProperties(
                    new TableBorders(
                        new TopBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new BottomBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new LeftBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new RightBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideHorizontalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideVerticalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                }
                        )
                    );

                table.AppendChild <TableProperties>(tblProp);

                TableRow
                    tr = new TableRow();

                TableCell
                    tc1 = new TableCell();

                tc1.Append(new TableCellProperties(new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "2400"
                }));
                tc1.Append(new Paragraph(new Run(new Text("some text"))));

                tr.Append(tc1);

                TableCell
                    tc2 = new TableCell(tc1.OuterXml);

                tr.Append(tc2);

                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Restart
                }));
                tc1.Append(new Paragraph(new Run(new Text("1"))));
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("21"))));
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Continue
                }));
                tc1.Append(new Paragraph());
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("22"))));
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Continue
                }));
                tc1.Append(new Paragraph());
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("23"))));
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Restart
                }));
                tc1.Append(new Paragraph(new Run(new Text("2"))));
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("24"))));
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Continue
                }));
                tc1.Append(new Paragraph());
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("25"))));
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties(new VerticalMerge()
                {
                    Val = MergedCellValues.Restart
                }));
                tr.Append(tc1);
                tc2 = new TableCell();
                tc2.Append(new TableCellProperties());
                tc2.Append(new Paragraph(new Run(new Text("26"))));
                tr.Append(tc2);
                table.Append(tr);

                wordprocessingDocument.MainDocumentPart.Document.Body.Append(table);

                table   = new Table();
                tblProp = new TableProperties(
                    new TableBorders(
                        new TopBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new BottomBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new LeftBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new RightBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideHorizontalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideVerticalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                }
                        )
                    );
                table.AppendChild <TableProperties>(tblProp);

                tc1.Append(table);
                tc1.Append(new Paragraph());

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties());
                tc1.Append(new Paragraph(new Run(new Text("some text"))));
                tr.Append(tc1);
                tc2 = new TableCell(tc1.OuterXml);
                tr.Append(tc2);
                table.Append(tr);

                wordprocessingDocument.MainDocumentPart.Document.Body.Append(new Paragraph(new Run(new Text("Paragraph"))));

                table   = new Table();
                tblProp = new TableProperties(
                    new TableBorders(
                        new TopBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new BottomBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new LeftBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new RightBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideHorizontalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                },
                        new InsideVerticalBorder()
                {
                    Val = new EnumValue <BorderValues>(BorderValues.Dashed), Size = 24
                }
                        )
                    );
                table.AppendChild <TableProperties>(tblProp);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties());
                tc1.Append(new Paragraph(new Run(new Text("some text"))));
                tr.Append(tc1);
                tc2 = new TableCell(tc1.OuterXml);
                tr.Append(tc2);
                tc2 = new TableCell(tc1.OuterXml);
                tr.Append(tc2);
                tc2 = new TableCell(tc1.OuterXml);
                tr.Append(tc2);
                table.Append(tr);

                tr  = new TableRow();
                tc1 = new TableCell();
                tc1.Append(new TableCellProperties());
                tc1.Append(new Paragraph(new Run(new Text("some text"))));
                tc1.Append(new GridSpan()
                {
                    Val = 2
                });
                tr.Append(tc1);
                tc2 = new TableCell(tc1.OuterXml);
                tr.Append(tc2);
                table.Append(tr);

                wordprocessingDocument.MainDocumentPart.Document.Body.Append(table);
                #endif

                wordprocessingDocument.Close();

                #if TEST_STREAM
                stream.Close();
                #endif
            }
            catch (Exception eException)
            {
                Console.WriteLine(eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + (eException.InnerException != null && !string.IsNullOrEmpty(eException.InnerException.Message) ? "InnerException.Message" + eException.InnerException.Message + Environment.NewLine : string.Empty) + "StackTrace:" + Environment.NewLine + eException.StackTrace);
                Console.ReadLine();
            }
        }
예제 #59
0
        private TableCell CreateUnderlineCell(int cellWidth)
        {
            TableCellProperties tableCellProperties8 = new TableCellProperties();
            TableCellWidth tableCellWidth8 = new TableCellWidth() { Width = cellWidth.ToString(), Type = TableWidthUnitValues.Dxa };

            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Nil };
            LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Nil };
            BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U };
            RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Nil };

            tableCellBorders1.Append(topBorder1);
            tableCellBorders1.Append(leftBorder1);
            tableCellBorders1.Append(bottomBorder1);
            tableCellBorders1.Append(rightBorder1);

            tableCellProperties8.Append(tableCellWidth8);
            tableCellProperties8.Append(tableCellBorders1);

            TableCell tableCell = new TableCell();
            tableCell.Append(tableCellProperties8);
            tableCell.Append(CreateEmptyParagraph());
            return tableCell;
        }
예제 #60
0
		// Creates an TableCell instance and adds its children.
		public static void AddPersonCell(this TableRow row, Person p, bool addEmployer)
		{
			TableCell tableCell1 = new TableCell();

			TableCellProperties tableCellProperties1 = new TableCellProperties();
			TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "3787", Type = TableWidthUnitValues.Dxa };

			tableCellProperties1.Append(tableCellWidth1);

			Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "005A43FA", RsidParagraphProperties = "005A43FA", RsidRunAdditionDefault = "005A43FA" };

			ParagraphProperties paragraphProperties1 = new ParagraphProperties();
			SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { Before = "111" };
			Indentation indentation1 = new Indentation() { Left = "95", Right = "95" };

			paragraphProperties1.Append(spacingBetweenLines1);
			paragraphProperties1.Append(indentation1);
			paragraph1.Append(paragraphProperties1);

			if (p != null)
			{
				Run run1 = new Run();
				Text text1 = new Text();
				var name = (p.TitleCode.HasValue() ? p.TitleCode + " " : "")
					+ (p.FirstName == "?" ? "" : p.FirstName + " ")
					+ (p.LastName == "?" ? "" : p.LastName);
				text1.Text = name;

				run1.Append(text1);

				paragraph1.Append(run1);

				Paragraph paragraph2 = null;
				if (addEmployer && p.EmployerOther.HasValue())
				{
					paragraph2 = new Paragraph()
					                       {
					                       	RsidParagraphAddition = "005A43FA",
					                       	RsidParagraphProperties = "005A43FA",
					                       	RsidRunAdditionDefault = "005A43FA"
					                       };

					ParagraphProperties paragraphProperties2 = new ParagraphProperties();
					Indentation indentation2 = new Indentation() { Left = "245", Right = "95", Hanging = "150" };

					paragraphProperties2.Append(indentation2);

					Run run2 = new Run();
					Text text2 = new Text();
					text2.Text = p.EmployerOther;

					run2.Append(text2);

					paragraph2.Append(paragraphProperties2);
					paragraph2.Append(run2);
				}

				Paragraph paragraph3 = new Paragraph()
				                       {
				                       	RsidParagraphAddition = "005A43FA",
				                       	RsidParagraphProperties = "005A43FA",
				                       	RsidRunAdditionDefault = "005A43FA"
				                       };

				ParagraphProperties paragraphProperties3 = new ParagraphProperties();
				Indentation indentation3 = new Indentation() {Left = "95", Right = "95"};

				paragraphProperties3.Append(indentation3);

				Run run3 = new Run();
				Text text3 = new Text();
				text3.Text = p.PrimaryAddress;

				run3.Append(text3);

				paragraph3.Append(paragraphProperties3);
				paragraph3.Append(run3);

				Paragraph paragraph3a = null;
				if (p.PrimaryAddress2.HasValue())
				{
					paragraph3a = new Paragraph()
					                        {
					                        	RsidParagraphAddition = "005A43FA",
					                        	RsidParagraphProperties = "005A43FA",
					                        	RsidRunAdditionDefault = "005A43FA"
					                        };

					ParagraphProperties paragraphProperties2 = new ParagraphProperties();
					Indentation indentation2 = new Indentation() {Left = "95", Right = "95"};

					paragraphProperties2.Append(indentation2);

					Run run2 = new Run();
					Text text2 = new Text();
					text2.Text = p.PrimaryAddress2;

					run2.Append(text2);

					paragraph3a.Append(paragraphProperties2);
					paragraph3a.Append(run2);
				}


				Paragraph paragraph4 = new Paragraph()
				                       {
				                       	RsidParagraphAddition = "005A43FA",
				                       	RsidParagraphProperties = "005A43FA",
				                       	RsidRunAdditionDefault = "005A43FA"
				                       };

				ParagraphProperties paragraphProperties4 = new ParagraphProperties();
				Indentation indentation4 = new Indentation() {Left = "95", Right = "95"};

				paragraphProperties4.Append(indentation4);

				Run run4 = new Run();
				Text text4 = new Text();
				text4.Text = p.CityStateZip;

				run4.Append(text4);

				paragraph4.Append(paragraphProperties4);
				paragraph4.Append(run4);

				tableCell1.Append(tableCellProperties1);
				tableCell1.Append(paragraph1);
				if (paragraph2 != null)
					tableCell1.Append(paragraph2);
				tableCell1.Append(paragraph3);
				if (paragraph3a != null)
					tableCell1.Append(paragraph3a);
				tableCell1.Append(paragraph4);
			}
			else
				tableCell1.Append(paragraph1);
			row.Append(tableCell1);
		}