public void Update(DocumentFormat.OpenXml.Wordprocessing.Tag tag, string value, MainDocumentPart mainPart) { string mainhtml = "<html><head><style type='text/css'>.catalogGeneralTable{border-collapse: collapse;text-align: left;} .catalogGeneralTable td, th{ padding: 5px; border: 1px solid #999999; } </style></head> <body style='font-family:Trebuchet MS;font-size:.9em;'>" + value + "</body></html>"; int blockLevelCounter = 1; string altChunkId = String.Format("AltChunkId{0}", altChunkIdCounter++); AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Html, altChunkId); using (Stream chunkStream = chunk.GetStream(FileMode.Create, FileAccess.Write)) { using (StreamWriter stringWriter = new StreamWriter(chunkStream, Encoding.UTF8)) //Encoding.UTF8 is important to remove special characters { stringWriter.Write(mainhtml); } } AltChunk altChunk = new AltChunk(); altChunk.Id = altChunkId; SdtBlock sdtBlock = tag.Ancestors <SdtBlock>().Single(); sdtBlock.InsertAt(altChunk, blockLevelCounter++); }
private void DeleteSdtBlockAndKeepContent(MainDocumentPart mainDocumentPart, string sdtBlockTag) { List <SdtBlock> sdtList = mainDocumentPart.Document.Descendants <SdtBlock>().ToList(); SdtBlock sdtA = null; foreach (SdtBlock sdt in sdtList) { if (sdt.SdtProperties.GetFirstChild <Tag>().Val.Value == sdtBlockTag) { sdtA = sdt; break; } } OpenXmlElement sdtc = sdtA.GetFirstChild <SdtContentBlock>(); OpenXmlElement parent = sdtA.Parent; OpenXmlElementList elements = sdtc.ChildElements; var mySdtc = new SdtContentBlock(sdtc.OuterXml); foreach (OpenXmlElement elem in elements) { string text = parent.FirstChild.InnerText; parent.Append((OpenXmlElement)elem.Clone()); } sdtA.Remove(); }
/// <summary> /// Gets the SDT content of content control. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public OpenXmlCompositeElement GetSdtContentOfContentControl(SdtElement element) { SdtRun sdtRunELement = element as SdtRun; SdtBlock sdtBlockElement = element as SdtBlock; SdtCell sdtCellElement = element as SdtCell; SdtRow sdtRowElement = element as SdtRow; if (sdtRunELement != null) { var contentRun = sdtRunELement.SdtContentRun; if (contentRun == null && sdtRunELement.FirstChild is SdtRun) { contentRun = (sdtRunELement.FirstChild as SdtRun).SdtContentRun; } return(contentRun); } else if (sdtBlockElement != null) { return(sdtBlockElement.SdtContentBlock); } else if (sdtCellElement != null) { return(sdtCellElement.SdtContentCell); } else if (sdtRowElement != null) { return(sdtRowElement.SdtContentRow); } return(null); }
/// <summary> /// Get ContentControl from a ContentControl /// </summary> /// <param name="pBlock">Root Content Control</param> /// <param name="pTag">ContentControl tag to find</param> /// <returns>The ContentControl</returns> public static SdtBlock GetContentControl(SdtBlock pBlock, string pTag) { SdtBlock cc = pBlock.Descendants<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == pTag).Single(); return cc; }
/// <summary> /// Gets the SDT content of content control. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public OpenXmlCompositeElement GetSdtContentOfContentControl(SdtElement element) { SdtRun sdtRunELement = element as SdtRun; SdtBlock sdtBlockElement = element as SdtBlock; SdtCell sdtCellElement = element as SdtCell; SdtRow sdtRowElement = element as SdtRow; if (sdtRunELement != null) { return(sdtRunELement.SdtContentRun); } else if (sdtBlockElement != null) { return(sdtBlockElement.SdtContentBlock); } else if (sdtCellElement != null) { return(sdtCellElement.SdtContentCell); } else if (sdtRowElement != null) { return(sdtRowElement.SdtContentRow); } return(null); }
private static int ReplaceHelper(Stream template, bool hasNestedControls) { int replacedElements = 0; using (WordprocessingDocument doc = WordprocessingDocument.Open(template, true)) { MainDocumentPart main = doc.MainDocumentPart; var customXmlElements = main.Document.Descendants<CustomXmlElement>().Where(cb => !cb.Descendants<CustomXmlElement>().Any()).ToList(); foreach (var customXmlElement in customXmlElements) { string elementXmlPath = String.Concat(customXmlElement.Ancestors<CustomXmlElement>().Select(ce => ce.GetAttribute("element", customXmlElement.NamespaceUri).Value + "/").ToArray().Reverse()), title = customXmlElement.GetAttribute("element", customXmlElement.NamespaceUri).Value, tagName; OpenXmlElement newElement = null; Random random = new Random(); if(!hasNestedControls){ tagName = elementXmlPath + customXmlElement.GetAttribute("element", customXmlElement.NamespaceUri).Value; } else{ tagName = title; } int newId = random.Next(Int32.MinValue, Int32.MaxValue); SdtProperties sdtPr = new SdtProperties( new SdtAlias() { Val = title }, new Tag() { Val = tagName }, new SdtId() { Val = newId }); if (customXmlElement.GetType() == typeof(CustomXmlBlock)) { SdtContentBlock sdtContent = new SdtContentBlock(); TransferChildElements(customXmlElement, sdtContent); newElement = new SdtBlock(sdtPr, sdtContent); } else if (customXmlElement.GetType() == typeof(CustomXmlRun)) { SdtContentRun sdtContent = new SdtContentRun(); TransferChildElements(customXmlElement, sdtContent); newElement = new SdtRun(sdtPr, sdtContent); } else if (customXmlElement.GetType() == typeof(CustomXmlRow)) { SdtContentRow sdtContent = new SdtContentRow(); TransferChildElements(customXmlElement, sdtContent); newElement = new SdtRow(sdtPr, sdtContent); } else if (customXmlElement.GetType() == typeof(CustomXmlCell)) { SdtContentCell sdtContent = new SdtContentCell(); TransferChildElements(customXmlElement, sdtContent); newElement = new SdtCell(sdtPr, sdtContent); } customXmlElement.Parent.InsertAfter(newElement, customXmlElement); customXmlElement.Remove(); } replacedElements = customXmlElements.Count; } return replacedElements; }
// ATTENTION : dont work with google doc use CreateParagraph_PageNumber() public static SdtBlock CreatePageNumberBlock(string styleId, string text) { // SdtBlock, <w:sdt> SdtBlock sdtBlock = new SdtBlock(); // Structured Document Tag Properties, <w:sdtPr> SdtProperties sdtProperties = new SdtProperties(); // SdtContentDocPartObject, <w:docPartObj> SdtContentDocPartObject docPartObject = new SdtContentDocPartObject(); // Document Part Gallery Filter, <w:docPartGallery> docPartObject.AppendChild(new DocPartGallery { Val = "Page Numbers (Bottom of Page)" }); docPartObject.AppendChild(new DocPartUnique()); sdtProperties.AppendChild(docPartObject); sdtBlock.SdtProperties = sdtProperties; // Block-Level Structured Document Tag Content, <w:sdtContent> SdtContentBlock sdtContentBlock = new SdtContentBlock(); Paragraph paragraph = new Paragraph(); paragraph.ParagraphProperties = new ParagraphProperties { ParagraphStyleId = new ParagraphStyleId() { Val = styleId } }; Run run = paragraph.AppendChild(new Run()); run.AppendChild(new TabStop()); run.AppendChild(new DW.Text { Text = text }); run.AppendChild(new TabStop()); run.AppendChild(new DW.Text { Text = "page ", Space = SpaceProcessingModeValues.Preserve }); // Complex Field Character, <w:fldChar> run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.Begin }); // Field Code, <w:instrText> // "PAGE \\* MERGEFORMAT" "PAGE" run.AppendChild(new FieldCode("PAGE \\* MERGEFORMAT")); run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.Separate }); run.AppendChild(new DW.Text { Text = "" }); run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.End }); sdtContentBlock.AppendChild(paragraph); sdtBlock.SdtContentBlock = sdtContentBlock; return(sdtBlock); }
/// <summary> /// Get the DocumentFormat.OpenXml.Wordprocessing.Table from the tag /// </summary> public DocumentFormat.OpenXml.Wordprocessing.Table GetTable(string tag) { string tblTag = "StockTableTag"; MainDocumentPart mainPart = Document.MainDocumentPart; //StockService.baseDS.stockCodeDataTable tbl = Gateway.PriceData.getPriceDataToDay(); SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where (r => r.SdtProperties.GetFirstChild <Tag>().Val == tblTag).Single(); // This should return only one table. DocumentFormat.OpenXml.Wordprocessing.Table theTable = ccWithTable.Descendants <DocumentFormat.OpenXml.Wordprocessing.Table>().Single(); return(theTable); }
private void InsertContentControl(Body body, string tag, string contentText) { //praragraph to be added to the rich text content control Run run = new Run(new Text(contentText)); Paragraph paragraph = new Paragraph(run); SdtProperties sdtPr = new SdtProperties(new Tag { Val = tag }); SdtContentBlock sdtCBlock = new SdtContentBlock(paragraph); SdtBlock sdtBlock = new SdtBlock(sdtPr, sdtCBlock); body.AppendChild(sdtBlock); }
public static void replacePicture(string filePath) { using (WordprocessingDocument doc = WordprocessingDocument.Open(filePath, true)) { SdtBlock cc = doc.MainDocumentPart.Document.Body.Descendants <SdtBlock>() .FirstOrDefault(c => { SdtProperties p = c.Elements <SdtProperties>().FirstOrDefault(); if (p != null) { // Is it a picture content control? SdtContentPicture pict = p.Elements <SdtContentPicture>().FirstOrDefault(); // Get the alias. SdtAlias a = p.Elements <SdtAlias>().FirstOrDefault(); if (pict != null) { return(true); } } return(false); }); string embed = null; if (cc != null) { Drawing dr = cc.Descendants <Drawing>().FirstOrDefault(); if (dr != null) { Blip blip = dr.Descendants <Blip>().FirstOrDefault(); if (blip != null) { embed = blip.Embed; } } } if (embed != null) { IdPartPair idpp = doc.MainDocumentPart.Parts .Where(pa => pa.RelationshipId == embed).FirstOrDefault(); if (idpp != null) { ImagePart ip = (ImagePart)idpp.OpenXmlPart; using (FileStream fileStream = File.Open("test.png", FileMode.Open)) ip.FeedData(fileStream); } } } }
public static IEnumerable <OpenXmlCompositeElement> RenderableChildren(this OpenXmlElement xmlElement) { return(xmlElement .ChildElements .Where(c => c is Paragraph || c is Table || c is SdtBlock) .SelectMany(c => { return c switch { SdtBlock block => block.SdtContentBlock.ChildElements.OfType <OpenXmlCompositeElement>().ToArray(), _ => new[] { c } }; }) .Cast <OpenXmlCompositeElement>()); }
public static Paragraph ReplaceToParagraph(this SdtBlock Block, string?Content = null) { var paragraph = Block.SdtContentBlock !.GetFirstChild <Paragraph>() !; paragraph.Remove(); if (Content is not null) { paragraph.GetFirstChild <Run>() !.Text(Content); } Block.InsertAfterSelf(paragraph); Block.Remove(); return(paragraph); }
public void AnalyseReport(WordprocessingDocument wordDoc) { wDoc = wordDoc; //PROCESSING STRING EXPRESSION IN WORD this.SearchAndReplace(wordDoc, "", "", true); //PROCESSING StockTable_Tag string tblTag = "StockTable_Tag"; MainDocumentPart mainPart = wordDoc.MainDocumentPart; //StockService.baseDS.stockCodeDataTable tbl = Gateway.PriceData.getPriceDataToDay(); SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where (r => r.SdtProperties.GetFirstChild <Tag>().Val == tblTag).Single(); // This should return only one table. Table theTable = ccWithTable.Descendants <Table>().Single(); // Get the last row in the table. TableRow theRow = theTable.Elements <TableRow>().Last(); StockReport stockReport = StockReport.getInstance(); databases.tmpDS.dataVarrianceDataTable tbl = stockReport.TopBiggestChangeTable(); foreach (databases.tmpDS.dataVarrianceRow item in tbl.Rows) { try { TableRow rowCopy = (TableRow)theRow.CloneNode(true); rowCopy.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run(new Text(item.code.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run(new Text(String.Format("{0:0,0}", item.val1 * 1000) + " VNĐ")))); rowCopy.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run(new Text(String.Format("{0:0,0}", item.val2 * 1000) + " VNĐ")))); rowCopy.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run(new Text(String.Format("{0:0,0}", item.value * 1000) + " VNĐ")))); rowCopy.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run(new Text((item.percent / 100).ToString("P"))))); theTable.AppendChild(rowCopy); } catch (Exception ex) { continue; } } theTable.RemoveChild(theRow); }
protected bool GetParentContainer(ref SdtElement parentContainer, string placeholder) { MainDocumentPart mainDocumentPart = parentContainer.Ancestors <Document>().First().MainDocumentPart; KeyValuePair <string, string> nameToValue = this.customXmlPartHelper.GetNameToValueCollectionFromElementForType(mainDocumentPart, DocumentContainerPlaceholdersNode, NodeType.Element).FirstOrDefault(f => f.Key.Equals(placeholder)); bool isRefresh = !string.IsNullOrEmpty(nameToValue.Value); if (isRefresh) { SdtElement parentElementFromCustomXmlPart = new SdtBlock(nameToValue.Value); parentContainer.Parent.ReplaceChild(parentElementFromCustomXmlPart, parentContainer); parentContainer = parentElementFromCustomXmlPart; } else { Dictionary <string, string> nameToValueCollection = new Dictionary <string, string> { { placeholder, parentContainer.OuterXml } }; this.customXmlPartHelper.SetElementFromNameToValueCollectionForType(mainDocumentPart, DocumentRootNode, DocumentContainerPlaceholdersNode, nameToValueCollection, NodeType.Element); } return(isRefresh); }
public static void FillTextBox(this SdtBlock sdtBlock, string newText) { // Get Textbox content SdtContentBlock content = sdtBlock.Descendants <SdtContentBlock>().FirstOrDefault(); if (content != null) { // Retrieve old paragraph to get the current style of text Paragraph oldParagraph = content.Elements <Paragraph>().FirstOrDefault(); // Create a new text var paragraph = CreateParagraph(oldParagraph, newText); // Replace old text with new one if (oldParagraph != null) { content.ReplaceChild(paragraph, oldParagraph); } else { content.Append(paragraph); } } }
public void Update(DocumentFormat.OpenXml.Wordprocessing.Tag tag, DataView dataView, bool?completePage, int?linesInPage, MainDocumentPart mainPart) { // This should return only one table. SdtBlock sdtBlock = tag.Ancestors <SdtBlock>().Single(); Table theTable = sdtBlock.Descendants <Table>().Single(); var tableRows = theTable.Elements <TableRow>().ToList(); TableRow theRow = tableRows.Last(); TableRow headerRow = tableRows.First(); Orientation orientation = theRow.InnerText.ToLower().StartsWith("v") ? Orientation.Vertical : Orientation.Horizontal; for (int i = tableRows.Count() - 1; i >= 1; i--) { TableRow row = tableRows[i]; theTable.RemoveChild(row); } var rowCells = theRow.Descendants <TableCell>().ToList(); for (int j = 0; j < rowCells.Count; j++) { //TableCell cell = rowCells[j]; theRow.Descendants <TableCell>().ElementAt(j).RemoveAllChildren <Paragraph>(); } var headerCells = headerRow.Descendants <TableCell>().ToList(); int totaLines = 0; int rowCount = 0; if (orientation == Orientation.Horizontal) { foreach (DataRowView row in dataView) { TableRow rowCopy = (TableRow)theRow.CloneNode(true); for (int j = 0; j < headerCells.Count; j++) { //TableCell cell = headerCells[j]; //string value = string.Empty; //value = row.Row[j].ToString(); //rowCopy.Descendants<TableCell>().ElementAt(j).Append(new Paragraph //(new Run(new Text(value)))); rowCopy.Descendants <TableCell>().ElementAt(j).Append(GetElement(dataView, row.Row, j, mainPart)); } theTable.AppendChild(rowCopy); rowCount++; if (completePage.HasValue && completePage.Value && linesInPage.HasValue) { totaLines += GetRowLines(theTable, rowCopy); } } } else { foreach (DataRowView row in dataView) { for (int j = 0; j < headerCells.Count; j++) { TableRow rowCopy = (TableRow)theRow.CloneNode(true); rowCopy.Descendants <TableCell>().ElementAt(0).Append(GetElement(dataView, row.Row, j, mainPart)); rowCopy.Descendants <TableCell>().ElementAt(1).Append(new Paragraph(new Run(new Text("")))); theTable.AppendChild(rowCopy); rowCount++; if (completePage.HasValue && completePage.Value && linesInPage.HasValue) { totaLines += GetRowLines(theTable, rowCopy); } } } } //if (orientation == Orientation.Horizontal) //{ if (completePage.HasValue && completePage.Value && linesInPage.HasValue) { for (int i = totaLines % linesInPage.Value; i < linesInPage.Value; i++) { TableRow rowCopy = (TableRow)theRow.CloneNode(true); for (int j = 0; j < headerCells.Count; j++) { string value = string.Empty; TableCell cell = headerCells[j]; rowCopy.Descendants <TableCell>().ElementAt(j).Append(new Paragraph (new Run(new Text(value)))); } theTable.AppendChild(rowCopy); } } //} }
/// <summary> /// Fill data object into word file that has arrBytesSource data. /// </summary> /// <param name="dataInputObject"></param> /// <param name="arrBytesSource"></param> /// <returns>The MemoryStream object.</returns> public Stream FillDataObject(object dataInputObject, byte[] arrBytesSource) { MemoryStream memoryStream = null; try { if (dataInputObject != null) { if (arrBytesSource != null && arrBytesSource.Length > 0) { #region Fix bug TFS #1971 //memoryStream = new MemoryStream(arrBytesSource, true); memoryStream = new MemoryStream(); memoryStream.Write(arrBytesSource, 0, arrBytesSource.Length); memoryStream.Position = 0; #endregion // Use OpenXML to process var dictionary = GetDictionaryFromObject(dataInputObject); using (WordprocessingDocument word = WordprocessingDocument.Open(memoryStream, true)) { var part = word.MainDocumentPart; var elements = part.Document.Descendants <SdtElement>().ToList(); foreach (SdtElement element in elements) { SdtAlias alias = element.Descendants <SdtAlias>().FirstOrDefault(); if (alias != null) { // Get title of content control var title = alias.Val.Value; if (dictionary.ContainsKey(title)) { object value = dictionary[title]; if (value != null) { if (element.ToString().Equals("DocumentFormat.OpenXml.Wordprocessing.SdtRun")) { SdtRun run = element as SdtRun; if (run != null) { if (value is bool) { SdtContentCheckBox contentCheckBox = run.Descendants <SdtContentCheckBox>().FirstOrDefault(); if (contentCheckBox != null) { if (string.Compare(value.ToString(), Boolean.TrueString, true) == 0) { contentCheckBox.Checked.Val = string.Compare(value.ToString(), Boolean.TrueString, true) == 0 ? OnOffValues.One : OnOffValues.Zero; SdtContentRun contentRun = run.Descendants <SdtContentRun>().FirstOrDefault(); if (contentRun != null) { Run xRun = contentRun.Descendants <Run>().FirstOrDefault(); if (xRun != null) { SymbolChar checkedSymbolChar = xRun.Descendants <SymbolChar>().FirstOrDefault(); if (checkedSymbolChar != null) { checkedSymbolChar.Char = new HexBinaryValue(CheckedSymbolChar); } } } } } } else { SdtContentRun contentRun = run.Descendants <SdtContentRun>().FirstOrDefault(); Run xRun = contentRun.Descendants <Run>().FirstOrDefault(); if (xRun == null) { contentRun.AppendChild(new Run()); xRun = contentRun.Descendants <Run>().FirstOrDefault(); } Text text = xRun.Descendants <Text>().FirstOrDefault(); if (text == null) { xRun.AppendChild(new Text(value.ToString())); text = xRun.Descendants <Text>().FirstOrDefault(); } text.Text = value.ToString(); } } } else if (element.ToString().Equals("DocumentFormat.OpenXml.Wordprocessing.SdtBlock")) { SdtBlock block = element as SdtBlock; if (block != null) { if (value is bool) { SdtContentCheckBox contentCheckBox = block.Descendants <SdtContentCheckBox>().FirstOrDefault(); if (contentCheckBox != null) { if (string.Compare(value.ToString(), Boolean.TrueString, true) == 0) { contentCheckBox.Checked.Val = string.Compare(value.ToString(), Boolean.TrueString, true) == 0 ? OnOffValues.One : OnOffValues.Zero; SdtContentRun contentRun = block.Descendants <SdtContentRun>().FirstOrDefault(); if (contentRun != null) { Run xRun = contentRun.Descendants <Run>().FirstOrDefault(); if (xRun != null) { SymbolChar checkedSymbolChar = xRun.Descendants <SymbolChar>().FirstOrDefault(); if (checkedSymbolChar != null) { checkedSymbolChar.Char = new HexBinaryValue(CheckedSymbolChar); } } } } } } else { SdtContentBlock contentBlock = block.Descendants <SdtContentBlock>().FirstOrDefault(); Run xRun = contentBlock.Descendants <Run>().FirstOrDefault(); if (xRun == null) { contentBlock.AppendChild(new Run()); xRun = contentBlock.Descendants <Run>().FirstOrDefault(); } Text text = xRun.Descendants <Text>().FirstOrDefault(); if (text == null) { xRun.AppendChild(new Text(value.ToString())); text = xRun.Descendants <Text>().FirstOrDefault(); } text.Text = value.ToString(); } } } } } } } part.Document.Save(); } } } } catch (Exception ex) { ULSLogging.LogError(ex); throw ex; } return(memoryStream); }
/// <summary> /// FillDataObject /// </summary> /// <param name="dataInputObject"></param> /// <param name="stream"></param> public void FillDataObject(object dataInputObject, Stream stream) { if (dataInputObject != null) { if (stream != null && stream.CanRead && stream.CanWrite) { // Use OpenXML to process var dictionary = GetDictionaryFromObject(dataInputObject); using (WordprocessingDocument word = WordprocessingDocument.Open(stream, true)) { var part = word.MainDocumentPart; var elements = part.Document.Descendants <SdtElement>().ToList(); foreach (SdtElement element in elements) { SdtAlias alias = element.Descendants <SdtAlias>().FirstOrDefault(); if (alias != null) { // Get title of content control var title = alias.Val.Value; if (dictionary.ContainsKey(title)) { object value = dictionary[title]; if (element.ToString().Equals("DocumentFormat.OpenXml.Wordprocessing.SdtRun")) { SdtRun run = element as SdtRun; if (run != null) { SdtContentRun contentRun = run.Descendants <SdtContentRun>().FirstOrDefault(); Run xRun = contentRun.Descendants <Run>().FirstOrDefault(); if (xRun == null) { contentRun.AppendChild(new Run()); xRun = contentRun.Descendants <Run>().FirstOrDefault(); } Text text = xRun.Descendants <Text>().FirstOrDefault(); if (text == null) { xRun.AppendChild(new Text(value.ToString())); text = xRun.Descendants <Text>().FirstOrDefault(); } text.Text = value.ToString(); } } else if (element.ToString().Equals("DocumentFormat.OpenXml.Wordprocessing.SdtBlock")) { SdtBlock block = element as SdtBlock; if (block != null) { SdtContentBlock contentBlock = block.Descendants <SdtContentBlock>().FirstOrDefault(); Run xRun = contentBlock.Descendants <Run>().FirstOrDefault(); if (xRun == null) { contentBlock.AppendChild(new Run()); xRun = contentBlock.Descendants <Run>().FirstOrDefault(); } Text text = xRun.Descendants <Text>().FirstOrDefault(); if (text == null) { xRun.AppendChild(new Text(value.ToString())); text = xRun.Descendants <Text>().FirstOrDefault(); } text.Text = value.ToString(); } } } } } part.Document.Save(); } } } }
// Generates content of mainDocumentPart1. private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1) { Document document1 = new Document(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" } }; document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); document1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2010/11/wordml"); document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Body body1 = new Body(); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); RunProperties runProperties1 = new RunProperties(); RunFonts runFonts1 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties1.Append(runFonts1); SdtAlias sdtAlias1 = new SdtAlias(){ Val = "Test1.1.1" }; Tag tag1 = new Tag(){ Val = "Test1.1.1" }; SdtId sdtId1 = new SdtId(){ Val = -1832063964 }; SdtPlaceholder sdtPlaceholder1 = new SdtPlaceholder(); DocPartReference docPartReference1 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder1.Append(docPartReference1); ShowingPlaceholder showingPlaceholder1 = new ShowingPlaceholder(); SdtContentText sdtContentText1 = new SdtContentText(); sdtProperties1.Append(runProperties1); sdtProperties1.Append(sdtAlias1); sdtProperties1.Append(tag1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtPlaceholder1); sdtProperties1.Append(showingPlaceholder1); sdtProperties1.Append(sdtContentText1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00535C5E", RsidRunAdditionDefault = "000010BA" }; Run run1 = new Run(){ RsidRunProperties = "003E0DED" }; RunProperties runProperties2 = new RunProperties(); RunStyle runStyle1 = new RunStyle(){ Val = "PlaceholderText" }; runProperties2.Append(runStyle1); Text text1 = new Text(); text1.Text = "Click here to enter text."; run1.Append(runProperties2); run1.Append(text1); paragraph1.Append(run1); sdtContentBlock1.Append(paragraph1); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); RunProperties runProperties3 = new RunProperties(); RunFonts runFonts2 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties3.Append(runFonts2); SdtAlias sdtAlias2 = new SdtAlias(){ Val = "Test1.1.2" }; Tag tag2 = new Tag(){ Val = "Test1.1.2" }; SdtId sdtId2 = new SdtId(){ Val = -2043657734 }; SdtPlaceholder sdtPlaceholder2 = new SdtPlaceholder(); DocPartReference docPartReference2 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder2.Append(docPartReference2); SdtContentText sdtContentText2 = new SdtContentText(); sdtProperties2.Append(runProperties3); sdtProperties2.Append(sdtAlias2); sdtProperties2.Append(tag2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtPlaceholder2); sdtProperties2.Append(sdtContentText2); SdtEndCharProperties sdtEndCharProperties2 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph2 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run2 = new Run(); RunProperties runProperties4 = new RunProperties(); RunFonts runFonts3 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties4.Append(runFonts3); Text text2 = new Text(); text2.Text = "Test string"; run2.Append(runProperties4); run2.Append(text2); paragraph2.Append(run2); sdtContentBlock2.Append(paragraph2); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtEndCharProperties2); sdtBlock2.Append(sdtContentBlock2); SdtBlock sdtBlock3 = new SdtBlock(); SdtProperties sdtProperties3 = new SdtProperties(); RunProperties runProperties5 = new RunProperties(); RunFonts runFonts4 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties5.Append(runFonts4); SdtAlias sdtAlias3 = new SdtAlias(){ Val = "Test1.2.1" }; Tag tag3 = new Tag(){ Val = "Test1.2.1" }; SdtId sdtId3 = new SdtId(){ Val = 401180698 }; SdtPlaceholder sdtPlaceholder3 = new SdtPlaceholder(); DocPartReference docPartReference3 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder3.Append(docPartReference3); SdtContentText sdtContentText3 = new SdtContentText(); sdtProperties3.Append(runProperties5); sdtProperties3.Append(sdtAlias3); sdtProperties3.Append(tag3); sdtProperties3.Append(sdtId3); sdtProperties3.Append(sdtPlaceholder3); sdtProperties3.Append(sdtContentText3); SdtEndCharProperties sdtEndCharProperties3 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock3 = new SdtContentBlock(); Paragraph paragraph3 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run3 = new Run(); RunProperties runProperties6 = new RunProperties(); RunFonts runFonts5 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties6.Append(runFonts5); Text text3 = new Text(); text3.Text = "Appearance1"; run3.Append(runProperties6); run3.Append(text3); paragraph3.Append(run3); sdtContentBlock3.Append(paragraph3); sdtBlock3.Append(sdtProperties3); sdtBlock3.Append(sdtEndCharProperties3); sdtBlock3.Append(sdtContentBlock3); SdtBlock sdtBlock4 = new SdtBlock(); SdtProperties sdtProperties4 = new SdtProperties(); RunProperties runProperties7 = new RunProperties(); RunFonts runFonts6 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties7.Append(runFonts6); SdtAlias sdtAlias4 = new SdtAlias(){ Val = "Test1.2.2" }; Tag tag4 = new Tag(){ Val = "Test1.2.2" }; SdtId sdtId4 = new SdtId(){ Val = 2096980748 }; SdtPlaceholder sdtPlaceholder4 = new SdtPlaceholder(); DocPartReference docPartReference4 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder4.Append(docPartReference4); W15.Appearance appearance1 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags }; SdtContentText sdtContentText4 = new SdtContentText(); sdtProperties4.Append(runProperties7); sdtProperties4.Append(sdtAlias4); sdtProperties4.Append(tag4); sdtProperties4.Append(sdtId4); sdtProperties4.Append(sdtPlaceholder4); sdtProperties4.Append(appearance1); sdtProperties4.Append(sdtContentText4); SdtEndCharProperties sdtEndCharProperties4 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock4 = new SdtContentBlock(); Paragraph paragraph4 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run4 = new Run(); RunProperties runProperties8 = new RunProperties(); RunFonts runFonts7 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties8.Append(runFonts7); Text text4 = new Text(); text4.Text = "Appearance2"; run4.Append(runProperties8); run4.Append(text4); paragraph4.Append(run4); sdtContentBlock4.Append(paragraph4); sdtBlock4.Append(sdtProperties4); sdtBlock4.Append(sdtEndCharProperties4); sdtBlock4.Append(sdtContentBlock4); SdtBlock sdtBlock5 = new SdtBlock(); SdtProperties sdtProperties5 = new SdtProperties(); RunProperties runProperties9 = new RunProperties(); RunFonts runFonts8 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties9.Append(runFonts8); SdtAlias sdtAlias5 = new SdtAlias(){ Val = "Test1.2.3" }; Tag tag5 = new Tag(){ Val = "Test1.2.3" }; SdtId sdtId5 = new SdtId(){ Val = -343394056 }; SdtPlaceholder sdtPlaceholder5 = new SdtPlaceholder(); DocPartReference docPartReference5 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder5.Append(docPartReference5); W15.Appearance appearance2 = new W15.Appearance(){ Val = W15.SdtAppearance.Hidden }; SdtContentText sdtContentText5 = new SdtContentText(); sdtProperties5.Append(runProperties9); sdtProperties5.Append(sdtAlias5); sdtProperties5.Append(tag5); sdtProperties5.Append(sdtId5); sdtProperties5.Append(sdtPlaceholder5); sdtProperties5.Append(appearance2); sdtProperties5.Append(sdtContentText5); SdtEndCharProperties sdtEndCharProperties5 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock5 = new SdtContentBlock(); Paragraph paragraph5 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run5 = new Run(); RunProperties runProperties10 = new RunProperties(); RunFonts runFonts9 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties10.Append(runFonts9); Text text5 = new Text(); text5.Text = "Appearance3"; run5.Append(runProperties10); run5.Append(text5); paragraph5.Append(run5); sdtContentBlock5.Append(paragraph5); sdtBlock5.Append(sdtProperties5); sdtBlock5.Append(sdtEndCharProperties5); sdtBlock5.Append(sdtContentBlock5); SdtBlock sdtBlock6 = new SdtBlock(); SdtProperties sdtProperties6 = new SdtProperties(); RunProperties runProperties11 = new RunProperties(); RunFonts runFonts10 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties11.Append(runFonts10); SdtAlias sdtAlias6 = new SdtAlias(){ Val = "Test1.3.1" }; Tag tag6 = new Tag(){ Val = "Test1.3.1" }; SdtId sdtId6 = new SdtId(){ Val = 1119424041 }; SdtPlaceholder sdtPlaceholder6 = new SdtPlaceholder(); DocPartReference docPartReference6 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder6.Append(docPartReference6); SdtContentText sdtContentText6 = new SdtContentText(); sdtProperties6.Append(runProperties11); sdtProperties6.Append(sdtAlias6); sdtProperties6.Append(tag6); sdtProperties6.Append(sdtId6); sdtProperties6.Append(sdtPlaceholder6); sdtProperties6.Append(sdtContentText6); SdtEndCharProperties sdtEndCharProperties6 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock6 = new SdtContentBlock(); Paragraph paragraph6 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run6 = new Run(); RunProperties runProperties12 = new RunProperties(); RunFonts runFonts11 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties12.Append(runFonts11); Text text6 = new Text(); text6.Text = "Color Content Control1"; run6.Append(runProperties12); run6.Append(text6); paragraph6.Append(run6); sdtContentBlock6.Append(paragraph6); sdtBlock6.Append(sdtProperties6); sdtBlock6.Append(sdtEndCharProperties6); sdtBlock6.Append(sdtContentBlock6); SdtBlock sdtBlock7 = new SdtBlock(); SdtProperties sdtProperties7 = new SdtProperties(); RunProperties runProperties13 = new RunProperties(); RunFonts runFonts12 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties13.Append(runFonts12); SdtAlias sdtAlias7 = new SdtAlias(){ Val = "Test1.3.2" }; Tag tag7 = new Tag(){ Val = "Test1.3.2" }; SdtId sdtId7 = new SdtId(){ Val = 550972260 }; SdtPlaceholder sdtPlaceholder7 = new SdtPlaceholder(); DocPartReference docPartReference7 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" }; sdtPlaceholder7.Append(docPartReference7); W15.Color color1 = new W15.Color(){ Val = "0000FF" }; SdtContentText sdtContentText7 = new SdtContentText(); sdtProperties7.Append(runProperties13); sdtProperties7.Append(sdtAlias7); sdtProperties7.Append(tag7); sdtProperties7.Append(sdtId7); sdtProperties7.Append(sdtPlaceholder7); sdtProperties7.Append(color1); sdtProperties7.Append(sdtContentText7); SdtEndCharProperties sdtEndCharProperties7 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock7 = new SdtContentBlock(); Paragraph paragraph7 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run7 = new Run(); RunProperties runProperties14 = new RunProperties(); RunFonts runFonts13 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties14.Append(runFonts13); Text text7 = new Text(); text7.Text = "Color Content Control2"; run7.Append(runProperties14); run7.Append(text7); paragraph7.Append(run7); sdtContentBlock7.Append(paragraph7); sdtBlock7.Append(sdtProperties7); sdtBlock7.Append(sdtEndCharProperties7); sdtBlock7.Append(sdtContentBlock7); SdtBlock sdtBlock8 = new SdtBlock(); SdtProperties sdtProperties8 = new SdtProperties(); RunProperties runProperties15 = new RunProperties(); RunFonts runFonts14 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties15.Append(runFonts14); SdtAlias sdtAlias8 = new SdtAlias(){ Val = "Test1.4.1" }; Tag tag8 = new Tag(){ Val = "Test1.4.1" }; SdtId sdtId8 = new SdtId(){ Val = 1758249604 }; W15.SdtRepeatedSection sdtRepeatedSection1 = new W15.SdtRepeatedSection(); sdtProperties8.Append(runProperties15); sdtProperties8.Append(sdtAlias8); sdtProperties8.Append(tag8); sdtProperties8.Append(sdtId8); sdtProperties8.Append(sdtRepeatedSection1); SdtEndCharProperties sdtEndCharProperties8 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock8 = new SdtContentBlock(); SdtBlock sdtBlock9 = new SdtBlock(); SdtProperties sdtProperties9 = new SdtProperties(); RunProperties runProperties16 = new RunProperties(); RunFonts runFonts15 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties16.Append(runFonts15); SdtId sdtId9 = new SdtId(){ Val = 481433089 }; SdtPlaceholder sdtPlaceholder8 = new SdtPlaceholder(); DocPartReference docPartReference8 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" }; sdtPlaceholder8.Append(docPartReference8); ShowingPlaceholder showingPlaceholder2 = new ShowingPlaceholder(); W15.SdtRepeatedSectionItem sdtRepeatedSectionItem1 = new W15.SdtRepeatedSectionItem(); sdtProperties9.Append(runProperties16); sdtProperties9.Append(sdtId9); sdtProperties9.Append(sdtPlaceholder8); sdtProperties9.Append(showingPlaceholder2); sdtProperties9.Append(sdtRepeatedSectionItem1); SdtEndCharProperties sdtEndCharProperties9 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock9 = new SdtContentBlock(); Paragraph paragraph8 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; Run run8 = new Run(){ RsidRunProperties = "003E0DED" }; RunProperties runProperties17 = new RunProperties(); RunStyle runStyle2 = new RunStyle(){ Val = "PlaceholderText" }; runProperties17.Append(runStyle2); Text text8 = new Text(); text8.Text = "Enter any content that you want to repeat, including other content controls. You can also insert this control around table rows in order to repeat parts of a table."; run8.Append(runProperties17); run8.Append(text8); paragraph8.Append(run8); sdtContentBlock9.Append(paragraph8); sdtBlock9.Append(sdtProperties9); sdtBlock9.Append(sdtEndCharProperties9); sdtBlock9.Append(sdtContentBlock9); sdtContentBlock8.Append(sdtBlock9); sdtBlock8.Append(sdtProperties8); sdtBlock8.Append(sdtEndCharProperties8); sdtBlock8.Append(sdtContentBlock8); SdtBlock sdtBlock10 = new SdtBlock(); SdtProperties sdtProperties10 = new SdtProperties(); RunProperties runProperties18 = new RunProperties(); RunFonts runFonts16 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties18.Append(runFonts16); SdtAlias sdtAlias9 = new SdtAlias(){ Val = "Test1.4.2" }; Tag tag9 = new Tag(){ Val = "Test1.4.2" }; SdtId sdtId10 = new SdtId(){ Val = -78606169 }; W15.SdtRepeatedSection sdtRepeatedSection2 = new W15.SdtRepeatedSection(); sdtProperties10.Append(runProperties18); sdtProperties10.Append(sdtAlias9); sdtProperties10.Append(tag9); sdtProperties10.Append(sdtId10); sdtProperties10.Append(sdtRepeatedSection2); SdtEndCharProperties sdtEndCharProperties10 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock10 = new SdtContentBlock(); SdtBlock sdtBlock11 = new SdtBlock(); SdtProperties sdtProperties11 = new SdtProperties(); RunProperties runProperties19 = new RunProperties(); RunFonts runFonts17 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties19.Append(runFonts17); SdtId sdtId11 = new SdtId(){ Val = -1356270719 }; SdtPlaceholder sdtPlaceholder9 = new SdtPlaceholder(); DocPartReference docPartReference9 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" }; sdtPlaceholder9.Append(docPartReference9); W15.SdtRepeatedSectionItem sdtRepeatedSectionItem2 = new W15.SdtRepeatedSectionItem(); sdtProperties11.Append(runProperties19); sdtProperties11.Append(sdtId11); sdtProperties11.Append(sdtPlaceholder9); sdtProperties11.Append(sdtRepeatedSectionItem2); SdtEndCharProperties sdtEndCharProperties11 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock11 = new SdtContentBlock(); Paragraph paragraph9 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; ProofError proofError1 = new ProofError(){ Type = ProofingErrorValues.SpellStart }; ProofError proofError2 = new ProofError(){ Type = ProofingErrorValues.GrammarStart }; Run run9 = new Run(); RunProperties runProperties20 = new RunProperties(); RunFonts runFonts18 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties20.Append(runFonts18); Text text9 = new Text(); text9.Text = "repeatingSectionItem"; run9.Append(runProperties20); run9.Append(text9); ProofError proofError3 = new ProofError(){ Type = ProofingErrorValues.SpellEnd }; ProofError proofError4 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd }; paragraph9.Append(proofError1); paragraph9.Append(proofError2); paragraph9.Append(run9); paragraph9.Append(proofError3); paragraph9.Append(proofError4); sdtContentBlock11.Append(paragraph9); sdtBlock11.Append(sdtProperties11); sdtBlock11.Append(sdtEndCharProperties11); sdtBlock11.Append(sdtContentBlock11); sdtContentBlock10.Append(sdtBlock11); sdtBlock10.Append(sdtProperties10); sdtBlock10.Append(sdtEndCharProperties10); sdtBlock10.Append(sdtContentBlock10); SdtBlock sdtBlock12 = new SdtBlock(); SdtProperties sdtProperties12 = new SdtProperties(); RunProperties runProperties21 = new RunProperties(); RunFonts runFonts19 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties21.Append(runFonts19); SdtAlias sdtAlias10 = new SdtAlias(){ Val = "Test1.4.3" }; Tag tag10 = new Tag(){ Val = "Test1.4.3" }; SdtId sdtId12 = new SdtId(){ Val = -294221661 }; W15.SdtRepeatedSection sdtRepeatedSection3 = new W15.SdtRepeatedSection(); W15.DoNotAllowInsertDeleteSection doNotAllowInsertDeleteSection1 = new W15.DoNotAllowInsertDeleteSection(){ Val = true }; sdtRepeatedSection3.Append(doNotAllowInsertDeleteSection1); sdtProperties12.Append(runProperties21); sdtProperties12.Append(sdtAlias10); sdtProperties12.Append(tag10); sdtProperties12.Append(sdtId12); sdtProperties12.Append(sdtRepeatedSection3); SdtEndCharProperties sdtEndCharProperties12 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock12 = new SdtContentBlock(); SdtBlock sdtBlock13 = new SdtBlock(); SdtProperties sdtProperties13 = new SdtProperties(); RunProperties runProperties22 = new RunProperties(); RunFonts runFonts20 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties22.Append(runFonts20); SdtId sdtId13 = new SdtId(){ Val = 2112001363 }; Lock lock1 = new Lock(){ Val = LockingValues.SdtLocked }; SdtPlaceholder sdtPlaceholder10 = new SdtPlaceholder(); DocPartReference docPartReference10 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" }; sdtPlaceholder10.Append(docPartReference10); W15.SdtRepeatedSectionItem sdtRepeatedSectionItem3 = new W15.SdtRepeatedSectionItem(); sdtProperties13.Append(runProperties22); sdtProperties13.Append(sdtId13); sdtProperties13.Append(lock1); sdtProperties13.Append(sdtPlaceholder10); sdtProperties13.Append(sdtRepeatedSectionItem3); SdtEndCharProperties sdtEndCharProperties13 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock13 = new SdtContentBlock(); Paragraph paragraph10 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; ProofError proofError5 = new ProofError(){ Type = ProofingErrorValues.SpellStart }; ProofError proofError6 = new ProofError(){ Type = ProofingErrorValues.GrammarStart }; Run run10 = new Run(); RunProperties runProperties23 = new RunProperties(); RunFonts runFonts21 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties23.Append(runFonts21); Text text10 = new Text(); text10.Text = "doNotAllowInsertDeleteSection"; run10.Append(runProperties23); run10.Append(text10); ProofError proofError7 = new ProofError(){ Type = ProofingErrorValues.SpellEnd }; ProofError proofError8 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd }; paragraph10.Append(proofError5); paragraph10.Append(proofError6); paragraph10.Append(run10); paragraph10.Append(proofError7); paragraph10.Append(proofError8); sdtContentBlock13.Append(paragraph10); sdtBlock13.Append(sdtProperties13); sdtBlock13.Append(sdtEndCharProperties13); sdtBlock13.Append(sdtContentBlock13); sdtContentBlock12.Append(sdtBlock13); sdtBlock12.Append(sdtProperties12); sdtBlock12.Append(sdtEndCharProperties12); sdtBlock12.Append(sdtContentBlock12); SdtBlock sdtBlock14 = new SdtBlock(); SdtProperties sdtProperties14 = new SdtProperties(); RunProperties runProperties24 = new RunProperties(); RunFonts runFonts22 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties24.Append(runFonts22); SdtAlias sdtAlias11 = new SdtAlias(){ Val = "Test1.4.4" }; Tag tag11 = new Tag(){ Val = "Test1.4.4" }; SdtId sdtId14 = new SdtId(){ Val = -248501389 }; W15.SdtRepeatedSection sdtRepeatedSection4 = new W15.SdtRepeatedSection(); W15.SectionTitle sectionTitle1 = new W15.SectionTitle(){ Val = "Section title string" }; sdtRepeatedSection4.Append(sectionTitle1); sdtProperties14.Append(runProperties24); sdtProperties14.Append(sdtAlias11); sdtProperties14.Append(tag11); sdtProperties14.Append(sdtId14); sdtProperties14.Append(sdtRepeatedSection4); SdtEndCharProperties sdtEndCharProperties14 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock14 = new SdtContentBlock(); SdtBlock sdtBlock15 = new SdtBlock(); SdtProperties sdtProperties15 = new SdtProperties(); RunProperties runProperties25 = new RunProperties(); RunFonts runFonts23 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties25.Append(runFonts23); SdtId sdtId15 = new SdtId(){ Val = 1971018620 }; SdtPlaceholder sdtPlaceholder11 = new SdtPlaceholder(); DocPartReference docPartReference11 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" }; sdtPlaceholder11.Append(docPartReference11); W15.SdtRepeatedSectionItem sdtRepeatedSectionItem4 = new W15.SdtRepeatedSectionItem(); sdtProperties15.Append(runProperties25); sdtProperties15.Append(sdtId15); sdtProperties15.Append(sdtPlaceholder11); sdtProperties15.Append(sdtRepeatedSectionItem4); SdtEndCharProperties sdtEndCharProperties15 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock15 = new SdtContentBlock(); Paragraph paragraph11 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" }; ProofError proofError9 = new ProofError(){ Type = ProofingErrorValues.SpellStart }; ProofError proofError10 = new ProofError(){ Type = ProofingErrorValues.GrammarStart }; Run run11 = new Run(); RunProperties runProperties26 = new RunProperties(); RunFonts runFonts24 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties26.Append(runFonts24); Text text11 = new Text(); text11.Text = "sectionTitle"; run11.Append(runProperties26); run11.Append(text11); ProofError proofError11 = new ProofError(){ Type = ProofingErrorValues.SpellEnd }; ProofError proofError12 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd }; paragraph11.Append(proofError9); paragraph11.Append(proofError10); paragraph11.Append(run11); paragraph11.Append(proofError11); paragraph11.Append(proofError12); sdtContentBlock15.Append(paragraph11); sdtBlock15.Append(sdtProperties15); sdtBlock15.Append(sdtEndCharProperties15); sdtBlock15.Append(sdtContentBlock15); sdtContentBlock14.Append(sdtBlock15); sdtBlock14.Append(sdtProperties14); sdtBlock14.Append(sdtEndCharProperties14); sdtBlock14.Append(sdtContentBlock14); Table table1 = new Table(); TableProperties tableProperties1 = new TableProperties(); TableWidth tableWidth1 = new TableWidth(){ Width = "0", Type = TableWidthUnitValues.Auto }; TableBorders tableBorders1 = new TableBorders(); TopBorder topBorder1 = new TopBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U }; LeftBorder leftBorder1 = new LeftBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U }; BottomBorder bottomBorder1 = new BottomBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U }; RightBorder rightBorder1 = new RightBorder(){ Val = BorderValues.Double, 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); TableLayout tableLayout1 = new TableLayout(){ Type = TableLayoutValues.Fixed }; TableLook tableLook1 = new TableLook(){ Val = "0000" }; tableProperties1.Append(tableWidth1); tableProperties1.Append(tableBorders1); tableProperties1.Append(tableLayout1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn(){ Width = "4788" }; GridColumn gridColumn2 = new GridColumn(){ Width = "4788" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); SdtRow sdtRow1 = new SdtRow(); SdtProperties sdtProperties16 = new SdtProperties(); SdtId sdtId16 = new SdtId(){ Val = 1391384564 }; SdtPlaceholder sdtPlaceholder12 = new SdtPlaceholder(); DocPartReference docPartReference12 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" }; sdtPlaceholder12.Append(docPartReference12); W15.DataBinding dataBinding1 = new W15.DataBinding(){ XPath = "/books[1]/book", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" }; W15.Appearance appearance3 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags }; W15.SdtRepeatedSection sdtRepeatedSection5 = new W15.SdtRepeatedSection(); sdtProperties16.Append(sdtId16); sdtProperties16.Append(sdtPlaceholder12); sdtProperties16.Append(dataBinding1); sdtProperties16.Append(appearance3); sdtProperties16.Append(sdtRepeatedSection5); SdtEndCharProperties sdtEndCharProperties16 = new SdtEndCharProperties(); SdtContentRow sdtContentRow1 = new SdtContentRow(); SdtRow sdtRow2 = new SdtRow(); SdtProperties sdtProperties17 = new SdtProperties(); SdtId sdtId17 = new SdtId(){ Val = 1787311118 }; W15.Appearance appearance4 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags }; W15.SdtRepeatedSectionItem sdtRepeatedSectionItem5 = new W15.SdtRepeatedSectionItem(); sdtProperties17.Append(sdtId17); sdtProperties17.Append(appearance4); sdtProperties17.Append(sdtRepeatedSectionItem5); SdtEndCharProperties sdtEndCharProperties17 = new SdtEndCharProperties(); SdtContentRow sdtContentRow2 = new SdtContentRow(); TableRow tableRow1 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" }; SdtCell sdtCell1 = new SdtCell(); SdtProperties sdtProperties18 = new SdtProperties(); SdtAlias sdtAlias12 = new SdtAlias(){ Val = "Test1.5.1_1" }; Tag tag12 = new Tag(){ Val = "Test1.5.1_1" }; SdtId sdtId18 = new SdtId(){ Val = -1276551752 }; SdtPlaceholder sdtPlaceholder13 = new SdtPlaceholder(); DocPartReference docPartReference13 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" }; sdtPlaceholder13.Append(docPartReference13); DataBinding dataBinding2 = new DataBinding(){ XPath = "/books[1]/book[1]/title[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" }; SdtContentText sdtContentText8 = new SdtContentText(); sdtProperties18.Append(sdtAlias12); sdtProperties18.Append(tag12); sdtProperties18.Append(sdtId18); sdtProperties18.Append(sdtPlaceholder13); sdtProperties18.Append(dataBinding2); sdtProperties18.Append(sdtContentText8); SdtEndCharProperties sdtEndCharProperties18 = new SdtEndCharProperties(); SdtContentCell sdtContentCell1 = new SdtContentCell(); TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading1 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties1.Append(tableCellWidth1); tableCellProperties1.Append(shading1); Paragraph paragraph12 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" }; Run run12 = new Run(); RunProperties runProperties27 = new RunProperties(); RunFonts runFonts25 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties27.Append(runFonts25); Text text12 = new Text(); text12.Text = "Repeating Section,Row1"; run12.Append(runProperties27); run12.Append(text12); Run run13 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties28 = new RunProperties(); RunFonts runFonts26 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; runProperties28.Append(runFonts26); Text text13 = new Text(); text13.Text = ",Cell1"; run13.Append(runProperties28); run13.Append(text13); paragraph12.Append(run12); paragraph12.Append(run13); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph12); sdtContentCell1.Append(tableCell1); sdtCell1.Append(sdtProperties18); sdtCell1.Append(sdtEndCharProperties18); sdtCell1.Append(sdtContentCell1); SdtCell sdtCell2 = new SdtCell(); SdtProperties sdtProperties19 = new SdtProperties(); RunProperties runProperties29 = new RunProperties(); Kern kern1 = new Kern(){ Val = (UInt32Value)0U }; runProperties29.Append(kern1); SdtAlias sdtAlias13 = new SdtAlias(){ Val = "Test1.5.1_2" }; Tag tag13 = new Tag(){ Val = "Test1.5.1_2" }; SdtId sdtId19 = new SdtId(){ Val = -1317331761 }; SdtPlaceholder sdtPlaceholder14 = new SdtPlaceholder(); DocPartReference docPartReference14 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" }; sdtPlaceholder14.Append(docPartReference14); DataBinding dataBinding3 = new DataBinding(){ XPath = "/books[1]/book[1]/author[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" }; SdtContentText sdtContentText9 = new SdtContentText(); sdtProperties19.Append(runProperties29); sdtProperties19.Append(sdtAlias13); sdtProperties19.Append(tag13); sdtProperties19.Append(sdtId19); sdtProperties19.Append(sdtPlaceholder14); sdtProperties19.Append(dataBinding3); sdtProperties19.Append(sdtContentText9); SdtEndCharProperties sdtEndCharProperties19 = new SdtEndCharProperties(); SdtContentCell sdtContentCell2 = new SdtContentCell(); TableCell tableCell2 = new TableCell(); TableCellProperties tableCellProperties2 = new TableCellProperties(); TableCellWidth tableCellWidth2 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading2 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties2.Append(tableCellWidth2); tableCellProperties2.Append(shading2); Paragraph paragraph13 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" }; Run run14 = new Run(); RunProperties runProperties30 = new RunProperties(); Kern kern2 = new Kern(){ Val = (UInt32Value)0U }; runProperties30.Append(kern2); Text text14 = new Text(); text14.Text = "Repeating Section"; run14.Append(runProperties30); run14.Append(text14); Run run15 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties31 = new RunProperties(); RunFonts runFonts27 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern3 = new Kern(){ Val = (UInt32Value)0U }; runProperties31.Append(runFonts27); runProperties31.Append(kern3); Text text15 = new Text(); text15.Text = ","; run15.Append(runProperties31); run15.Append(text15); Run run16 = new Run(); RunProperties runProperties32 = new RunProperties(); Kern kern4 = new Kern(){ Val = (UInt32Value)0U }; runProperties32.Append(kern4); Text text16 = new Text(); text16.Text = "Row1"; run16.Append(runProperties32); run16.Append(text16); Run run17 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties33 = new RunProperties(); RunFonts runFonts28 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern5 = new Kern(){ Val = (UInt32Value)0U }; runProperties33.Append(runFonts28); runProperties33.Append(kern5); Text text17 = new Text(); text17.Text = ",Cell2"; run17.Append(runProperties33); run17.Append(text17); paragraph13.Append(run14); paragraph13.Append(run15); paragraph13.Append(run16); paragraph13.Append(run17); tableCell2.Append(tableCellProperties2); tableCell2.Append(paragraph13); sdtContentCell2.Append(tableCell2); sdtCell2.Append(sdtProperties19); sdtCell2.Append(sdtEndCharProperties19); sdtCell2.Append(sdtContentCell2); tableRow1.Append(sdtCell1); tableRow1.Append(sdtCell2); sdtContentRow2.Append(tableRow1); sdtRow2.Append(sdtProperties17); sdtRow2.Append(sdtEndCharProperties17); sdtRow2.Append(sdtContentRow2); SdtRow sdtRow3 = new SdtRow(); SdtProperties sdtProperties20 = new SdtProperties(); SdtId sdtId20 = new SdtId(){ Val = 689805002 }; W15.Appearance appearance5 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags }; W15.SdtRepeatedSectionItem sdtRepeatedSectionItem6 = new W15.SdtRepeatedSectionItem(); sdtProperties20.Append(sdtId20); sdtProperties20.Append(appearance5); sdtProperties20.Append(sdtRepeatedSectionItem6); SdtEndCharProperties sdtEndCharProperties20 = new SdtEndCharProperties(); SdtContentRow sdtContentRow3 = new SdtContentRow(); TableRow tableRow2 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" }; SdtCell sdtCell3 = new SdtCell(); SdtProperties sdtProperties21 = new SdtProperties(); SdtAlias sdtAlias14 = new SdtAlias(){ Val = "Test1.5.1_3" }; Tag tag14 = new Tag(){ Val = "Test1.5.1_3" }; SdtId sdtId21 = new SdtId(){ Val = 880594776 }; SdtPlaceholder sdtPlaceholder15 = new SdtPlaceholder(); DocPartReference docPartReference15 = new DocPartReference(){ Val = "4B632797D8B1461898B8F461443A20E0" }; sdtPlaceholder15.Append(docPartReference15); DataBinding dataBinding4 = new DataBinding(){ XPath = "/books[1]/book[4]/title[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" }; SdtContentText sdtContentText10 = new SdtContentText(); sdtProperties21.Append(sdtAlias14); sdtProperties21.Append(tag14); sdtProperties21.Append(sdtId21); sdtProperties21.Append(sdtPlaceholder15); sdtProperties21.Append(dataBinding4); sdtProperties21.Append(sdtContentText10); SdtEndCharProperties sdtEndCharProperties21 = new SdtEndCharProperties(); RunProperties runProperties34 = new RunProperties(); Kern kern6 = new Kern(){ Val = (UInt32Value)0U }; runProperties34.Append(kern6); sdtEndCharProperties21.Append(runProperties34); SdtContentCell sdtContentCell3 = new SdtContentCell(); TableCell tableCell3 = new TableCell(); TableCellProperties tableCellProperties3 = new TableCellProperties(); TableCellWidth tableCellWidth3 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading3 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties3.Append(tableCellWidth3); tableCellProperties3.Append(shading3); Paragraph paragraph14 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" }; Run run18 = new Run(); RunProperties runProperties35 = new RunProperties(); Kern kern7 = new Kern(){ Val = (UInt32Value)0U }; runProperties35.Append(kern7); Text text18 = new Text(); text18.Text = "Repeating Section"; run18.Append(runProperties35); run18.Append(text18); Run run19 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties36 = new RunProperties(); RunFonts runFonts29 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern8 = new Kern(){ Val = (UInt32Value)0U }; runProperties36.Append(runFonts29); runProperties36.Append(kern8); Text text19 = new Text(); text19.Text = ","; run19.Append(runProperties36); run19.Append(text19); Run run20 = new Run(); RunProperties runProperties37 = new RunProperties(); Kern kern9 = new Kern(){ Val = (UInt32Value)0U }; runProperties37.Append(kern9); Text text20 = new Text(); text20.Text = "Row"; run20.Append(runProperties37); run20.Append(text20); Run run21 = new Run(); RunProperties runProperties38 = new RunProperties(); RunFonts runFonts30 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern10 = new Kern(){ Val = (UInt32Value)0U }; runProperties38.Append(runFonts30); runProperties38.Append(kern10); Text text21 = new Text(); text21.Text = "2"; run21.Append(runProperties38); run21.Append(text21); Run run22 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties39 = new RunProperties(); RunFonts runFonts31 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern11 = new Kern(){ Val = (UInt32Value)0U }; runProperties39.Append(runFonts31); runProperties39.Append(kern11); Text text22 = new Text(); text22.Text = ",Cell1"; run22.Append(runProperties39); run22.Append(text22); paragraph14.Append(run18); paragraph14.Append(run19); paragraph14.Append(run20); paragraph14.Append(run21); paragraph14.Append(run22); tableCell3.Append(tableCellProperties3); tableCell3.Append(paragraph14); sdtContentCell3.Append(tableCell3); sdtCell3.Append(sdtProperties21); sdtCell3.Append(sdtEndCharProperties21); sdtCell3.Append(sdtContentCell3); SdtCell sdtCell4 = new SdtCell(); SdtProperties sdtProperties22 = new SdtProperties(); RunProperties runProperties40 = new RunProperties(); Kern kern12 = new Kern(){ Val = (UInt32Value)0U }; runProperties40.Append(kern12); SdtAlias sdtAlias15 = new SdtAlias(){ Val = "Test1.5.1_4" }; Tag tag15 = new Tag(){ Val = "Test1.5.1_4" }; SdtId sdtId22 = new SdtId(){ Val = -1022928317 }; SdtPlaceholder sdtPlaceholder16 = new SdtPlaceholder(); DocPartReference docPartReference16 = new DocPartReference(){ Val = "4B632797D8B1461898B8F461443A20E0" }; sdtPlaceholder16.Append(docPartReference16); DataBinding dataBinding5 = new DataBinding(){ XPath = "/books[1]/book[4]/author[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" }; SdtContentText sdtContentText11 = new SdtContentText(); sdtProperties22.Append(runProperties40); sdtProperties22.Append(sdtAlias15); sdtProperties22.Append(tag15); sdtProperties22.Append(sdtId22); sdtProperties22.Append(sdtPlaceholder16); sdtProperties22.Append(dataBinding5); sdtProperties22.Append(sdtContentText11); SdtEndCharProperties sdtEndCharProperties22 = new SdtEndCharProperties(); SdtContentCell sdtContentCell4 = new SdtContentCell(); TableCell tableCell4 = new TableCell(); TableCellProperties tableCellProperties4 = new TableCellProperties(); TableCellWidth tableCellWidth4 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading4 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties4.Append(tableCellWidth4); tableCellProperties4.Append(shading4); Paragraph paragraph15 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "009651D6" }; Run run23 = new Run(); RunProperties runProperties41 = new RunProperties(); Kern kern13 = new Kern(){ Val = (UInt32Value)0U }; runProperties41.Append(kern13); Text text23 = new Text(); text23.Text = "Repeating Section"; run23.Append(runProperties41); run23.Append(text23); Run run24 = new Run(){ RsidRunAddition = "00E86739" }; RunProperties runProperties42 = new RunProperties(); RunFonts runFonts32 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia }; Kern kern14 = new Kern(){ Val = (UInt32Value)0U }; runProperties42.Append(runFonts32); runProperties42.Append(kern14); Text text24 = new Text(); text24.Text = ",Row2,Cell2"; run24.Append(runProperties42); run24.Append(text24); paragraph15.Append(run23); paragraph15.Append(run24); tableCell4.Append(tableCellProperties4); tableCell4.Append(paragraph15); sdtContentCell4.Append(tableCell4); sdtCell4.Append(sdtProperties22); sdtCell4.Append(sdtEndCharProperties22); sdtCell4.Append(sdtContentCell4); tableRow2.Append(sdtCell3); tableRow2.Append(sdtCell4); sdtContentRow3.Append(tableRow2); sdtRow3.Append(sdtProperties20); sdtRow3.Append(sdtEndCharProperties20); sdtRow3.Append(sdtContentRow3); sdtContentRow1.Append(sdtRow2); sdtContentRow1.Append(sdtRow3); sdtRow1.Append(sdtProperties16); sdtRow1.Append(sdtEndCharProperties16); sdtRow1.Append(sdtContentRow1); TableRow tableRow3 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" }; TableCell tableCell5 = new TableCell(); TableCellProperties tableCellProperties5 = new TableCellProperties(); TableCellWidth tableCellWidth5 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading5 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties5.Append(tableCellWidth5); tableCellProperties5.Append(shading5); Paragraph paragraph16 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00242789", RsidRunAdditionDefault = "00E930A2" }; tableCell5.Append(tableCellProperties5); tableCell5.Append(paragraph16); TableCell tableCell6 = new TableCell(); TableCellProperties tableCellProperties6 = new TableCellProperties(); TableCellWidth tableCellWidth6 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa }; Shading shading6 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" }; tableCellProperties6.Append(tableCellWidth6); tableCellProperties6.Append(shading6); Paragraph paragraph17 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00242789", RsidRunAdditionDefault = "00E930A2" }; tableCell6.Append(tableCellProperties6); tableCell6.Append(paragraph17); tableRow3.Append(tableCell5); tableRow3.Append(tableCell6); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(sdtRow1); table1.Append(tableRow3); Paragraph paragraph18 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidRunAdditionDefault = "00E930A2" }; SectionProperties sectionProperties1 = new SectionProperties(){ RsidR = "00E930A2" }; PageSize pageSize1 = new PageSize(){ Width = (UInt32Value)11906U, Height = (UInt32Value)16838U }; PageMargin pageMargin1 = new PageMargin(){ Top = 1985, Right = (UInt32Value)1701U, Bottom = 1701, Left = (UInt32Value)1701U, Header = (UInt32Value)851U, Footer = (UInt32Value)992U, Gutter = (UInt32Value)0U }; Columns columns1 = new Columns(){ Space = "425" }; DocGrid docGrid1 = new DocGrid(){ Type = DocGridValues.Lines, LinePitch = 360 }; sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); sectionProperties1.Append(docGrid1); body1.Append(sdtBlock1); body1.Append(sdtBlock2); body1.Append(sdtBlock3); body1.Append(sdtBlock4); body1.Append(sdtBlock5); body1.Append(sdtBlock6); body1.Append(sdtBlock7); body1.Append(sdtBlock8); body1.Append(sdtBlock10); body1.Append(sdtBlock12); body1.Append(sdtBlock14); body1.Append(table1); body1.Append(paragraph18); body1.Append(sectionProperties1); document1.Append(body1); mainDocumentPart1.Document = document1; }
public void GenerateTable(string document, string tag, string startDate, string endDate) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) { MainDocumentPart mainPart = wordDoc.MainDocumentPart; string fromString = startDate; string toString = endDate; DateTime fromDate = DateTime.ParseExact(fromString, "dd/MM/yyyy", null); DateTime toDate = DateTime.ParseExact(toString, "dd/MM/yyyy", null); // date tag SdtRun controlTag = mainPart.Document.Body.Descendants <SdtRun>().Where (r => r.SdtProperties.GetFirstChild <Tag>().Val == "dateTag").SingleOrDefault(); SdtContentRun contentRun = controlTag.GetFirstChild <SdtContentRun>(); contentRun.GetFirstChild <Run>().GetFirstChild <Text>().Text = "Date: " + fromDate.ToLongDateString() + " to " + toDate.ToLongDateString(); // This should return only one content control element: the one with // the specified tag value. // If not, "Single()" throws an exception. SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where (r => r.SdtProperties.GetFirstChild <Tag>().Val == tag).Single(); // This should return only one table. Table theTable = ccWithTable.Descendants <Table>().Single(); CurrentStatus cstatus = CurrentStatus.Current; EndorsementStatus estatus = EndorsementStatus.Active; /***********************Area of health with active committees***********************/ // display area of health which has active committees // in which the active committees have active reps // in which the active reps have prep and meeting time var areaOfHealth = (from aoh in db.CommitteeAreaOfHealth from comm in db.Committees from area in db.CommitteeModel_CommitteeAreaOfHealth from conh in db.ConsumerRepCommitteeHistory from conr in db.ConsumerReps where aoh.CommitteeAreaOfHealthModelID == area.CommitteeAreaOfHealthModelID where area.CommitteeModelID == comm.CommitteeModelID where conh.CommitteeModelID == comm.CommitteeModelID where conr.ConsumerRepModelID == conh.ConsumerRepModelID where comm.CurrentStatus == cstatus where conr.EndorsementStatus == estatus where conh.ReportedDate >= fromDate && conh.ReportedDate <= toDate where conh.PrepTime > 0 || conh.Meetingtime > 0 select aoh).Distinct(); int sumTotalCommittees = 0; int totalSumTotalReps = 0; int totalSumTotalPrepTime = 0; int totalSumTotalMeetingTime = 0; int totalSumTotalTime = 0; foreach (var aoh in areaOfHealth) { // copy the table Table tableCopy = (Table)theTable.CloneNode(true); // add the table ccWithTable.AppendChild(tableCopy); // get the first row first element in the table TableRow firstRow = tableCopy.Elements <TableRow>().First(); // get the last row in the table TableRow lastRow = tableCopy.Elements <TableRow>().Last(); // add value to the first row in the table firstRow.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "24" }, new Bold()), new Text(aoh.AreaOfHealthName.ToString())))); firstRow.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Number of Reps")))); firstRow.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Prep Hours")))); firstRow.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Meeting Hours")))); firstRow.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Total Hours")))); // display active committees within the area of health // in which active committees have active reps with prep time or meeting time var committees = (from com in db.Committees from aohh in db.CommitteeModel_CommitteeAreaOfHealth from crch in db.ConsumerRepCommitteeHistory from csr in db.ConsumerReps where com.CommitteeModelID == aohh.CommitteeModelID where aohh.CommitteeAreaOfHealthModelID == aoh.CommitteeAreaOfHealthModelID where crch.CommitteeModelID == com.CommitteeModelID where crch.ConsumerRepModelID == csr.ConsumerRepModelID where com.CurrentStatus == cstatus where csr.EndorsementStatus == estatus where crch.PrepTime > 0 || crch.Meetingtime > 0 where crch.ReportedDate >= fromDate && crch.ReportedDate <= toDate select com).Distinct(); int totalCommittees = 0; int sumTotalReps = 0; int sumTotalPrepTime = 0; int sumTotalMeetingTime = 0; int sumTotalTime = 0; foreach (var com in committees) { // all consumer reps within the committee var consumerReps = (from cr in db.ConsumerReps from ch in db.ConsumerRepCommitteeHistory where ch.CommitteeModelID == com.CommitteeModelID where ch.ConsumerRepModelID == cr.ConsumerRepModelID where cr.EndorsementStatus == estatus where ch.ReportedDate >= fromDate && ch.ReportedDate <= toDate where ch.PrepTime > 0 || ch.Meetingtime > 0 select cr).Distinct(); int totalReps = 0; int totalPrepTime = 0; int totalMeetingTime = 0; int totalTime = 0; foreach (var cr in consumerReps) { // newest reported date of the consumer rep var maxReportedDate = (from ch in db.ConsumerRepCommitteeHistory where cr.ConsumerRepModelID == ch.ConsumerRepModelID where ch.CommitteeModelID == com.CommitteeModelID where ch.ReportedDate >= fromDate && ch.ReportedDate <= toDate where cr.EndorsementStatus == estatus select ch.ReportedDate).Max(); // newest consumer rep history of the consumer rep var consumerRepHisotry = (from ch in db.ConsumerRepCommitteeHistory where cr.ConsumerRepModelID == ch.ConsumerRepModelID where ch.CommitteeModelID == com.CommitteeModelID where ch.ReportedDate >= fromDate && ch.ReportedDate <= toDate where cr.EndorsementStatus == estatus where ch.ReportedDate == maxReportedDate select ch).Distinct(); // total totalReps++; foreach (var ch in consumerRepHisotry) { totalPrepTime += ch.PrepTime; totalMeetingTime += ch.Meetingtime; totalTime = totalMeetingTime + totalPrepTime; } } // row for each committee TableRow rowCopy = (TableRow)lastRow.CloneNode(true); rowCopy.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(com.CommitteeName.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(totalReps.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(totalPrepTime.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(totalMeetingTime.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(totalTime.ToString())))); tableCopy.AppendChild(rowCopy); // sum of total totalCommittees++; sumTotalReps += totalReps; sumTotalPrepTime += totalPrepTime; sumTotalMeetingTime += totalMeetingTime; sumTotalTime += totalTime; } // remove the empty placeholder row from the table. tableCopy.RemoveChild(lastRow); // add a final row to the table tableCopy.AppendChild(lastRow); lastRow.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Committees active in the period: " + totalCommittees.ToString())))); lastRow.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text(sumTotalReps.ToString())))); lastRow.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text(sumTotalPrepTime.ToString())))); lastRow.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text(sumTotalMeetingTime.ToString())))); lastRow.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text(sumTotalTime.ToString())))); // total sum of total sumTotalCommittees += totalCommittees; totalSumTotalReps += sumTotalReps; totalSumTotalPrepTime += sumTotalPrepTime; totalSumTotalMeetingTime += sumTotalMeetingTime; totalSumTotalTime += sumTotalTime; } //remove the template table theTable.Remove(); //***********************Other active committees***********************/ //get last row of active committees TableRow lastRowActive = theTable.Elements <TableRow>().Last(); //get first row of active committees TableRow firstRowActive = theTable.Elements <TableRow>().First(); //first row values firstRowActive.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Active Committees that Have Not Met in This Period".ToString())))); firstRowActive.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Number of Reps".ToString())))); var activeCommittees = (from aCom in db.Committees from aComh in db.ConsumerRepCommitteeHistory where aComh.CommitteeModelID == aCom.CommitteeModelID where aComh.PrepTime == 0 && aComh.Meetingtime == 0 where aComh.ReportedDate >= fromDate && aComh.ReportedDate <= toDate where aCom.CurrentStatus == cstatus select aCom).Distinct(); int totalcommittees = 0; int totalsumrep = 0; foreach (var aCom in activeCommittees) { var activeReps = (from aRep in db.ConsumerReps from aComh in db.ConsumerRepCommitteeHistory where aRep.ConsumerRepModelID == aComh.ConsumerRepModelID where aComh.CommitteeModelID == aCom.CommitteeModelID where aComh.ReportedDate >= fromDate && aComh.ReportedDate <= toDate where aRep.EndorsementStatus == estatus select aRep).Distinct(); int totalprep = 0; int totalmeet = 0; int totalrep = 0; foreach (var aRep in activeReps) { var maxDate = (from aComh in db.ConsumerRepCommitteeHistory where aComh.CommitteeModelID == aCom.CommitteeModelID where aComh.ConsumerRepModelID == aRep.ConsumerRepModelID where aComh.ReportedDate >= fromDate && aComh.ReportedDate <= toDate select aComh.ReportedDate).Max(); var activeComh = from aComh in db.ConsumerRepCommitteeHistory where aComh.CommitteeModelID == aCom.CommitteeModelID where aComh.ConsumerRepModelID == aRep.ConsumerRepModelID where aComh.ReportedDate >= fromDate && aComh.ReportedDate <= toDate where aComh.ReportedDate == maxDate select aComh; foreach (var aComh in activeComh) { totalprep += aComh.PrepTime; totalmeet += aComh.Meetingtime; } totalrep++; } if (totalprep == 0 && totalmeet == 0) { TableRow rowCopyActive = (TableRow)lastRowActive.CloneNode(true); rowCopyActive.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(aCom.CommitteeName.ToString())))); rowCopyActive.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }), new Text(totalrep.ToString())))); // add row theTable.AppendChild(rowCopyActive); // total active committees and reps that is doesn't have a prep time totalcommittees++; totalsumrep += totalrep; } } // remove empty row theTable.RemoveChild(lastRowActive); /***********************Total number***********************/ sumTotalCommittees += totalcommittees; totalSumTotalReps += totalsumrep; // three more rows for (int i = 0; i < 3; i++) { TableRow rowFinalCopy = (TableRow)lastRowActive.CloneNode(true); theTable.AppendChild(rowFinalCopy); } // Get the last row in the last two rows TableRow theLastRow = theTable.Elements <TableRow>().Last(); // Get the second last row TableRow theSecondLastRow = theTable.Elements <TableRow>().Reverse().Skip(1).First(); // Get the third last row TableRow theThirdLastRow = theTable.Elements <TableRow>().Reverse().Skip(2).First(); // edit the final three rows theThirdLastRow.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text("Committees Active in the Period in this Grouping: " + totalcommittees.ToString())))); theThirdLastRow.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "20" }, new Bold()), new Text(totalsumrep.ToString())))); theSecondLastRow.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Total Reps".ToString())))); theSecondLastRow.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Total Prep Hours".ToString())))); theSecondLastRow.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Total Meeting Hours")))); theSecondLastRow.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Total Hours")))); theLastRow.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text("Total Committees Active in this Period: " + sumTotalCommittees.ToString())))); theLastRow.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text(totalSumTotalReps.ToString())))); theLastRow.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text(totalSumTotalPrepTime.ToString())))); theLastRow.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text(totalSumTotalMeetingTime.ToString())))); theLastRow.Descendants <TableCell>().ElementAt(4).Append(new Paragraph (new Run( new RunFonts { Ascii = "Arial" }, new RunProperties(new FontSize { Val = "32" }, new Bold(), new Italic()), new Text(totalSumTotalTime.ToString())))); // add the template table ccWithTable.AppendChild(theTable); // Save the changes to the table back into the document. mainPart.Document.Save(); } }
public static void GentText(Dictionary <string, string> dict, List <List <string> > List1, string path2, string path3) { List <string> Tables = new List <string>(); int flazhok = 0; int fcount = 0; int k = 0; byte[] byteArray = File.ReadAllBytes(path3); 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 = "16"; string[] tblTag = new string[0];//Табличные теги bool flag = true; 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>(); SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().FirstOrDefault(); int index = 0; foreach (var tt in ccWithTable1) { if (flag != false) { 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; flag = false; } } } int count = 0; int row = 0; int r2 = 3; int n = 0; int u2 = 1; if (flazhok == 1) { Table theTable = ccWithTable.Descendants <Table>().FirstOrDefault(); for (row = 4; row < theTable.Elements <TableRow>().Count(); row++) { count = 0; bool p = true; int countp = 0; TableRow row8 = theTable.Elements <TableRow>().ElementAt(row); for (int yacheika2 = 0; yacheika2 < theTable.Elements <TableRow>().ElementAt(row).Elements <TableCell>().Count(); yacheika2++) { if (row == 4) { TableCell cell1 = row8.Elements <TableCell>().ElementAt(yacheika2); int b3 = 0; int[] gridSpan1 = null; gridSpan1 = new int[] { 1, 7 }; TableCellProperties tcp3 = new TableCellProperties(new GridSpan() { Val = gridSpan1[b3] }); b3++; TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2])))); TableCell cell2 = row8.Elements <TableCell>().ElementAt(yacheika2); cell2 = cell23; var sdts12 = mainPart.Document.Descendants <SdtElement>(); //TableRow rowCopy = (TableRow)theRow.CloneNode(true); row8.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph (new Run(new Text(List1[m][u2])))); //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2]; Paragraph p3 = row8.Descendants <TableCell>().ElementAt(yacheika2).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 (t2.Count() > 1) { t2.LastChild.Remove(); } if (row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1) { foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (countp == 0) { t3.Remove(); break; } } } foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (t3.Elements <ParagraphProperties>().Count() > 1) { for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++) { t3.Elements <ParagraphProperties>().ElementAt(i7).Remove(); } } u2++; TableCellProperties tcp5 = new TableCellProperties( new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); ParagraphProperties pp = new ParagraphProperties(new Justification() { Val = JustificationValues.Center }); t3.PrependChild <ParagraphProperties>(pp); t3.PrependChild <TableCellProperties>(tcp5); } } if (row != 4) { countp = 0; if (theTable.Elements <TableRow>().Count() <= row) { break; } TableRow row9 = theTable.Elements <TableRow>().ElementAt(row); row8 = theTable.Elements <TableRow>().ElementAt(row - 1); // row9 = theTable.Elements<TableRow>().ElementAt(row); if (yacheika2 == 15) { break; } if (count == 0) { if (u2 <= List1[m].Count() - 1) { if (List1[m][u2 - 15] != List1[m][u2]) { p = false; } } else { break; } } if (p == false) { TableCell cell1 = row8.Elements <TableCell>().ElementAt(yacheika2); int b3 = 0; int[] gridSpan1 = null; gridSpan1 = new int[] { 1, 7 }; TableCellProperties tcp3 = new TableCellProperties(new GridSpan() { Val = gridSpan1[b3] }); b3++; // TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2])))); // TableCell cell2 = row9.Elements<TableCell>().ElementAt(yacheika2); // cell2 = cell23; // var sdts12 = mainPart.Document.Descendants<SdtElement>(); //TableRow rowCopy = (TableRow)theRow.CloneNode(true); row9.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph (new Run(new Text(List1[m][u2])))); //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2]; Paragraph p3 = row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First(); Run t2 = p3.Elements <Run>().First(); if (row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1) { foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (countp == 0) { t3.Remove(); break; } } } RunProperties rPr2 = new RunProperties( new RunFonts() { Ascii = font, HighAnsi = font }, new FontSize() { Val = fs.Val }); t2.PrependChild <RunProperties>(rPr2); if (t2.Count() > 1) { t2.LastChild.Remove(); } foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (t3.Elements <ParagraphProperties>().Count() > 1) { for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++) { t3.Elements <ParagraphProperties>().ElementAt(i7).Remove(); } } TableCellProperties tcp5 = new TableCellProperties( new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); ParagraphProperties pp = new ParagraphProperties(new Justification() { Val = JustificationValues.Center }); t3.PrependChild <ParagraphProperties>(pp); t3.PrependChild <TableCellProperties>(tcp5); } } else { countp = 0; if (List1[m][u2 - 15] != List1[m][u2]) { // row9 = theTable.Elements<TableRow>().ElementAt(row - 1); TableCell cell1 = row8.Elements <TableCell>().ElementAt(yacheika2); int b3 = 0; int[] gridSpan1 = null; gridSpan1 = new int[] { 1, 7 }; TableCellProperties tcp3 = new TableCellProperties(new GridSpan() { Val = gridSpan1[b3] }); b3++; TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2])))); TableCell cell2 = row8.Elements <TableCell>().ElementAt(yacheika2); cell2 = cell23; var sdts12 = mainPart.Document.Descendants <SdtElement>(); //TableRow rowCopy = (TableRow)theRow.CloneNode(true); row9.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph (new Run(new Text(List1[m][u2])))); //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2]; Paragraph p3 = row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First(); Run t2 = p3.Elements <Run>().First(); if (row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1) { foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (countp == 0) { t3.Remove(); break; } } } RunProperties rPr2 = new RunProperties( new RunFonts() { Ascii = font, HighAnsi = font }, new FontSize() { Val = fs.Val }); t2.PrependChild <RunProperties>(rPr2); if (t2.Count() > 1) { t2.LastChild.Remove(); } foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { if (t3.Elements <ParagraphProperties>().Count() > 1) { for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++) { t3.Elements <ParagraphProperties>().ElementAt(i7).Remove(); } } TableCellProperties tcp5 = new TableCellProperties( new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); ParagraphProperties pp = new ParagraphProperties(new Justification() { Val = JustificationValues.Center }); t3.PrependChild <ParagraphProperties>(pp); t3.PrependChild <TableCellProperties>(tcp5); } } } //string row11 = theTable.Elements<TableRow>().ElementAt(row1).Elements<TableCell>().ElementAt(yacheika1).InnerText; count++; u2++; } } } // int y = theTable.Elements <TableRow>().Count(); for (row = 4; row < theTable.Elements <TableRow>().Count(); row++) { TableRow row8 = theTable.Elements <TableRow>().ElementAt(row); for (int yacheika2 = 0; yacheika2 < theTable.Elements <TableRow>().ElementAt(row).Elements <TableCell>().Count(); yacheika2++) { foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>()) { Paragraph p3 = row8.Descendants <TableCell>().ElementAt(yacheika2).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); } } } } var sdts123 = mainPart.Document.Descendants <SdtElement>(); foreach (var sdt3 in sdts123) { Tag ff = sdt3.SdtProperties.GetFirstChild <Tag>(); string old_text = sdt3.SdtProperties.InnerText; if (ff != null) { if (dict.ContainsKey((ff.Val))) { string value = dict[ff.Val];; sdt3.Descendants <DocumentFormat.OpenXml.Wordprocessing.Text>().FirstOrDefault().Text = value; } } } } } try { File.Delete(path2); using (FileStream fileStream = new FileStream(path2, System.IO.FileMode.CreateNew)) { mem.WriteTo(fileStream); } } catch (Exception ex) { throw ex; } } }
private OpenXmlElement GetXmlElement() { var paragraph = new Paragraph(); var paragraphProperties = new ParagraphProperties( new ParagraphStyleId { Val = "Footer" }, new Justification { Val = JustificationValues.Right } ); paragraph.Append(paragraphProperties); paragraph.Append(new Run( new Text { Text = "стр. ", Space = SpaceProcessingModeValues.Preserve } )); paragraph.Append(new Run( new FieldChar { FieldCharType = FieldCharValues.Begin } )); paragraph.Append(new Run( new FieldCode { Space = SpaceProcessingModeValues.Preserve, Text = "PAGE" }, new RunProperties(new RunStyle { Val = "PageNumber" } ))); paragraph.Append(new Run (new FieldChar { FieldCharType = FieldCharValues.End } )); paragraph.Append(new Run( new Text { Text = " из ", Space = SpaceProcessingModeValues.Preserve } )); paragraph.Append(new Run( new FieldChar { FieldCharType = FieldCharValues.Begin } )); paragraph.Append(new Run( new FieldCode { Space = SpaceProcessingModeValues.Preserve, Text = "NUMPAGES" }, new RunProperties(new RunStyle { Val = "PageNumber" } ))); paragraph.Append(new Run( new FieldChar { FieldCharType = FieldCharValues.End } )); var pageNumberBlock = new SdtBlock(); var contentBlock = new SdtContentBlock(); contentBlock.Append(paragraph); pageNumberBlock.Append(contentBlock); return(pageNumberBlock); }
// ATTENTION : dont work with google doc use CreateParagraph_PageNumber() public static SdtBlock CreatePageNumberBlock(string styleId, string text) { // SdtBlock, <w:sdt> SdtBlock sdtBlock = new SdtBlock(); // Structured Document Tag Properties, <w:sdtPr> SdtProperties sdtProperties = new SdtProperties(); // SdtContentDocPartObject, <w:docPartObj> SdtContentDocPartObject docPartObject = new SdtContentDocPartObject(); // Document Part Gallery Filter, <w:docPartGallery> docPartObject.AppendChild(new DocPartGallery { Val = "Page Numbers (Bottom of Page)" }); docPartObject.AppendChild(new DocPartUnique()); sdtProperties.AppendChild(docPartObject); sdtBlock.SdtProperties = sdtProperties; // Block-Level Structured Document Tag Content, <w:sdtContent> SdtContentBlock sdtContentBlock = new SdtContentBlock(); Paragraph paragraph = new Paragraph(); paragraph.ParagraphProperties = new ParagraphProperties { ParagraphStyleId = new ParagraphStyleId() { Val = styleId } }; Run run = paragraph.AppendChild(new Run()); run.AppendChild(new TabStop()); run.AppendChild(new DW.Text { Text = text }); run.AppendChild(new TabStop()); run.AppendChild(new DW.Text { Text = "page ", Space = SpaceProcessingModeValues.Preserve }); // Complex Field Character, <w:fldChar> run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.Begin }); // Field Code, <w:instrText> // "PAGE \\* MERGEFORMAT" "PAGE" run.AppendChild(new FieldCode("PAGE \\* MERGEFORMAT")); run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.Separate }); run.AppendChild(new DW.Text { Text = "" }); run.AppendChild(new FieldChar { FieldCharType = FieldCharValues.End }); sdtContentBlock.AppendChild(paragraph); sdtBlock.SdtContentBlock = sdtContentBlock; return sdtBlock; }
static void AddWatermark(WordprocessingDocument doc, string textWatermark) { if (doc.MainDocumentPart.HeaderParts.Count() == 0) { doc.MainDocumentPart.DeleteParts(doc.MainDocumentPart.HeaderParts); var newHeaderPart = doc.MainDocumentPart.AddNewPart <HeaderPart>(); var rId = doc.MainDocumentPart.GetIdOfPart(newHeaderPart); var headerRef = new HeaderReference(); headerRef.Id = rId; var sectionProps = doc.MainDocumentPart.Document.Body.Elements <SectionProperties>().LastOrDefault(); if (sectionProps == null) { sectionProps = new SectionProperties(); doc.MainDocumentPart.Document.Body.Append(sectionProps); } sectionProps.RemoveAllChildren <HeaderReference>(); sectionProps.Append(headerRef); newHeaderPart.Header = MakeHeader(); newHeaderPart.Header.Save(); } foreach (HeaderPart headerPart in doc.MainDocumentPart.HeaderParts) { var sdtBlock1 = new SdtBlock(); var sdtProperties1 = new SdtProperties(); var sdtId1 = new SdtId() { Val = 87908844 }; var sdtContentDocPartObject1 = new SdtContentDocPartObject(); var docPartGallery1 = new DocPartGallery() { Val = "Watermarks" }; var docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); var sdtContentBlock1 = new SdtContentBlock(); var paragraph2 = new Paragraph() { RsidParagraphAddition = "00656E18", RsidRunAdditionDefault = "00656E18" }; var paragraphProperties2 = new ParagraphProperties(); var paragraphStyleId2 = new ParagraphStyleId() { Val = "Header" }; paragraphProperties2.Append(paragraphStyleId2); var run1 = new Run(); var runProperties1 = new RunProperties(); var noProof1 = new NoProof(); var languages1 = new Languages() { EastAsia = "zh-TW" }; runProperties1.Append(noProof1); runProperties1.Append(languages1); var picture1 = new Picture(); var shapetype1 = new Shapetype() { Id = "_x0000_t136", CoordinateSize = "21600,21600", OptionalNumber = 136, Adjustment = "10800", EdgePath = "m@7,l@8,m@5,21600l@6,21600e" }; var formulas1 = new Formulas(); var formula1 = new Formula() { Equation = "sum #0 0 10800" }; var formula2 = new Formula() { Equation = "prod #0 2 1" }; var formula3 = new Formula() { Equation = "sum 21600 0 @1" }; var formula4 = new Formula() { Equation = "sum 0 0 @2" }; var formula5 = new Formula() { Equation = "sum 21600 0 @3" }; var formula6 = new Formula() { Equation = "if @0 @3 0" }; var formula7 = new Formula() { Equation = "if @0 21600 @1" }; var formula8 = new Formula() { Equation = "if @0 0 @2" }; var formula9 = new Formula() { Equation = "if @0 @4 21600" }; var formula10 = new Formula() { Equation = "mid @5 @6" }; var formula11 = new Formula() { Equation = "mid @8 @5" }; var formula12 = new Formula() { Equation = "mid @7 @8" }; var formula13 = new Formula() { Equation = "mid @6 @7" }; var formula14 = new Formula() { Equation = "sum @6 0 @5" }; formulas1.Append(formula1); formulas1.Append(formula2); formulas1.Append(formula3); formulas1.Append(formula4); formulas1.Append(formula5); formulas1.Append(formula6); formulas1.Append(formula7); formulas1.Append(formula8); formulas1.Append(formula9); formulas1.Append(formula10); formulas1.Append(formula11); formulas1.Append(formula12); formulas1.Append(formula13); formulas1.Append(formula14); var path1 = new Path() { AllowTextPath = TrueFalseValue.FromBoolean(true), ConnectionPointType = ConnectValues.Custom, ConnectionPoints = "@9,0;@10,10800;@11,21600;@12,10800", ConnectAngles = "270,180,90,0" }; var textPath1 = new TextPath() { On = TrueFalseValue.FromBoolean(true), FitShape = TrueFalseValue.FromBoolean(true) }; var shapeHandles1 = new ShapeHandles(); var shapeHandle1 = new ShapeHandle() { Position = "#0,bottomRight", XRange = "6629,14971" }; shapeHandles1.Append(shapeHandle1); var lock1 = new Lock { Extension = ExtensionHandlingBehaviorValues.Edit, TextLock = TrueFalseValue.FromBoolean(true), ShapeType = TrueFalseValue.FromBoolean(true) }; shapetype1.Append(formulas1); shapetype1.Append(path1); shapetype1.Append(textPath1); shapetype1.Append(shapeHandles1); shapetype1.Append(lock1); var shape1 = new Shape() { Id = "PowerPlusWaterMarkObject357922611", Style = "position:absolute;left:0;text-align:left;margin-left:0;margin-top:0;width:527.85pt;height:131.95pt;rotation:315;z-index:-251656192;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin", OptionalString = "_x0000_s2049", AllowInCell = TrueFalseValue.FromBoolean(true), FillColor = "silver", Stroked = TrueFalseValue.FromBoolean(false), Type = "#_x0000_t136" }; var fill1 = new Fill() { Opacity = ".5" }; TextPath textPath2 = new TextPath() { Style = "font-family:\"Calibri\";font-size:1pt", String = textWatermark }; var textWrap1 = new TextWrap() { AnchorX = HorizontalAnchorValues.Margin, AnchorY = VerticalAnchorValues.Margin }; shape1.Append(fill1); shape1.Append(textPath2); shape1.Append(textWrap1); picture1.Append(shapetype1); picture1.Append(shape1); run1.Append(runProperties1); run1.Append(picture1); paragraph2.Append(paragraphProperties2); paragraph2.Append(run1); sdtContentBlock1.Append(paragraph2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtContentBlock1); headerPart.Header.Append(sdtBlock1); headerPart.Header.Save(); //break; } }
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; } } }
// Generates content of footerPart1. private void GenerateFooterPart1Content(FooterPart footerPart1) { Footer footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se wp14" } }; footer1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); footer1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); footer1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); footer1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); footer1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); footer1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); footer1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); footer1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); footer1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); footer1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); footer1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); footer1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); footer1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); footer1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); footer1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); footer1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); footer1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); footer1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); footer1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); footer1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties50 = new SdtProperties(); SdtId sdtId50 = new SdtId() { Val = -1161223993 }; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() { Val = "Page Numbers (Bottom of Page)" }; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties50.Append(sdtId50); sdtProperties50.Append(sdtContentDocPartObject1); SdtEndCharProperties sdtEndCharProperties50 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph369 = new Paragraph() { RsidParagraphAddition = "0094109A", RsidParagraphProperties = "00697199", RsidRunAdditionDefault = "00A563A2", ParagraphId = "3CF2B95B", TextId = "59B2ED64" }; ParagraphProperties paragraphProperties366 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId26 = new ParagraphStyleId() { Val = "Footer" }; paragraphProperties366.Append(paragraphStyleId26); Hyperlink hyperlink1 = new Hyperlink() { History = true, Id = "rId1" }; Run run738 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties780 = new RunProperties(); FontSize fontSize1048 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1034 = new FontSizeComplexScript() { Val = "20" }; runProperties780.Append(fontSize1048); runProperties780.Append(fontSizeComplexScript1034); Text text700 = new Text(); text700.Text = "BJC IS Tech Management Standards"; run738.Append(runProperties780); run738.Append(text700); hyperlink1.Append(run738); Run run739 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties781 = new RunProperties(); FontSize fontSize1049 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1035 = new FontSizeComplexScript() { Val = "20" }; runProperties781.Append(fontSize1049); runProperties781.Append(fontSizeComplexScript1035); Text text701 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text701.Text = " can be found at: "; run739.Append(runProperties781); run739.Append(text701); Hyperlink hyperlink2 = new Hyperlink() { History = true, Id = "rId2" }; Run run740 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties782 = new RunProperties(); RunStyle runStyle2 = new RunStyle() { Val = "Hyperlink" }; FontSize fontSize1050 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1036 = new FontSizeComplexScript() { Val = "20" }; runProperties782.Append(runStyle2); runProperties782.Append(fontSize1050); runProperties782.Append(fontSizeComplexScript1036); Text text702 = new Text(); text702.Text = "http://bjcis/sites/techservices/Informational%20Documents/Forms/AllItems.aspx"; run740.Append(runProperties782); run740.Append(text702); hyperlink2.Append(run740); Run run741 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties783 = new RunProperties(); FontSize fontSize1051 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1037 = new FontSizeComplexScript() { Val = "20" }; runProperties783.Append(fontSize1051); runProperties783.Append(fontSizeComplexScript1037); TabChar tabChar45 = new TabChar(); run741.Append(runProperties783); run741.Append(tabChar45); Run run742 = new Run() { RsidRunAddition = "00697199" }; RunProperties runProperties784 = new RunProperties(); FontSize fontSize1052 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1038 = new FontSizeComplexScript() { Val = "20" }; runProperties784.Append(fontSize1052); runProperties784.Append(fontSizeComplexScript1038); Text text703 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text703.Text = " "; run742.Append(runProperties784); run742.Append(text703); SdtRun sdtRun50 = new SdtRun(); SdtProperties sdtProperties51 = new SdtProperties(); RunProperties runProperties785 = new RunProperties(); FontSize fontSize1053 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1039 = new FontSizeComplexScript() { Val = "20" }; runProperties785.Append(fontSize1053); runProperties785.Append(fontSizeComplexScript1039); SdtId sdtId51 = new SdtId() { Val = 860082579 }; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() { Val = "Page Numbers (Top of Page)" }; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties51.Append(runProperties785); sdtProperties51.Append(sdtId51); sdtProperties51.Append(sdtContentDocPartObject2); SdtEndCharProperties sdtEndCharProperties51 = new SdtEndCharProperties(); RunProperties runProperties786 = new RunProperties(); FontSize fontSize1054 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript1040 = new FontSizeComplexScript() { Val = "24" }; runProperties786.Append(fontSize1054); runProperties786.Append(fontSizeComplexScript1040); sdtEndCharProperties51.Append(runProperties786); SdtContentRun sdtContentRun50 = new SdtContentRun(); Run run743 = new Run() { RsidRunAddition = "0094109A" }; Text text704 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text704.Text = "Page "; run743.Append(text704); Run run744 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties787 = new RunProperties(); Bold bold109 = new Bold(); BoldComplexScript boldComplexScript4 = new BoldComplexScript(); runProperties787.Append(bold109); runProperties787.Append(boldComplexScript4); FieldChar fieldChar1 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run744.Append(runProperties787); run744.Append(fieldChar1); Run run745 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties788 = new RunProperties(); Bold bold110 = new Bold(); BoldComplexScript boldComplexScript5 = new BoldComplexScript(); runProperties788.Append(bold110); runProperties788.Append(boldComplexScript5); FieldCode fieldCode1 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve }; fieldCode1.Text = " PAGE "; run745.Append(runProperties788); run745.Append(fieldCode1); Run run746 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties789 = new RunProperties(); Bold bold111 = new Bold(); BoldComplexScript boldComplexScript6 = new BoldComplexScript(); runProperties789.Append(bold111); runProperties789.Append(boldComplexScript6); FieldChar fieldChar2 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run746.Append(runProperties789); run746.Append(fieldChar2); Run run747 = new Run() { RsidRunAddition = "007F6223" }; RunProperties runProperties790 = new RunProperties(); Bold bold112 = new Bold(); BoldComplexScript boldComplexScript7 = new BoldComplexScript(); NoProof noProof2 = new NoProof(); runProperties790.Append(bold112); runProperties790.Append(boldComplexScript7); runProperties790.Append(noProof2); Text text705 = new Text(); text705.Text = "1"; run747.Append(runProperties790); run747.Append(text705); Run run748 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties791 = new RunProperties(); Bold bold113 = new Bold(); BoldComplexScript boldComplexScript8 = new BoldComplexScript(); runProperties791.Append(bold113); runProperties791.Append(boldComplexScript8); FieldChar fieldChar3 = new FieldChar() { FieldCharType = FieldCharValues.End }; run748.Append(runProperties791); run748.Append(fieldChar3); Run run749 = new Run() { RsidRunAddition = "0094109A" }; Text text706 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text706.Text = " of "; run749.Append(text706); Run run750 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties792 = new RunProperties(); Bold bold114 = new Bold(); BoldComplexScript boldComplexScript9 = new BoldComplexScript(); runProperties792.Append(bold114); runProperties792.Append(boldComplexScript9); FieldChar fieldChar4 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run750.Append(runProperties792); run750.Append(fieldChar4); Run run751 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties793 = new RunProperties(); Bold bold115 = new Bold(); BoldComplexScript boldComplexScript10 = new BoldComplexScript(); runProperties793.Append(bold115); runProperties793.Append(boldComplexScript10); FieldCode fieldCode2 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve }; fieldCode2.Text = " NUMPAGES "; run751.Append(runProperties793); run751.Append(fieldCode2); Run run752 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties794 = new RunProperties(); Bold bold116 = new Bold(); BoldComplexScript boldComplexScript11 = new BoldComplexScript(); runProperties794.Append(bold116); runProperties794.Append(boldComplexScript11); FieldChar fieldChar5 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run752.Append(runProperties794); run752.Append(fieldChar5); Run run753 = new Run() { RsidRunAddition = "007F6223" }; RunProperties runProperties795 = new RunProperties(); Bold bold117 = new Bold(); BoldComplexScript boldComplexScript12 = new BoldComplexScript(); NoProof noProof3 = new NoProof(); runProperties795.Append(bold117); runProperties795.Append(boldComplexScript12); runProperties795.Append(noProof3); Text text707 = new Text(); text707.Text = "8"; run753.Append(runProperties795); run753.Append(text707); Run run754 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties796 = new RunProperties(); Bold bold118 = new Bold(); BoldComplexScript boldComplexScript13 = new BoldComplexScript(); runProperties796.Append(bold118); runProperties796.Append(boldComplexScript13); FieldChar fieldChar6 = new FieldChar() { FieldCharType = FieldCharValues.End }; run754.Append(runProperties796); run754.Append(fieldChar6); sdtContentRun50.Append(run743); sdtContentRun50.Append(run744); sdtContentRun50.Append(run745); sdtContentRun50.Append(run746); sdtContentRun50.Append(run747); sdtContentRun50.Append(run748); sdtContentRun50.Append(run749); sdtContentRun50.Append(run750); sdtContentRun50.Append(run751); sdtContentRun50.Append(run752); sdtContentRun50.Append(run753); sdtContentRun50.Append(run754); sdtRun50.Append(sdtProperties51); sdtRun50.Append(sdtEndCharProperties51); sdtRun50.Append(sdtContentRun50); paragraph369.Append(paragraphProperties366); paragraph369.Append(hyperlink1); paragraph369.Append(run739); paragraph369.Append(hyperlink2); paragraph369.Append(run741); paragraph369.Append(run742); paragraph369.Append(sdtRun50); sdtContentBlock1.Append(paragraph369); sdtBlock1.Append(sdtProperties50); sdtBlock1.Append(sdtEndCharProperties50); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph370 = new Paragraph() { RsidParagraphAddition = "0094109A", RsidParagraphProperties = "000F55C6", RsidRunAdditionDefault = "0094109A", ParagraphId = "0AAC1AD4", TextId = "7EFCA27E" }; ParagraphProperties paragraphProperties367 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId27 = new ParagraphStyleId() { Val = "Footer" }; Justification justification77 = new Justification() { Val = JustificationValues.Center }; paragraphProperties367.Append(paragraphStyleId27); paragraphProperties367.Append(justification77); paragraph370.Append(paragraphProperties367); footer1.Append(sdtBlock1); footer1.Append(paragraph370); footerPart1.Footer = footer1; }
private void button1_Click(object sender, EventArgs e) { PriceData.getPriceDataToDay("ACB"); if (File.Exists("template_output.docx")) { File.Delete("template_output.docx"); } File.Copy("template_input.docx", "template_output.docx"); //OpenXMLUtils.createDocument("t.docx"); //OpenXMLUtils.CreateTable("t.docx"); //OpenXMLUtils.replacePicture("template.docx"); using (WordprocessingDocument doc = WordprocessingDocument.Open("template_output.docx", true)) { SearchAndReplacer.SearchAndReplace(doc, "[date]", DateTime.Now.ToShortDateString(), true); SearchAndReplacer.SearchAndReplace(doc, "[Market Overview]", "Với một phiên tăng giá tiếp tục trên cả 2 sàn trong ngày 10/1, các tín hiệu xác nhận sự đảo chiều giảm điểm đã không xuất hiện, đà tăng giá vẫn chưa có dấu hiệu dừng lại. ", true); SearchAndReplacer.SearchAndReplace(doc, "[change1]", "+2.53%", true); SearchAndReplacer.SearchAndReplace(doc, "[change2]", "+1.54%", true); SearchAndReplacer.SearchAndReplace(doc, "[gtdc1]", "460.12", true); SearchAndReplacer.SearchAndReplace(doc, "[gtdc2]", "60.53", true); SearchAndReplacer.SearchAndReplace(doc, "[klgd1]", "79.394.580", true); SearchAndReplacer.SearchAndReplace(doc, "[klgd2]", "67.007.880", true); SearchAndReplacer.SearchAndReplace(doc, "[gtgd1]", "1.523,346", true); SearchAndReplacer.SearchAndReplace(doc, "[gtgd2]", "470,871", true); // Dispose the previous instance. if (documentManipulator != null) { documentManipulator.Dispose(); } documentManipulator = new WordDocumentImageManipulator(doc); int i = 1; foreach (var blip in documentManipulator.GetAllImages()) { if (i == 1) { documentManipulator.ReplaceImage( blip, new FileInfo("lineChart.jpg")); i++; continue; } documentManipulator.ReplaceImage( blip, new FileInfo("ck" + (i - 1) + ".png")); i++; } string tblTag = "StockTableTag"; MainDocumentPart mainPart = doc.MainDocumentPart; //StockService.baseDS.stockCodeDataTable tbl = Gateway.PriceData.getPriceDataToDay(); SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where (r => r.SdtProperties.GetFirstChild <Tag>().Val == tblTag).Single(); // This should return only one table. Table theTable = ccWithTable.Descendants <Table>().Single(); // Get the last row in the table. TableRow theRow = theTable.Elements <TableRow>().Last(); foreach (var item in lstStockCodes) { try { StockService.baseDS.priceDataRow row = Gateway.PriceData.getPriceDataToDay(item); TableRow rowCopy = (TableRow)theRow.CloneNode(true); rowCopy.Descendants <TableCell>().ElementAt(0).Append(new Paragraph (new Run(new Text(row.stockCode.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(1).Append(new Paragraph (new Run(new Text(row.openPrice.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(2).Append(new Paragraph (new Run(new Text(row.closePrice.ToString())))); rowCopy.Descendants <TableCell>().ElementAt(3).Append(new Paragraph (new Run(new Text(row.volume.ToString())))); theTable.AppendChild(rowCopy); } catch (Exception ex) { continue; } } // Remove the empty placeholder row from the table. theTable.RemoveChild(theRow); // Save the changes to the table back into the document. mainPart.Document.Save(); } MessageBox.Show("Input->template_input.docx and Ouput->template_output.docx. Success!!! The program will be closed!!!"); this.Close(); }
public static Paragraph GetParagraph(this SdtBlock block) { var paragraph = block.SdtContentBlock !.GetFirstChild <Paragraph>() !; return(paragraph); }
private SdtBlock GetTableOfContents() { SdtBlock tableOfContents = new SdtBlock(); RunProperties tocRpr = new RunProperties(new RunFonts() { HighAnsi = renderData.RenderSettings.FontFamily }, new Color() { Val = "auto" }, new FontSize() { Val = renderData.RenderSettings.DefaultTextSize }); SdtContentDocPartObject sdtContentDocPartObject = new SdtContentDocPartObject( new DocPartGallery() { Val = "Table of Contents" }, new DocPartUnique()); SdtProperties sdtProperties = new SdtProperties(tocRpr, sdtContentDocPartObject); tableOfContents.Append(sdtProperties); tableOfContents.Append(new SdtEndCharProperties()); SdtContentBlock sdtContentBlock = new SdtContentBlock(); WordParagraph p = new WordParagraph(); ParagraphProperties ppr = new ParagraphProperties() { Justification = new Justification() { Val = JustificationValues.Center } }; p.Append(ppr); RunProperties rpr = new RunProperties(new RunFonts() { Ascii = renderData.RenderSettings.FontFamily, HighAnsi = renderData.RenderSettings.FontFamily }) { Bold = new Bold(), Caps = new Caps(), FontSize = new FontSize() { Val = renderData.RenderSettings.DefaultTextSize } }; Run run = new Run(); run.Append(rpr); Text text = new Text("Содержание"); run.Append(text); p.Append(run); sdtContentBlock.Append(p); string index = "0"; foreach (DocumentElementRenderDto element in renderData.Document.Elements) { index = (int.Parse(index) + 1).ToString(); UploadItemsToTableOfContents(element, sdtContentBlock, 0, index); } tableOfContents.Append(sdtContentBlock); return(tableOfContents); }
// Generates content of mainDocumentPart1. private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1) { Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se wp14" } }; document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); document1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); document1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); document1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Body body1 = new Body(); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00EC73B1", RsidRunAdditionDefault = "00EC73B1" }; Run run1 = new Run(); Text text1 = new Text(); text1.Text = "Test 1"; run1.Append(text1); paragraph1.Append(run1); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); Tag tag1 = new Tag() { Val = "testa" }; SdtId sdtId1 = new SdtId() { Val = -1218056249 }; SdtPlaceholder sdtPlaceholder1 = new SdtPlaceholder(); DocPartReference docPartReference1 = new DocPartReference() { Val = "DefaultPlaceholder_-1854013440" }; sdtPlaceholder1.Append(docPartReference1); sdtProperties1.Append(tag1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtPlaceholder1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "001E13C4", RsidRunAdditionDefault = "001E13C4" }; Run run2 = new Run(); Text text2 = new Text(); text2.Text = "Test a"; run2.Append(text2); paragraph2.Append(run2); sdtContentBlock1.Append(paragraph2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "00EC73B1", RsidRunAdditionDefault = "00EC73B1" }; Run run3 = new Run(); Break break1 = new Break() { Type = BreakValues.Page }; run3.Append(break1); paragraph3.Append(run3); Paragraph paragraph4 = new Paragraph() { RsidParagraphAddition = "00A15A83", RsidRunAdditionDefault = "00EC73B1" }; Run run4 = new Run(); LastRenderedPageBreak lastRenderedPageBreak1 = new LastRenderedPageBreak(); Text text3 = new Text(); text3.Text = "Test 2"; run4.Append(lastRenderedPageBreak1); run4.Append(text3); paragraph4.Append(run4); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", DisplacedByCustomXml = DisplacedByCustomXmlValues.Next, Id = "0" }; SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); Tag tag2 = new Tag() { Val = "testb" }; SdtId sdtId2 = new SdtId() { Val = -285745073 }; SdtPlaceholder sdtPlaceholder2 = new SdtPlaceholder(); DocPartReference docPartReference2 = new DocPartReference() { Val = "03E0ACA1F9B64F42892D8CC68D472C5B" }; sdtPlaceholder2.Append(docPartReference2); sdtProperties2.Append(tag2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtPlaceholder2); SdtEndCharProperties sdtEndCharProperties2 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph5 = new Paragraph() { RsidParagraphAddition = "001E13C4", RsidParagraphProperties = "001E13C4", RsidRunAdditionDefault = "001E13C4" }; Run run5 = new Run(); Text text4 = new Text(); text4.Text = "Test b"; run5.Append(text4); paragraph5.Append(run5); sdtContentBlock2.Append(paragraph5); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtEndCharProperties2); sdtBlock2.Append(sdtContentBlock2); BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { DisplacedByCustomXml = DisplacedByCustomXmlValues.Previous, Id = "0" }; Paragraph paragraph6 = new Paragraph() { RsidParagraphAddition = "001E13C4", RsidRunAdditionDefault = "001E13C4" }; SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "001E13C4" }; PageSize pageSize1 = new PageSize() { Width = (UInt32Value)11906U, Height = (UInt32Value)16838U }; PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)708U, Footer = (UInt32Value)708U, Gutter = (UInt32Value)0U }; Columns columns1 = new Columns() { Space = "708" }; DocGrid docGrid1 = new DocGrid() { LinePitch = 360 }; sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); sectionProperties1.Append(docGrid1); body1.Append(paragraph1); body1.Append(sdtBlock1); body1.Append(paragraph3); body1.Append(paragraph4); body1.Append(bookmarkStart1); body1.Append(sdtBlock2); body1.Append(bookmarkEnd1); body1.Append(paragraph6); body1.Append(sectionProperties1); document1.Append(body1); mainDocumentPart1.Document = document1; }
public static SdtBlock CreateTable(List <ColumnTable> columns, string tableName) { SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); RunProperties runProperties1 = new RunProperties(); Bold bold1 = new Bold() { Val = false }; BoldComplexScript boldComplexScript1 = new BoldComplexScript() { Val = false }; Color color1 = new Color() { Val = "auto" }; Languages languages1 = new Languages() { Val = "en-US" }; runProperties1.Append(bold1); runProperties1.Append(boldComplexScript1); runProperties1.Append(color1); runProperties1.Append(languages1); SdtAlias sdtAlias1 = new SdtAlias() { Val = tableName }; Tag tag1 = new Tag() { Val = tableName }; SdtId sdtId1 = new SdtId() { Val = -1702077049 }; SdtPlaceholder sdtPlaceholder1 = new SdtPlaceholder(); DocPartReference docPartReference1 = new DocPartReference() { Val = "DefaultPlaceholder_1081868574" }; sdtPlaceholder1.Append(docPartReference1); sdtProperties1.Append(runProperties1); sdtProperties1.Append(sdtAlias1); sdtProperties1.Append(tag1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtPlaceholder1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Table table1 = new Table(); TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "GridTable4-Accent1" }; TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }; 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); 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 = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tableCellMarginDefault1); tableProperties1.Append(tableBorders1); tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); foreach (ColumnTable column in columns) { GridColumn gridColumn1 = new GridColumn() { }; tableGrid1.Append(gridColumn1); } TableRow tableRow1 = CreateHeaderRow(columns); TableRow tableRow2 = CreateCellRow(columns); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); table1.Append(tableRow2); sdtContentBlock1.Append(table1); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); return(sdtBlock1); }
public static Footer GenerateFooter() { Footer footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } }; footer1.SetAttribute(new OpenXmlAttribute("xmlns", "wpi", "http://www.w3.org/2000/xmlns/", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk")); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); SdtId sdtId1 = new SdtId() { Val = -2004816677 }; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() { Val = "Page Numbers (Bottom of Page)" }; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); SdtId sdtId2 = new SdtId() { Val = 262557138 }; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() { Val = "Page Numbers (Top of Page)" }; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtContentDocPartObject2); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "000A3202", RsidRunAdditionDefault = "000A3202", ParagraphId = "450F18F9", TextId = "3669B4E6" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "a6" }; Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties1.Append(paragraphStyleId1); paragraphProperties1.Append(justification1); Run run1 = new Run(); Text text1 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text1.Text = "Страница "; run1.Append(text1); Run run2 = new Run(); RunProperties runProperties1 = new RunProperties(); Bold bold1 = new Bold(); FontSize fontSize1 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "24" }; runProperties1.Append(bold1); runProperties1.Append(fontSize1); runProperties1.Append(fontSizeComplexScript1); FieldChar fieldChar1 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run2.Append(runProperties1); run2.Append(fieldChar1); Run run3 = new Run(); RunProperties runProperties2 = new RunProperties(); Bold bold2 = new Bold(); runProperties2.Append(bold2); FieldCode fieldCode1 = new FieldCode(); fieldCode1.Text = "PAGE"; run3.Append(runProperties2); run3.Append(fieldCode1); Run run4 = new Run(); RunProperties runProperties3 = new RunProperties(); Bold bold3 = new Bold(); FontSize fontSize2 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "24" }; runProperties3.Append(bold3); runProperties3.Append(fontSize2); runProperties3.Append(fontSizeComplexScript2); FieldChar fieldChar2 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run4.Append(runProperties3); run4.Append(fieldChar2); Run run5 = new Run(); RunProperties runProperties4 = new RunProperties(); Bold bold4 = new Bold(); NoProof noProof1 = new NoProof(); runProperties4.Append(bold4); runProperties4.Append(noProof1); Text text2 = new Text(); text2.Text = "2"; run5.Append(runProperties4); run5.Append(text2); Run run6 = new Run(); RunProperties runProperties5 = new RunProperties(); Bold bold5 = new Bold(); FontSize fontSize3 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript() { Val = "24" }; runProperties5.Append(bold5); runProperties5.Append(fontSize3); runProperties5.Append(fontSizeComplexScript3); FieldChar fieldChar3 = new FieldChar() { FieldCharType = FieldCharValues.End }; run6.Append(runProperties5); run6.Append(fieldChar3); Run run7 = new Run(); Text text3 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text3.Text = " из "; run7.Append(text3); Run run8 = new Run(); RunProperties runProperties6 = new RunProperties(); Bold bold6 = new Bold(); FontSize fontSize4 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript() { Val = "24" }; runProperties6.Append(bold6); runProperties6.Append(fontSize4); runProperties6.Append(fontSizeComplexScript4); FieldChar fieldChar4 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run8.Append(runProperties6); run8.Append(fieldChar4); Run run9 = new Run(); RunProperties runProperties7 = new RunProperties(); Bold bold7 = new Bold(); runProperties7.Append(bold7); FieldCode fieldCode2 = new FieldCode(); fieldCode2.Text = "NUMPAGES"; run9.Append(runProperties7); run9.Append(fieldCode2); Run run10 = new Run(); RunProperties runProperties8 = new RunProperties(); Bold bold8 = new Bold(); FontSize fontSize5 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript5 = new FontSizeComplexScript() { Val = "24" }; runProperties8.Append(bold8); runProperties8.Append(fontSize5); runProperties8.Append(fontSizeComplexScript5); FieldChar fieldChar5 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run10.Append(runProperties8); run10.Append(fieldChar5); Run run11 = new Run(); RunProperties runProperties9 = new RunProperties(); Bold bold9 = new Bold(); NoProof noProof2 = new NoProof(); runProperties9.Append(bold9); runProperties9.Append(noProof2); Text text4 = new Text(); text4.Text = "2"; run11.Append(runProperties9); run11.Append(text4); Run run12 = new Run(); RunProperties runProperties10 = new RunProperties(); Bold bold10 = new Bold(); FontSize fontSize6 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript6 = new FontSizeComplexScript() { Val = "24" }; runProperties10.Append(bold10); runProperties10.Append(fontSize6); runProperties10.Append(fontSizeComplexScript6); FieldChar fieldChar6 = new FieldChar() { FieldCharType = FieldCharValues.End }; run12.Append(runProperties10); run12.Append(fieldChar6); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); paragraph1.Append(run2); paragraph1.Append(run3); paragraph1.Append(run4); paragraph1.Append(run5); paragraph1.Append(run6); paragraph1.Append(run7); paragraph1.Append(run8); paragraph1.Append(run9); paragraph1.Append(run10); paragraph1.Append(run11); paragraph1.Append(run12); sdtContentBlock2.Append(paragraph1); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtContentBlock2); sdtContentBlock1.Append(sdtBlock2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "000A3202", RsidRunAdditionDefault = "000A3202", ParagraphId = "7CCB7F19", TextId = "77777777" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId() { Val = "a6" }; paragraphProperties2.Append(paragraphStyleId2); paragraph2.Append(paragraphProperties2); footer1.Append(sdtBlock1); footer1.Append(paragraph2); return(footer1); }
public static TableCell CreateColumnCell(ColumnTable column) { TableCell tableCell = new TableCell(); TableCellProperties tableCellProperties = new TableCellProperties(); DocumentFormat.OpenXml.Wordprocessing.ConditionalFormatStyle conditionalFormatStyleCell1 = new ConditionalFormatStyle() { Val = "001000000000", FirstRow = false, LastRow = false, FirstColumn = true, LastColumn = false, OddVerticalBand = false, EvenVerticalBand = false, OddHorizontalBand = false, EvenHorizontalBand = false, FirstRowFirstColumn = false, FirstRowLastColumn = false, LastRowFirstColumn = false, LastRowLastColumn = false }; DocumentFormat.OpenXml.Wordprocessing.TableCellWidth tableCellWidth1 = new TableCellWidth() { Type = TableWidthUnitValues.Dxa }; tableCellProperties.Append(conditionalFormatStyleCell1); tableCellProperties.Append(tableCellWidth1); SdtBlock sdtBlockSub = new SdtBlock(); SdtProperties sdtProperties = new SdtProperties(); RunProperties runProperties = new RunProperties(); RunFonts runFonts1 = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" }; FontSize fontSize1 = new FontSize() { Val = "28" }; FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "28" }; runProperties.Append(runFonts1); runProperties.Append(fontSize1); runProperties.Append(fontSizeComplexScript1); SdtAlias sdtAliasSub = new SdtAlias() { Val = column.ColumnField }; Tag tagCell = new Tag() { Val = column.ColumnField }; SdtId sdtIdCell = new SdtId() { Val = -2144724967 }; SdtPlaceholder sdtPlaceholderCell1 = new SdtPlaceholder(); DocPartReference docPartReferenceCell1 = new DocPartReference() { Val = "941489452D594FF2A513A53EEFA3E58F" }; sdtPlaceholderCell1.Append(docPartReferenceCell1); sdtProperties.Append(runProperties); sdtProperties.Append(sdtAliasSub); sdtProperties.Append(tagCell); sdtProperties.Append(sdtIdCell); sdtProperties.Append(sdtPlaceholderCell1); SdtContentBlock sdtContentBlockSub = new SdtContentBlock(); Paragraph paragraphCell = new Paragraph() { RsidParagraphAddition = "00C03259", RsidParagraphProperties = "00BB7EFE", RsidRunAdditionDefault = "00C03259" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunPropertiesCell = new ParagraphMarkRunProperties(); RunFonts runFonts2 = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" }; FontSize fontSize2 = new FontSize() { Val = "28" }; FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "28" }; paragraphMarkRunPropertiesCell.Append(runFonts2); paragraphMarkRunPropertiesCell.Append(fontSize2); paragraphMarkRunPropertiesCell.Append(fontSizeComplexScript2); paragraphProperties1.Append(paragraphMarkRunPropertiesCell); Run runCell = new Run(); RunProperties runPropertiesCell = new RunProperties(); RunFonts runFonts3 = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" }; Bold bold1 = new Bold() { Val = false }; FontSize fontSize3 = new FontSize() { Val = "28" }; FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript() { Val = "28" }; runPropertiesCell.Append(runFonts3); runPropertiesCell.Append(bold1); runPropertiesCell.Append(fontSize3); runPropertiesCell.Append(fontSizeComplexScript3); Text textCell = new Text(); textCell.Text = column.ColumnHeader; runCell.Append(runPropertiesCell); runCell.Append(textCell); paragraphCell.Append(paragraphProperties1); paragraphCell.Append(runCell); sdtContentBlockSub.Append(paragraphCell); sdtBlockSub.Append(sdtProperties); sdtBlockSub.Append(sdtContentBlockSub); tableCell.Append(tableCellProperties); tableCell.Append(sdtBlockSub); return(tableCell); }
public IEnumerable <Run> GetRuns() { var runProperties = GetRunProperties(); foreach (var content in Contents) { switch (content) { case TextContent text: yield return(text.GetRun(runProperties)); break; case ImageContent img: yield return(img.GetRun(runProperties)); break; case CheckboxControl checkbox: { var run = new Run { RunProperties = runProperties.CloneNode() }; var cb = new CheckBox( new Checked { Val = checkbox.IsChecked ? OnOffValues.One : OnOffValues.Zero }, new CheckedState { Val = "0052", Font = "Wingdings 2" }, new UncheckedState { Val = "00A3", Font = "Wingdings 2" } ); var cbSdt = new SdtBlock( new SdtProperties( new Lock { Val = LockingValues.ContentLocked }, new Appearance { Val = SdtAppearance.Hidden }, cb), new SdtContentBlock( new Run(new SymbolChar { Font = "Wingdings 2", Char = checkbox.IsChecked ? "F052" : "F0A3" })) ); run.AppendChild(cbSdt); yield return(run); if (!string.IsNullOrWhiteSpace(checkbox.Label)) { yield return(new Run( new Text(checkbox.Label) { Space = SpaceProcessingModeValues.Preserve }) { RunProperties = runProperties.CloneNode() }); } break; } } } }
// Generates content of mainDocumentPart1. private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1) { Document document1 = new Document(); document1.AddNamespaceDeclaration("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"); document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); Body body1 = new Body(); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "006E2549", RsidRunAdditionDefault = "00E850CC" }; Run run1 = new Run(); Text text1 = new Text(); text1.Text = "This document contains content controls that will be bound to a custom XML part."; run1.Append(text1); paragraph1.Append(run1); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; 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" }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "1908" }; GridColumn gridColumn2 = new GridColumn() { Width = "4410" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties1.Append(tableCellWidth1); Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run2 = new Run(); Text text2 = new Text(); text2.Text = "Name"; run2.Append(text2); paragraph3.Append(run2); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph3); SdtCell sdtCell1 = new SdtCell(); SdtProperties sdtProperties1 = new SdtProperties(); SdtAlias sdtAlias1 = new SdtAlias() { Val = "Name" }; Tag tag1 = new Tag() { Val = "Name" }; SdtId sdtId1 = new SdtId() { Val = 13264407 }; SdtPlaceholder sdtPlaceholder1 = new SdtPlaceholder(); DocPartReference docPartReference1 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder1.Append(docPartReference1); DataBinding dataBinding1 = new DataBinding() { XPath = "/Root/Name", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText1 = new SdtContentText(); sdtProperties1.Append(sdtAlias1); sdtProperties1.Append(tag1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtPlaceholder1); sdtProperties1.Append(dataBinding1); sdtProperties1.Append(sdtContentText1); SdtContentCell sdtContentCell1 = new SdtContentCell(); TableCell tableCell2 = new TableCell(); TableCellProperties tableCellProperties2 = new TableCellProperties(); TableCellWidth tableCellWidth2 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties2.Append(tableCellWidth2); Paragraph paragraph4 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidParagraphProperties = "00E850CC", RsidRunAdditionDefault = "00A539C5" }; Run run3 = new Run(); Text text3 = new Text(); text3.Text = "Eric White"; run3.Append(text3); paragraph4.Append(run3); tableCell2.Append(tableCellProperties2); tableCell2.Append(paragraph4); sdtContentCell1.Append(tableCell2); sdtCell1.Append(sdtProperties1); sdtCell1.Append(sdtContentCell1); tableRow1.Append(tableCell1); tableRow1.Append(sdtCell1); TableRow tableRow2 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell3 = new TableCell(); TableCellProperties tableCellProperties3 = new TableCellProperties(); TableCellWidth tableCellWidth3 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties3.Append(tableCellWidth3); Paragraph paragraph5 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run4 = new Run(); Text text4 = new Text(); text4.Text = "Company"; run4.Append(text4); paragraph5.Append(run4); tableCell3.Append(tableCellProperties3); tableCell3.Append(paragraph5); TableCell tableCell4 = new TableCell(); TableCellProperties tableCellProperties4 = new TableCellProperties(); TableCellWidth tableCellWidth4 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties4.Append(tableCellWidth4); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); SdtAlias sdtAlias2 = new SdtAlias() { Val = "Company" }; Tag tag2 = new Tag() { Val = "Company" }; SdtId sdtId2 = new SdtId() { Val = 13264410 }; SdtPlaceholder sdtPlaceholder2 = new SdtPlaceholder(); DocPartReference docPartReference2 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder2.Append(docPartReference2); DataBinding dataBinding2 = new DataBinding() { XPath = "/Root/Company", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; sdtProperties2.Append(sdtAlias2); sdtProperties2.Append(tag2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtPlaceholder2); sdtProperties2.Append(dataBinding2); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph6 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run5 = new Run(); Text text5 = new Text(); text5.Text = "Microsoft Corporation"; run5.Append(text5); paragraph6.Append(run5); sdtContentBlock1.Append(paragraph6); sdtBlock1.Append(sdtProperties2); sdtBlock1.Append(sdtContentBlock1); tableCell4.Append(tableCellProperties4); tableCell4.Append(sdtBlock1); tableRow2.Append(tableCell3); tableRow2.Append(tableCell4); TableRow tableRow3 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell5 = new TableCell(); TableCellProperties tableCellProperties5 = new TableCellProperties(); TableCellWidth tableCellWidth5 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties5.Append(tableCellWidth5); Paragraph paragraph7 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run6 = new Run(); Text text6 = new Text(); text6.Text = "Address"; run6.Append(text6); paragraph7.Append(run6); tableCell5.Append(tableCellProperties5); tableCell5.Append(paragraph7); TableCell tableCell6 = new TableCell(); TableCellProperties tableCellProperties6 = new TableCellProperties(); TableCellWidth tableCellWidth6 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties6.Append(tableCellWidth6); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties3 = new SdtProperties(); SdtAlias sdtAlias3 = new SdtAlias() { Val = "Address" }; Tag tag3 = new Tag() { Val = "Address" }; SdtId sdtId3 = new SdtId() { Val = 13264411 }; SdtPlaceholder sdtPlaceholder3 = new SdtPlaceholder(); DocPartReference docPartReference3 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder3.Append(docPartReference3); DataBinding dataBinding3 = new DataBinding() { XPath = "/Root/Address", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText2 = new SdtContentText(); sdtProperties3.Append(sdtAlias3); sdtProperties3.Append(tag3); sdtProperties3.Append(sdtId3); sdtProperties3.Append(sdtPlaceholder3); sdtProperties3.Append(dataBinding3); sdtProperties3.Append(sdtContentText2); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph8 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run7 = new Run(); Text text7 = new Text(); text7.Text = "One Microsoft Way"; run7.Append(text7); paragraph8.Append(run7); sdtContentBlock2.Append(paragraph8); sdtBlock2.Append(sdtProperties3); sdtBlock2.Append(sdtContentBlock2); tableCell6.Append(tableCellProperties6); tableCell6.Append(sdtBlock2); tableRow3.Append(tableCell5); tableRow3.Append(tableCell6); TableRow tableRow4 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell7 = new TableCell(); TableCellProperties tableCellProperties7 = new TableCellProperties(); TableCellWidth tableCellWidth7 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties7.Append(tableCellWidth7); Paragraph paragraph9 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run8 = new Run(); Text text8 = new Text(); text8.Text = "City"; run8.Append(text8); paragraph9.Append(run8); tableCell7.Append(tableCellProperties7); tableCell7.Append(paragraph9); TableCell tableCell8 = new TableCell(); TableCellProperties tableCellProperties8 = new TableCellProperties(); TableCellWidth tableCellWidth8 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties8.Append(tableCellWidth8); SdtBlock sdtBlock3 = new SdtBlock(); SdtProperties sdtProperties4 = new SdtProperties(); SdtAlias sdtAlias4 = new SdtAlias() { Val = "City" }; Tag tag4 = new Tag() { Val = "City" }; SdtId sdtId4 = new SdtId() { Val = 13264412 }; SdtPlaceholder sdtPlaceholder4 = new SdtPlaceholder(); DocPartReference docPartReference4 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder4.Append(docPartReference4); DataBinding dataBinding4 = new DataBinding() { XPath = "/Root/City", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText3 = new SdtContentText(); sdtProperties4.Append(sdtAlias4); sdtProperties4.Append(tag4); sdtProperties4.Append(sdtId4); sdtProperties4.Append(sdtPlaceholder4); sdtProperties4.Append(dataBinding4); sdtProperties4.Append(sdtContentText3); SdtContentBlock sdtContentBlock3 = new SdtContentBlock(); Paragraph paragraph10 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run9 = new Run(); Text text9 = new Text(); text9.Text = "Redmond"; run9.Append(text9); paragraph10.Append(run9); sdtContentBlock3.Append(paragraph10); sdtBlock3.Append(sdtProperties4); sdtBlock3.Append(sdtContentBlock3); tableCell8.Append(tableCellProperties8); tableCell8.Append(sdtBlock3); tableRow4.Append(tableCell7); tableRow4.Append(tableCell8); TableRow tableRow5 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell9 = new TableCell(); TableCellProperties tableCellProperties9 = new TableCellProperties(); TableCellWidth tableCellWidth9 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties9.Append(tableCellWidth9); Paragraph paragraph11 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run10 = new Run(); Text text10 = new Text(); text10.Text = "State"; run10.Append(text10); paragraph11.Append(run10); tableCell9.Append(tableCellProperties9); tableCell9.Append(paragraph11); TableCell tableCell10 = new TableCell(); TableCellProperties tableCellProperties10 = new TableCellProperties(); TableCellWidth tableCellWidth10 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties10.Append(tableCellWidth10); SdtBlock sdtBlock4 = new SdtBlock(); SdtProperties sdtProperties5 = new SdtProperties(); SdtAlias sdtAlias5 = new SdtAlias() { Val = "State" }; Tag tag5 = new Tag() { Val = "State" }; SdtId sdtId5 = new SdtId() { Val = 13264413 }; SdtPlaceholder sdtPlaceholder5 = new SdtPlaceholder(); DocPartReference docPartReference5 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder5.Append(docPartReference5); DataBinding dataBinding5 = new DataBinding() { XPath = "/Root/State", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText4 = new SdtContentText(); sdtProperties5.Append(sdtAlias5); sdtProperties5.Append(tag5); sdtProperties5.Append(sdtId5); sdtProperties5.Append(sdtPlaceholder5); sdtProperties5.Append(dataBinding5); sdtProperties5.Append(sdtContentText4); SdtContentBlock sdtContentBlock4 = new SdtContentBlock(); Paragraph paragraph12 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run11 = new Run(); Text text11 = new Text(); text11.Text = "WA"; run11.Append(text11); paragraph12.Append(run11); sdtContentBlock4.Append(paragraph12); sdtBlock4.Append(sdtProperties5); sdtBlock4.Append(sdtContentBlock4); tableCell10.Append(tableCellProperties10); tableCell10.Append(sdtBlock4); tableRow5.Append(tableCell9); tableRow5.Append(tableCell10); TableRow tableRow6 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableCell tableCell11 = new TableCell(); TableCellProperties tableCellProperties11 = new TableCellProperties(); TableCellWidth tableCellWidth11 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties11.Append(tableCellWidth11); Paragraph paragraph13 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run12 = new Run(); Text text12 = new Text(); text12.Text = "Country"; run12.Append(text12); paragraph13.Append(run12); tableCell11.Append(tableCellProperties11); tableCell11.Append(paragraph13); TableCell tableCell12 = new TableCell(); TableCellProperties tableCellProperties12 = new TableCellProperties(); TableCellWidth tableCellWidth12 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties12.Append(tableCellWidth12); SdtBlock sdtBlock5 = new SdtBlock(); SdtProperties sdtProperties6 = new SdtProperties(); SdtAlias sdtAlias6 = new SdtAlias() { Val = "Country" }; Tag tag6 = new Tag() { Val = "Country" }; SdtId sdtId6 = new SdtId() { Val = 13264414 }; SdtPlaceholder sdtPlaceholder6 = new SdtPlaceholder(); DocPartReference docPartReference6 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder6.Append(docPartReference6); DataBinding dataBinding6 = new DataBinding() { XPath = "/Root/Country", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText5 = new SdtContentText(); sdtProperties6.Append(sdtAlias6); sdtProperties6.Append(tag6); sdtProperties6.Append(sdtId6); sdtProperties6.Append(sdtPlaceholder6); sdtProperties6.Append(dataBinding6); sdtProperties6.Append(sdtContentText5); SdtContentBlock sdtContentBlock5 = new SdtContentBlock(); Paragraph paragraph14 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run13 = new Run(); Text text13 = new Text(); text13.Text = "USA"; run13.Append(text13); paragraph14.Append(run13); sdtContentBlock5.Append(paragraph14); sdtBlock5.Append(sdtProperties6); sdtBlock5.Append(sdtContentBlock5); tableCell12.Append(tableCellProperties12); tableCell12.Append(sdtBlock5); tableRow6.Append(tableCell11); tableRow6.Append(tableCell12); TableRow tableRow7 = new TableRow() { RsidTableRowAddition = "00E850CC", RsidTableRowProperties = "00E850CC" }; TableRowProperties tableRowProperties1 = new TableRowProperties(); TableRowHeight tableRowHeight1 = new TableRowHeight() { Val = (UInt32Value)188U }; tableRowProperties1.Append(tableRowHeight1); TableCell tableCell13 = new TableCell(); TableCellProperties tableCellProperties13 = new TableCellProperties(); TableCellWidth tableCellWidth13 = new TableCellWidth() { Width = "1908", Type = TableWidthUnitValues.Dxa }; tableCellProperties13.Append(tableCellWidth13); Paragraph paragraph15 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run14 = new Run(); Text text14 = new Text(); text14.Text = "Postal Code"; run14.Append(text14); paragraph15.Append(run14); tableCell13.Append(tableCellProperties13); tableCell13.Append(paragraph15); TableCell tableCell14 = new TableCell(); TableCellProperties tableCellProperties14 = new TableCellProperties(); TableCellWidth tableCellWidth14 = new TableCellWidth() { Width = "4410", Type = TableWidthUnitValues.Dxa }; tableCellProperties14.Append(tableCellWidth14); SdtBlock sdtBlock6 = new SdtBlock(); SdtProperties sdtProperties7 = new SdtProperties(); SdtAlias sdtAlias7 = new SdtAlias() { Val = "PostalCode" }; Tag tag7 = new Tag() { Val = "PostalCode" }; SdtId sdtId7 = new SdtId() { Val = 13264415 }; SdtPlaceholder sdtPlaceholder7 = new SdtPlaceholder(); DocPartReference docPartReference7 = new DocPartReference() { Val = "DefaultPlaceholder_22675703" }; sdtPlaceholder7.Append(docPartReference7); DataBinding dataBinding7 = new DataBinding() { XPath = "/Root/PostalCode", StoreItemId = "{7776B924-6173-4963-94EF-05AF7A57A4C4}" }; SdtContentText sdtContentText6 = new SdtContentText(); sdtProperties7.Append(sdtAlias7); sdtProperties7.Append(tag7); sdtProperties7.Append(sdtId7); sdtProperties7.Append(sdtPlaceholder7); sdtProperties7.Append(dataBinding7); sdtProperties7.Append(sdtContentText6); SdtContentBlock sdtContentBlock6 = new SdtContentBlock(); Paragraph paragraph16 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; Run run15 = new Run(); Text text15 = new Text(); text15.Text = "98052"; run15.Append(text15); paragraph16.Append(run15); sdtContentBlock6.Append(paragraph16); sdtBlock6.Append(sdtProperties7); sdtBlock6.Append(sdtContentBlock6); tableCell14.Append(tableCellProperties14); tableCell14.Append(sdtBlock6); tableRow7.Append(tableRowProperties1); tableRow7.Append(tableCell13); tableRow7.Append(tableCell14); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); table1.Append(tableRow2); table1.Append(tableRow3); table1.Append(tableRow4); table1.Append(tableRow5); table1.Append(tableRow6); table1.Append(tableRow7); Paragraph paragraph17 = new Paragraph() { RsidParagraphAddition = "00E850CC", RsidRunAdditionDefault = "00E850CC" }; SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "00E850CC", RsidSect = "006E2549" }; PageSize pageSize1 = new PageSize() { Width = (UInt32Value)12240U, Height = (UInt32Value)15840U }; PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U }; Columns columns1 = new Columns() { Space = "720" }; DocGrid docGrid1 = new DocGrid() { LinePitch = 360 }; sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); sectionProperties1.Append(docGrid1); body1.Append(paragraph1); body1.Append(paragraph2); body1.Append(table1); body1.Append(paragraph17); body1.Append(sectionProperties1); document1.Append(body1); mainDocumentPart1.Document = document1; }
public OXMLSdtBlockWrap(OpenXmlElement element) { XMLStdBlock = (SdtBlock)element; }
public void CreateMSWordDocument(Guid identifier) { var myResume = _resumeManagerRepository.Get(m => m.Guid.Equals(identifier)).First().Resume; string projPath = HttpContext.Current.Server.MapPath("~/Content/"); string outFilePath = Path.Combine(projPath, "doc", myResume.ResumeManager.Link); byte[] templateBytes = System.IO.File.ReadAllBytes(projPath + "MSWordTemplates\\template4.dotx"); using (MemoryStream templateStream = new MemoryStream()) { templateStream.Write(templateBytes, 0, (int)templateBytes.Length); using (WordprocessingDocument doc = WordprocessingDocument.Open(templateStream, true)) { doc.ChangeDocumentType(WordprocessingDocumentType.Document); var mainPart = doc.MainDocumentPart; // Get the Document Settings Part DocumentSettingsPart documentSettingPart1 = mainPart.DocumentSettingsPart; // Create a new attachedTemplate and specify a relationship ID AttachedTemplate attachedTemplate1 = new AttachedTemplate() { Id = "relationId1" }; // Append the attached template to the DocumentSettingsPart documentSettingPart1.Settings.Append(attachedTemplate1); // Add an ExternalRelationShip of type AttachedTemplate. // Specify the path of template and the relationship ID documentSettingPart1.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate", new Uri(projPath + "MSWordTemplates\\template4.dotx", UriKind.Absolute), "relationId1"); string fullname = string.Format("{0} {1}", myResume.FirstName, myResume.LastName); SetCCText(mainPart, "FullName", fullname); SetCCText(mainPart, "Goal", myResume.Goal); SetCCText(mainPart, "Location", myResume.CurrentLocation); string email = myResume.Contacts.First(c => c.ContactTitle.Title.Equals("EMail")).Data; SetCCText(mainPart, "Email", email); string phone = myResume.Contacts.First(c => c.ContactTitle.Title.Equals("Phone")).Data; SetCCText(mainPart, "Phone", phone); RemoveCCChild(mainPart, "OtherContacts"); foreach (var contact in myResume.Contacts.Where(c => !c.ContactTitle.Title.Equals("EMail") && !c.ContactTitle.Title.Equals("Phone"))) { AppendCCText(mainPart, "OtherContacts", string.Format("{0}: {1}", contact.ContactTitle.Title, contact.Data)); } // ОБРАЗОВАНИЕ if (myResume.Education.Count > 0) { SdtBlock contentControl = mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_Education").Single(); Table theTable = contentControl.Descendants <Table>().Single(); TableRow defaultRow = theTable.Elements <TableRow>().Last(); foreach (var institution in myResume.Education) { TableRow rowCopy = (TableRow)defaultRow.CloneNode(true); // период учебы var periodRun = rowCopy.Descendants <TableCell>().ElementAt(0).GetFirstChild <Paragraph>().GetFirstChild <Run>(); periodRun.GetFirstChild <Text>().Text = string.Format("{0} –", institution.From.Format()); periodRun.Append(new Break()); periodRun.Append(new Text(institution.To.Format())); // описание уч. заведениия: // название и город TableCell secondColumn = rowCopy.Descendants <TableCell>().ElementAt(1); SetCCText(secondColumn, "InstitutionName", string.Format("{0}, г. {1}", institution.Name, institution.City)); // кафедра if (string.IsNullOrEmpty(institution.Department)) { secondColumn.Descendants <SdtRun>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "InstitutionDepartment").Single().Parent.Remove(); } else { SetCCText(secondColumn, "InstitutionDepartment", institution.Department); } // специальность SetCCText(secondColumn, "InstitutionSpeciality", institution.Specialty); secondColumn.Elements <Paragraph>().Last().Append(new Run(new Break())); theTable.AppendChild(rowCopy); } theTable.RemoveChild(defaultRow); } else { mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_Education").Single().Remove(); } // ОПЫТ РАБОТЫ if (myResume.WorkExp.Count > 0) { SdtBlock contentControl = mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_Experience").Single(); Table theTable = contentControl.Descendants <Table>().Single(); TableRow defaultRow = theTable.Elements <TableRow>().Last(); foreach (var workPlace in myResume.WorkExp) { TableRow rowCopy = (TableRow)defaultRow.CloneNode(true); // период в который работали var periodRun = rowCopy.Descendants <TableCell>().ElementAt(0).GetFirstChild <Paragraph>().GetFirstChild <Run>(); periodRun.GetFirstChild <Text>().Text = string.Format("{0} –", workPlace.From.Format()); periodRun.Append(new Break()); periodRun.Append(new Text(workPlace.To.Format())); // описание работы: // название работы и город TableCell secondColumn = rowCopy.Descendants <TableCell>().ElementAt(1); SetCCText(secondColumn, "WorkplaceName", string.Format("{0}, г. {1}", workPlace.Name, workPlace.City)); // должность SetCCText(secondColumn, "WorkplacePosition", workPlace.Position); // обязанности if (workPlace.Duties.Count > 0) { RemoveCCChild(secondColumn, "WorkplaceDuties"); foreach (var duty in workPlace.Duties) { AppendCCText(secondColumn, "WorkplaceDuties", string.Format("– {0}", duty.Name)); } } else { secondColumn.Descendants <SdtRun>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "WorkplaceDuties").Single().Parent.Remove(); } //secondColumn.Elements<Paragraph>().Last().Append(new Run(new Break())); theTable.AppendChild(rowCopy); } theTable.RemoveChild(defaultRow); } else { mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_Experience").Single().Remove(); } // СЕРТИФИКАТЫ if (myResume.CertificatesAndTrainings.Count > 0) { RemoveCCChild(mainPart, "Certificates"); foreach (var certificate in myResume.CertificatesAndTrainings) { AppendCCText(mainPart, "Certificates", string.Format("{0} – {1}{2}", certificate.Date.Year, certificate.Name, certificate.Location != null ? string.Format(", г. {0}", certificate.Location) : "")); } } else { RemoveCC(mainPart, "Section_Certificates"); } // ЯЗЫКИ if (myResume.Languages.Count > 0) { SdtBlock contentControl = mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Languages").Single(); SdtContentBlock contentRun = contentControl.GetFirstChild <SdtContentBlock>(); Paragraph defaultLi = contentRun.GetFirstChild <Paragraph>(); foreach (var language in myResume.Languages) { Paragraph copy = (Paragraph)defaultLi.CloneNode(true); copy.Descendants <Text>().Where(t => t.Text == "lang").Single().Text = language.Name; copy.Descendants <Text>().Where(t => t.Text == "level").Single().Text = language.Level; contentRun.Append(copy); } contentRun.RemoveChild(defaultLi); } else { RemoveCC(mainPart, "Section_Languages"); } // ЛИЧНЫЕ КАЧЕСТВА if (myResume.PersonalQualities.Count > 0) { SdtBlock contentControl = mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "PersonalQualities").Single(); SdtContentBlock contentRun = contentControl.GetFirstChild <SdtContentBlock>(); Paragraph defaultLi = contentRun.GetFirstChild <Paragraph>(); foreach (var quality in myResume.PersonalQualities) { Paragraph copy = (Paragraph)defaultLi.CloneNode(true); copy.Descendants <Text>().Where(t => t.Text == "quality").Single().Text = quality.Name; contentRun.Append(copy); } contentRun.RemoveChild(defaultLi); } else { mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_PersonalQualities").Single().Remove(); } // НАВЫКИ if (myResume.Skills.Count > 0) { SdtBlock contentControl = mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Skills").Single(); SdtContentBlock contentRun = contentControl.GetFirstChild <SdtContentBlock>(); Paragraph defaultLi = contentRun.GetFirstChild <Paragraph>(); foreach (var skill in myResume.Skills) { Paragraph copy = (Paragraph)defaultLi.CloneNode(true); copy.Descendants <Text>().Where(t => t.Text == "skill").Single().Text = skill.Name; contentRun.Append(copy); } contentRun.RemoveChild(defaultLi); } else { mainPart.Document.Body.Descendants <SdtBlock>().Where(r => r.SdtProperties.GetFirstChild <Tag>().Val == "Section_Skills").Single().Remove(); } mainPart.Document.Save(); } File.WriteAllBytes(outFilePath, templateStream.ToArray()); } }
/// <summary> /// Gets the parent container. /// </summary> /// <param name="parentContainer">The parent container.</param> /// <param name="placeHolder">The place holder.</param> /// <returns></returns> protected bool GetParentContainer(ref SdtElement parentContainer, string placeHolder) { bool isRefresh = false; MainDocumentPart mainDocumentPart = parentContainer.Ancestors<Document>().First().MainDocumentPart; KeyValuePair<string, string> nameToValue = this.customXmlPartHelper.GetNameToValueCollectionFromElementForType(mainDocumentPart, DocumentContainerPlaceHoldersNode, NodeType.Element).Where(f => f.Key.Equals(placeHolder)).FirstOrDefault(); isRefresh = !string.IsNullOrEmpty(nameToValue.Value); if (isRefresh) { SdtElement parentElementFromCustomXmlPart = new SdtBlock(nameToValue.Value); parentContainer.Parent.ReplaceChild(parentElementFromCustomXmlPart, parentContainer); parentContainer = parentElementFromCustomXmlPart; } else { Dictionary<string, string> nameToValueCollection = new Dictionary<string, string>(); nameToValueCollection.Add(placeHolder, parentContainer.OuterXml); this.customXmlPartHelper.SetElementFromNameToValueCollectionForType(mainDocumentPart, DocumentRootNode, DocumentContainerPlaceHoldersNode, nameToValueCollection, NodeType.Element); } return isRefresh; }
// Generates content of footerPart2. private void GenerateFooterPart2Content(FooterPart footerPart2) { Footer footer2 = new Footer() {MCAttributes = new MarkupCompatibilityAttributes() {Ignorable = "w14 wp14"}}; footer2.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); footer2.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); footer2.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); footer2.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); footer2.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); footer2.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); footer2.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); footer2.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); footer2.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); footer2.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); footer2.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); footer2.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); footer2.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); footer2.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); footer2.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); SdtId sdtId1 = new SdtId() {Val = -1382393284}; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() {Val = "Page Numbers (Bottom of Page)"}; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); SdtId sdtId2 = new SdtId() {Val = 98381352}; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() {Val = "Page Numbers (Top of Page)"}; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtContentDocPartObject2); SdtEndCharProperties sdtEndCharProperties2 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph28 = new Paragraph() {RsidParagraphAddition = "0005059E", RsidRunAdditionDefault = "0005059E"}; ParagraphProperties paragraphProperties9 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId3 = new ParagraphStyleId() {Val = "Footer"}; paragraphProperties9.Append(paragraphStyleId3); Run run44 = new Run(); Text text29 = new Text() {Space = SpaceProcessingModeValues.Preserve}; text29.Text = "Page "; run44.Append(text29); Run run45 = new Run(); RunProperties runProperties23 = new RunProperties(); Bold bold16 = new Bold(); BoldComplexScript boldComplexScript16 = new BoldComplexScript(); FontSize fontSize15 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript15 = new FontSizeComplexScript() {Val = "24"}; runProperties23.Append(bold16); runProperties23.Append(boldComplexScript16); runProperties23.Append(fontSize15); runProperties23.Append(fontSizeComplexScript15); FieldChar fieldChar7 = new FieldChar() {FieldCharType = FieldCharValues.Begin}; run45.Append(runProperties23); run45.Append(fieldChar7); Run run46 = new Run(); RunProperties runProperties24 = new RunProperties(); Bold bold17 = new Bold(); BoldComplexScript boldComplexScript17 = new BoldComplexScript(); runProperties24.Append(bold17); runProperties24.Append(boldComplexScript17); FieldCode fieldCode3 = new FieldCode() {Space = SpaceProcessingModeValues.Preserve}; fieldCode3.Text = " PAGE "; run46.Append(runProperties24); run46.Append(fieldCode3); Run run47 = new Run(); RunProperties runProperties25 = new RunProperties(); Bold bold18 = new Bold(); BoldComplexScript boldComplexScript18 = new BoldComplexScript(); FontSize fontSize16 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript16 = new FontSizeComplexScript() {Val = "24"}; runProperties25.Append(bold18); runProperties25.Append(boldComplexScript18); runProperties25.Append(fontSize16); runProperties25.Append(fontSizeComplexScript16); FieldChar fieldChar8 = new FieldChar() {FieldCharType = FieldCharValues.Separate}; run47.Append(runProperties25); run47.Append(fieldChar8); Run run48 = new Run() {RsidRunAddition = "00FB1F22"}; RunProperties runProperties26 = new RunProperties(); Bold bold19 = new Bold(); BoldComplexScript boldComplexScript19 = new BoldComplexScript(); NoProof noProof23 = new NoProof(); runProperties26.Append(bold19); runProperties26.Append(boldComplexScript19); runProperties26.Append(noProof23); Text text30 = new Text(); text30.Text = "2"; run48.Append(runProperties26); run48.Append(text30); Run run49 = new Run(); RunProperties runProperties27 = new RunProperties(); Bold bold20 = new Bold(); BoldComplexScript boldComplexScript20 = new BoldComplexScript(); FontSize fontSize17 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript17 = new FontSizeComplexScript() {Val = "24"}; runProperties27.Append(bold20); runProperties27.Append(boldComplexScript20); runProperties27.Append(fontSize17); runProperties27.Append(fontSizeComplexScript17); FieldChar fieldChar9 = new FieldChar() {FieldCharType = FieldCharValues.End}; run49.Append(runProperties27); run49.Append(fieldChar9); Run run50 = new Run(); Text text31 = new Text() {Space = SpaceProcessingModeValues.Preserve}; text31.Text = " of "; run50.Append(text31); Run run51 = new Run(); RunProperties runProperties28 = new RunProperties(); Bold bold21 = new Bold(); BoldComplexScript boldComplexScript21 = new BoldComplexScript(); FontSize fontSize18 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript18 = new FontSizeComplexScript() {Val = "24"}; runProperties28.Append(bold21); runProperties28.Append(boldComplexScript21); runProperties28.Append(fontSize18); runProperties28.Append(fontSizeComplexScript18); FieldChar fieldChar10 = new FieldChar() {FieldCharType = FieldCharValues.Begin}; run51.Append(runProperties28); run51.Append(fieldChar10); Run run52 = new Run(); RunProperties runProperties29 = new RunProperties(); Bold bold22 = new Bold(); BoldComplexScript boldComplexScript22 = new BoldComplexScript(); runProperties29.Append(bold22); runProperties29.Append(boldComplexScript22); FieldCode fieldCode4 = new FieldCode() {Space = SpaceProcessingModeValues.Preserve}; fieldCode4.Text = " NUMPAGES "; run52.Append(runProperties29); run52.Append(fieldCode4); Run run53 = new Run(); RunProperties runProperties30 = new RunProperties(); Bold bold23 = new Bold(); BoldComplexScript boldComplexScript23 = new BoldComplexScript(); FontSize fontSize19 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript19 = new FontSizeComplexScript() {Val = "24"}; runProperties30.Append(bold23); runProperties30.Append(boldComplexScript23); runProperties30.Append(fontSize19); runProperties30.Append(fontSizeComplexScript19); FieldChar fieldChar11 = new FieldChar() {FieldCharType = FieldCharValues.Separate}; run53.Append(runProperties30); run53.Append(fieldChar11); Run run54 = new Run() {RsidRunAddition = "00FB1F22"}; RunProperties runProperties31 = new RunProperties(); Bold bold24 = new Bold(); BoldComplexScript boldComplexScript24 = new BoldComplexScript(); NoProof noProof24 = new NoProof(); runProperties31.Append(bold24); runProperties31.Append(boldComplexScript24); runProperties31.Append(noProof24); Text text32 = new Text(); text32.Text = "37"; run54.Append(runProperties31); run54.Append(text32); Run run55 = new Run(); RunProperties runProperties32 = new RunProperties(); Bold bold25 = new Bold(); BoldComplexScript boldComplexScript25 = new BoldComplexScript(); FontSize fontSize20 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript20 = new FontSizeComplexScript() {Val = "24"}; runProperties32.Append(bold25); runProperties32.Append(boldComplexScript25); runProperties32.Append(fontSize20); runProperties32.Append(fontSizeComplexScript20); FieldChar fieldChar12 = new FieldChar() {FieldCharType = FieldCharValues.End}; run55.Append(runProperties32); run55.Append(fieldChar12); paragraph28.Append(paragraphProperties9); paragraph28.Append(run44); paragraph28.Append(run45); paragraph28.Append(run46); paragraph28.Append(run47); paragraph28.Append(run48); paragraph28.Append(run49); paragraph28.Append(run50); paragraph28.Append(run51); paragraph28.Append(run52); paragraph28.Append(run53); paragraph28.Append(run54); paragraph28.Append(run55); sdtContentBlock2.Append(paragraph28); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtEndCharProperties2); sdtBlock2.Append(sdtContentBlock2); sdtContentBlock1.Append(sdtBlock2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph29 = new Paragraph() {RsidParagraphAddition = "0005059E", RsidRunAdditionDefault = "0005059E"}; ParagraphProperties paragraphProperties10 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId4 = new ParagraphStyleId() {Val = "Footer"}; paragraphProperties10.Append(paragraphStyleId4); paragraph29.Append(paragraphProperties10); footer2.Append(sdtBlock1); footer2.Append(paragraph29); footerPart2.Footer = footer2; }