I am building a solution that allows users to pick and chose sections from a Word template, populate those sections with content from a database, and assemble the 1k new data into a new .docx document So far, I have successful methodologies for locating content and transplanting that content into a new document. I am using the OpenXML SDK 2.0 to locate content by Styles and Content Controls. I am able to create IEnumerable objects containing elements such as Paragraphs, SdtBlocks, Run, etc.
I need to find an elegant way 开发者_Go百科to serialize these element blocks so I can store them as whole blocks of type VARBINARY in a SQL 2005 database. Can someone please point me to a viable example for serializing these OpenXML parts/elements?
I am working on Excel at the moment but I think your problem is similar in nature.
From the code below I can extract the XML code of the row and then store it.
private string GetContents(uint rowIndex)
{
    return GetExistingRow(rowIndex).OuterXml;
}
private Row GetExistingRow(uint rowIndex)
{
    return SheetData.
            Elements<Row>().
            Where(r => r.RowIndex == rowIndex).
            FirstOrDefault();
}
please note the SheetData object is extracted as
this.SheetData = WorksheetPart.Worksheet.GetFirstChild<SheetData>()
I hope this helps.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论