<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://openxmldeveloper.org/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Open XML&amp;nbsp;SDK 2.0 - Recent Threads</title><link>http://openxmldeveloper.org/discussions/development_tools/f/35.aspx</link><description>To discuss issues and&amp;nbsp;questions related to Open XML SDK 2.0</description><dc:language>en-US</dc:language><generator>Telligent Community 5.6.582.12783 (Build: 5.6.582.12783)</generator><item><title>Lock Cell of Worksheet</title><link>http://openxmldeveloper.org/thread/160837.aspx</link><pubDate>Thu, 09 May 2013 06:49:38 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160837</guid><dc:creator>kaushal.jani@valuechain.co.in</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160837.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160837/rss.aspx</wfw:commentRss><description>&lt;p&gt;
&lt;div&gt;Hi,&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Below is the function which reading my XLLX and write the data in it. It also protect it with password.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Now here I want to lock perticular cell of this sheet. Please suggest me options for that.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;What I have tried:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;1. CellFormat.ApplyProtection&lt;/div&gt;
&lt;div&gt;2. Tried to remove &amp;quot;Locked&amp;quot; property of locked sheet.&lt;/div&gt;
&lt;div&gt;3. Tried through &amp;quot;Protection&amp;quot;.&lt;/div&gt;
&lt;div&gt;4. As per below code.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Code :&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;private void readXLSX(string Filepath)&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(Filepath, true))&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // rId must be unique within the spreadsheet.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // You might be able to use the SpreadSheetDocument.Parts.Count() to do this.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // i.e. string relationshipID = &amp;quot;rId&amp;quot; + (spreadsheetDocument.Parts.Count() + 1).ToString();&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //string rId = &amp;quot;rId6&amp;quot;;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string rId = &amp;quot;rId&amp;quot; + (spreadsheetDocument.Parts.Count() + 1).ToString();&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Sheet.Name and Sheet.SheetId must be unique within the spreadsheet.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sheet sheet = new Sheet() { Name = Guid.NewGuid().ToString(), SheetId = 4U, Id = rId };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; workbookPart.Workbook.Sheets.Append(sheet);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WorksheetPart worksheetPart = workbookPart.AddNewPart&amp;lt;WorksheetPart&amp;gt;(rId);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Worksheet worksheet = new Worksheet();&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.AddNamespaceDeclaration(&amp;quot;r&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot;);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // I don&amp;#39;t know what SheetDimension.Reference is used for, it doesn&amp;#39;t seem to change the resulting xml.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetDimension sheetDimension = new SheetDimension() { Reference = &amp;quot;A1:A3&amp;quot; };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetViews sheetViews = new SheetViews();&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // If more than one SheetView.TabSelected is set to true, it looks like Excel just picks the first one.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetView sheetView = new SheetView() { TabSelected = false, WorkbookViewId = 0U };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // I don&amp;#39;t know what Selection.ActiveCell is used for, it doesn&amp;#39;t seem to change the resulting xml.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Selection selection = new Selection() { ActiveCell = &amp;quot;A1&amp;quot;, SequenceOfReferences = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;A1&amp;quot; } };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sheetView.Append(selection);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sheetViews.Append(sheetView);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetFormatProperties sheetFormatProperties = new SheetFormatProperties() { DefaultRowHeight = 15D };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetData sheetData = new SheetData();&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // I don&amp;#39;t know what the InnerText of Row.Spans is used for. It doesn&amp;#39;t seem to change the resulting xml.&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Row row = new Row() { RowIndex = 1U, Spans = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;1:3&amp;quot; } };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ProtectedRange pRange = new ProtectedRange() { SequenceOfReferences = A1:C1, Name=&amp;quot;ProtRange&amp;quot; };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CellFormat cellFormat = new CellFormat();&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //setting protection to the cell&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cellFormat.Protection = new Protection() { Locked = false };&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cell cell1 = new Cell() { CellReference = &amp;quot;A1&amp;quot;, DataType = CellValues.String, CellValue = new CellValue(&amp;quot;99&amp;quot;) };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cell cell2 = new Cell() { CellReference = &amp;quot;B1&amp;quot;, DataType = CellValues.Number, CellValue = new CellValue(&amp;quot;55&amp;quot;) };&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cell cell3 = new Cell() { CellReference = &amp;quot;C1&amp;quot;, DataType = CellValues.Number, CellValue = new CellValue(&amp;quot;33&amp;quot;) };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; row.Append(cell1);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; row.Append(cell2);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; row.Append(cell3);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sheetData.Append(row);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Setting up a password protected sheet&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SheetProtection sheetProtection = new SheetProtection()&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SelectLockedCells = true,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SelectUnlockedCells = true,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sheet = true,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AutoFilter = false,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Objects = true,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Scenarios = true,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //AlgorithmName = &amp;quot;SHA-1&amp;quot;,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //HashValue = &amp;quot;YV+dAThAIz3o3XCXmftMUngaqd0=&amp;quot;,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //SaltValue = &amp;quot;salt1&amp;quot;,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //SpinCount = 3,&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Password = &amp;quot;111&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //SheetProtection sheetProtection1 = new SheetProtection() { Password = &amp;quot;111&amp;quot;, Sheet = true, Objects = true, Scenarios = true };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PageMargins pageMargins = new PageMargins() { Left = 0.7D, Right = 0.7D, Top = 0.7D, Bottom = 0.75D, Header = 0.3D, Footer = 0.3D };&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //worksheet.Append(pRange);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(cellFormat);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(sheetDimension);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(sheetViews);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(sheetFormatProperties);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(sheetData);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(sheetProtection);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet.Append(pageMargins);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Range(UseRange).Style.Protection.SetLocked(FALSE)&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheetPart.Worksheet = worksheet;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Kaushal Jani&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Issues with altChunk - document showing garbled characters - â€‹ Â   </title><link>http://openxmldeveloper.org/thread/160766.aspx</link><pubDate>Wed, 01 May 2013 14:32:12 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160766</guid><dc:creator>Maverickht</dc:creator><slash:comments>1</slash:comments><comments>http://openxmldeveloper.org/thread/160766.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160766/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;br /&gt;I&amp;#39;m using altChunk to merge Rich text format (as XHTML) into a word document, the program seems to work but shows garbled characters (&amp;acirc;&amp;euro;&amp;lsaquo; &amp;Acirc; ) not sure whats causing it, please help!&lt;br /&gt;The code is below:&lt;br /&gt;&lt;br /&gt;Code to open a word document and get a Plain Text Content Control called response1:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; using (WordprocessingDocument myDoc =&lt;br /&gt;WordprocessingDocument.Open(ms, true))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainDocumentPart mainPart = myDoc.MainDocumentPart;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;OpenXmlElement&amp;gt; sdtList = InfoPathToWord.GetContentControl(mainPart.Document, &amp;quot;response1&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddRichText(0, response1, ref mainPart, ref sdtList);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Method to add the RichText:&lt;br /&gt;===========================&lt;br /&gt;&lt;br /&gt;//Example of rtfVale = &amp;quot;&amp;lt;html xml:space=\&amp;quot;preserve\&amp;quot; xmlns=\&amp;quot;http://www.w3.org/1999/xhtml\&amp;quot;&amp;gt;\r\n&amp;nbsp; &amp;lt;ol&amp;gt;\r\n&amp;lt;li&amp;gt;​Test Data&amp;lt;/li&amp;gt;\r\n&amp;lt;li&amp;gt;Test data2&amp;lt;/li&amp;gt;\r\n&amp;lt;li style=\&amp;quot;text-decoration:line-through\&amp;quot;&amp;gt;&amp;lt;span&amp;gt;TEst again&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;\r\n&amp;lt;p style=\&amp;quot;text-decoration:underline\&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;strong&amp;gt;Test data&amp;lt;/strong&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;&lt;br /&gt;&lt;br /&gt;public static void AddRichText(int id, string rtfValue,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ref MainDocumentPart mainPart, ref List&amp;lt;OpenXmlElement&amp;gt; sdtList)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (sdtList.Count != 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string altChunkId = &amp;quot;AltChunkId&amp;quot; + id;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AlternativeFormatImportPart chunk =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mainPart.AddAlternativeFormatImportPart(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AlternativeFormatImportPartType.Xhtml, altChunkId);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (MemoryStream ms = new MemoryStream(System.Text.Encoding.Default.GetBytes(rtfValue)))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chunk.FeedData(ms);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ms.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AltChunk altChunk = new AltChunk();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; altChunk.Id = altChunkId;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (sdtList.Count != 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (OpenXmlElement sdt in sdtList)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenXmlElement parent = sdt.Parent;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parent.InsertAfter(element, sdt);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sdt.Remove();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the Word document it generates proof errors (shown after I reopen and save the document in Word) , like following:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:proofErr w:type=&amp;quot;spellStart&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:r&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:rPr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:rFonts w:eastAsia=&amp;quot;Times New Roman&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/w:rPr&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:t&amp;gt;&amp;acirc;&amp;euro;&amp;lsaquo;Test&amp;lt;/w:t&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/w:r&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;w:proofErr w:type=&amp;quot;spellEnd&amp;quot;/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve tried everything but to no avail, I would appreciate help ASAP as its affecting our project.&lt;br /&gt;&lt;br /&gt;Many thanks&lt;br /&gt;Mave&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Excel formula (Total and Subtotal)</title><link>http://openxmldeveloper.org/thread/160758.aspx</link><pubDate>Mon, 29 Apr 2013 21:08:34 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160758</guid><dc:creator>newbee</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160758.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160758/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I&amp;#39;m a new bee to open XML . One of my projects include creating&amp;nbsp; a spreadsheet from the database and apply formats, calculations etc to the spreadsheet. I successfully created one but applying formulas (subtotals and totals) is the part I need help with.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;How can I let Excel know (through sheet.xml) to calculate Subtotal and Grand Totals based on every change in a specific column?&lt;/p&gt;
&lt;p&gt;I tried manually creating a spreadsheet with Subtotal and totals,saved as zip file ,extracted and viewed the *.xml files but I couldn&amp;#39;t figure out how the cell ranges and formulas were applied.&lt;/p&gt;
&lt;p&gt;Can someone please help....like I said, I&amp;#39;m very new to this topic and need help.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Show file name/caption in embedded object(doc file) in word document using OpenXML</title><link>http://openxmldeveloper.org/thread/160678.aspx</link><pubDate>Tue, 09 Apr 2013 09:55:33 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160678</guid><dc:creator>josephrxavier</dc:creator><slash:comments>1</slash:comments><comments>http://openxmldeveloper.org/thread/160678.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160678/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="white-space:pre;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="white-space:pre;"&gt;	&lt;/span&gt;With the help of following link &amp;quot;&lt;/span&gt;&lt;span&gt;http://msdn.microsoft.com/en-ca/library/ee355229.aspx&lt;/span&gt;&lt;span&gt;&amp;quot; i am able to embed documents in word successfully. After inserting the document as object it shows the caption as &amp;quot;Embedded Document&amp;quot;. When i gone through the code, caption comes from the image part. By default &amp;nbsp;image stored as a Base 64 string. Then its written in&amp;nbsp;BinaryWriter writer.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="white-space:pre;"&gt;	&lt;/span&gt;After decoding (base64 to String) the Base64 String it shows the&amp;nbsp;&amp;quot;Embedded Document&amp;quot; in two places. I tried to to replace the string&amp;nbsp;&amp;quot;Embedded Document&amp;quot; with other values without success. After replacing with new values its not showing the image in embedded object.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;	&lt;/span&gt;In following ways i replaced the string &amp;quot;Embedded Document&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;	&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style="white-space:pre;"&gt;byte[] toEncodeAsBytes = Convert.FromBase64String(iconBytes); //&lt;/span&gt;&amp;nbsp;Convert&lt;span style="white-space:pre;"&gt; to byte from base64&lt;/span&gt;. iconBytes contains required base64string&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string returnValue = System.Text.UnicodeEncoding.Unicode.GetString(toEncodeAsBytes); // &lt;/span&gt;Convert&amp;nbsp;&lt;span style="white-space:pre;"&gt;to string from byte&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;returnValue = returnValue.Replace(&amp;quot;Embedded Document&amp;quot;, &amp;quot;Embedded Document1&amp;quot;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; toEncodeAsBytes = System.Text.UnicodeEncoding.Unicode.GetBytes(returnValue); // &lt;/span&gt;Convert&amp;nbsp;&lt;span style="white-space:pre;"&gt;to byte from string&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; iconBytes = System.Convert.ToBase64String(toEncodeAsBytes); // &lt;/span&gt;Convert&amp;nbsp;&lt;span style="white-space:pre;"&gt;to base64 from byte.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="white-space:pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="white-space:pre;"&gt;	&lt;/span&gt;Any ideas ?. Thanks in advance :)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>OpenXML Excel - updating cell and making it bold </title><link>http://openxmldeveloper.org/thread/160671.aspx</link><pubDate>Thu, 04 Apr 2013 22:11:42 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160671</guid><dc:creator>Nate Pate</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160671.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160671/rss.aspx</wfw:commentRss><description>&lt;p&gt;I have the following code which successfully opens up an excel file and inserts a cell value. I am having a hard time though tweakingthe code so that it can make that cell bold. Any help would be appreciated. &amp;nbsp;I have attempted to make the font bold as you can see below but have not been successful.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;
&lt;pre class="prettyprint"&gt;using System.Linq;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
 

namespace portfolio
{
    public class PortfolioReport
    {

        // Given a document name and text, 
        // inserts a new work sheet and writes the text to column and row specified.
        
        public static void InsertText(string docName, string text,string column, uint row)
        {
            // Open the document for editing.
            using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(docName, true))
            {
                // Get the SharedStringTablePart. If it does not exist, create a new one.
                SharedStringTablePart shareStringPart;
                if (spreadSheet.WorkbookPart.GetPartsOfType&amp;lt;SharedStringTablePart&amp;gt;().Count() &amp;gt; 0)
                {
                    shareStringPart = spreadSheet.WorkbookPart.GetPartsOfType&amp;lt;SharedStringTablePart&amp;gt;().First();
                }
                else
                {
                    shareStringPart = spreadSheet.WorkbookPart.AddNewPart&amp;lt;SharedStringTablePart&amp;gt;();
                }

                // Insert the text into the SharedStringTablePart.
                int index = InsertSharedStringItem(text, shareStringPart);

                // Insert a new worksheet.
              //  WorksheetPart worksheetPart = InsertWorksheet(spreadSheet.WorkbookPart);

                Workbook workBook = spreadSheet.WorkbookPart.Workbook;
                WorksheetPart worksheetPart = workBook.WorkbookPart.WorksheetParts.First();

                // Insert cell A1 into the new worksheet.
               // Cell cell = InsertCellInWorksheet(&amp;quot;F&amp;quot;, 1, worksheetPart);
                Cell cell = InsertCellInWorksheet(column, row, worksheetPart);
                

                // Set the value of cell A1.
                cell.CellValue = new CellValue(index.ToString());
                cell.DataType = new EnumValue&amp;lt;CellValues&amp;gt;(CellValues.SharedString);
                // Save the new worksheet.
                worksheetPart.Worksheet.Save();
            }
        }

        // Given text and a SharedStringTablePart, creates a SharedStringItem with the specified text 
        // and inserts it into the SharedStringTablePart. If the item already exists, returns its index.
        private static int InsertSharedStringItem(string text, SharedStringTablePart shareStringPart)
        {
            // If the part does not contain a SharedStringTable, create one.
            if (shareStringPart.SharedStringTable == null)
            {
                shareStringPart.SharedStringTable = new SharedStringTable();
            }

            int i = 0;

            // Iterate through all the items in the SharedStringTable. If the text already exists, return its index.
            foreach (SharedStringItem item in shareStringPart.SharedStringTable.Elements&amp;lt;SharedStringItem&amp;gt;())
            {
                if (item.InnerText == text)
                {
                    return i;
                }

                i++;
            }

            // The text does not exist in the part. Create the SharedStringItem and return its index.
            shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new DocumentFormat.OpenXml.Spreadsheet.Text(text)));
            shareStringPart.SharedStringTable.Save();

            return i;
        }


        // Given a column name, a row index, and a WorksheetPart, inserts a cell into the worksheet. 
        // If the cell already exists, returns it. 
        private static Cell InsertCellInWorksheet(string columnName, uint rowIndex, WorksheetPart worksheetPart)
        {
            Worksheet worksheet = worksheetPart.Worksheet;
            SheetData sheetData = worksheet.GetFirstChild&amp;lt;SheetData&amp;gt;();
            string cellReference = columnName + rowIndex;

            // If the worksheet does not contain a row with the specified row index, insert one.
            Row row;
            if (sheetData.Elements&amp;lt;Row&amp;gt;().Where(r =&amp;gt; r.RowIndex == rowIndex).Count() != 0)
            {
                row = sheetData.Elements&amp;lt;Row&amp;gt;().Where(r =&amp;gt; r.RowIndex == rowIndex).First();
            }
            else
            {
                row = new Row() { RowIndex = rowIndex };
                sheetData.Append(row);
            }

            // If there is not a cell with the specified column name, insert one.  
            if (row.Elements&amp;lt;Cell&amp;gt;().Where(c =&amp;gt; c.CellReference.Value == columnName + rowIndex).Count() &amp;gt; 0)
            {
                return row.Elements&amp;lt;Cell&amp;gt;().Where(c =&amp;gt; c.CellReference.Value == cellReference).First();
            }
            else
            {
                // Cells must be in sequential order according to CellReference. Determine where to insert the new cell.
                Cell refCell = null;
                foreach (Cell cell in row.Elements&amp;lt;Cell&amp;gt;())
                {
                    if (string.Compare(cell.CellReference.Value, cellReference, true) &amp;gt; 0)
                    {
                        refCell = cell;
                        break;
                    }
                }

                Borders borders1 = new Borders() { Count = (UInt32Value)1U };

                Border border1 = new Border();
                LeftBorder leftBorder1 = new LeftBorder();
                RightBorder rightBorder1 = new RightBorder();
                TopBorder topBorder1 = new TopBorder();
                BottomBorder bottomBorder1 = new BottomBorder();

                border1.Append(leftBorder1);
                border1.Append(rightBorder1);
                border1.Append(topBorder1);
                border1.Append(bottomBorder1);

                borders1.Append(border1);

                Fonts fonts1 = new Fonts() {Count = (UInt32Value) 1U, KnownFonts = true};
                Font font1 = new Font();
                FontSize fontSize1 = new FontSize() { Val = 11D };
                Color color1 = new Color() { Theme = (UInt32Value)1U };
                FontName fontName1 = new FontName() { Val = &amp;quot;Calibri&amp;quot; };
                FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 };
                FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor };

                font1.Append(fontSize1);
                font1.Append(color1);
                font1.Append(fontName1);
                font1.Append(fontFamilyNumbering1);
                font1.Append(fontScheme1);

                fonts1.Append(font1);
 


                Cell newCell = new Cell() { CellReference = cellReference, StyleIndex = (UInt32Value) 1U }; 
                 
                row.InsertBefore(newCell, refCell);
                sheetData.Append(borders1);
                sheetData.Append(fonts1);
              
                worksheet.Save();
                return newCell;
            }
        }

    }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>How to identify if a WordprocessingDocument element is a Paragraph or a Table using open xml sdk 2.0?</title><link>http://openxmldeveloper.org/thread/160614.aspx</link><pubDate>Thu, 21 Mar 2013 09:32:38 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160614</guid><dc:creator>saravanan</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160614.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160614/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I want to check if the first element of the word document is Table or Paragraph.And Based on this i have to do some action.Is there any functions available for check this?...&lt;/p&gt;
&lt;p&gt;
&lt;pre class="prettyprint"&gt;bool isStartingWithTable=false;

using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(docFile, true))

{

DocumentFormat.OpenXml.Wordprocessing.Table table = (DocumentFormat.OpenXml.Wordprocessing.Table)wordDoc.MainDocumentPart.Document.Body.ElementAt(0);

isStartingWithTable=true;

}&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>How to convert html string into OOXML(Word 2007)formatted string using openxmlsdk2.0?</title><link>http://openxmldeveloper.org/thread/160608.aspx</link><pubDate>Wed, 20 Mar 2013 11:28:47 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160608</guid><dc:creator>saravanan</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160608.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160608/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have a string in HTML format(It may contains HTML tables).Now i want to convert this html string into OOXML represenation of WORD 2007 based string and store it into my DB table. In future,Once i have collected all the html strings then i have to build the word document from the OOXML string that are stored in the DB.&lt;/p&gt;
&lt;p&gt;So, now my problem is i have to convert my html string into equivalent OOXML formatted string for WORD 2007.&lt;/p&gt;
&lt;p&gt;Could you please help me to get out of this issue...&lt;/p&gt;
&lt;p&gt;I already tried with&amp;nbsp;&lt;strong&gt;AlternativeFormatImportPart &lt;/strong&gt;class.But it is directly build the Word document for the given html string.I dont want to do it. I just want to convert from HTML to OOXML format of WORD2007.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Adding Bookmark inside a bookmark not added properly</title><link>http://openxmldeveloper.org/thread/160604.aspx</link><pubDate>Tue, 19 Mar 2013 11:15:43 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160604</guid><dc:creator>sonu gupta</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160604.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160604/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am working on Open xml Project for wordprocessing, my requirement is to add book mark inside a book mark, after adding the book mark when i open the document, and go to bookmark&amp;nbsp; using Document UI, it select different paragraphs.&lt;/p&gt;
&lt;p&gt;Can you please tell me how to add Hierarchical bookmarks.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Newbie trying to set text for a collection of cells in excel</title><link>http://openxmldeveloper.org/thread/160587.aspx</link><pubDate>Fri, 15 Mar 2013 15:09:46 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160587</guid><dc:creator>ericstein86</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160587.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160587/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I have just started woking with openXML for excel&amp;nbsp;and want to set the text of all the cells&amp;nbsp;in a range without having to loop through each row.&lt;/p&gt;
&lt;p&gt;I was able to set data validations by specifying a range. Is there any way to do this and just set text for the cells?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>how to findout layout of each slide using OpenXml?</title><link>http://openxmldeveloper.org/thread/160536.aspx</link><pubDate>Mon, 04 Mar 2013 09:42:34 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160536</guid><dc:creator>Alpa</dc:creator><slash:comments>1</slash:comments><comments>http://openxmldeveloper.org/thread/160536.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160536/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hello All,&lt;/p&gt;
&lt;p&gt;I am having .pptx file in which each slide having different layout. i 
want to find out layout of each slides using C# coding, using OpenXml?
Does anyone have any idea?
&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;
&lt;p&gt;Alpa&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>How to read ActiveX control value in Excel and PPt using OpenXML</title><link>http://openxmldeveloper.org/thread/160522.aspx</link><pubDate>Fri, 01 Mar 2013 09:17:51 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160522</guid><dc:creator>sonu gupta</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160522.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160522/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am working with OpenXml sdk 2.0 for replacing ActiveX Control in 
Excel and PPT, i didn&amp;#39;t find any way for reading ActiveX control value.&lt;/p&gt;
&lt;p&gt;Please let me know if we have solution regarding this.&lt;/p&gt;
&lt;p&gt;Thanks for your response in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Formating spreadsheets with Open Xml</title><link>http://openxmldeveloper.org/thread/160514.aspx</link><pubDate>Tue, 26 Feb 2013 22:56:37 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160514</guid><dc:creator>risho</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160514.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160514/rss.aspx</wfw:commentRss><description>&lt;pre class="prettyprint"&gt;&lt;p&gt;I thought this would be easy. I&amp;#39;m creating an Excel workbook with two spreadsheets but what I get is  unformated output. I wanted to at least set certain&lt;/p&gt;&lt;p&gt;cell widths, make the top row stand out, and create alternate row background color settnings. I thought that by formating the output manually, then save &lt;/p&gt;&lt;p&gt;the file and open it with Open XML SDK Productivity tool I would be able to copy the code from the method that I thought was responsible for styling, &lt;/p&gt;&lt;p&gt;namely, GenerateWorkbookStylesPart1Content. While there is no error, there is also no styling.&lt;/p&gt;&lt;p&gt;I wanted to see if someone has experience with this and is willing to share how this is done. I&amp;#39;ve tried to paste the entire code but it is very long all won&amp;#39;t fit. &lt;/p&gt;&lt;p&gt;Here is a code that I was able modify to make things happen - I don&amp;#39;t fully understand how it&amp;#39;s all done. I just went through a tutorial at &lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/office/hh180830(v=office.14).aspx"&gt;http://msdn.microsoft.com/en-us/library/office/hh180830(v=office.14).aspx&lt;/a&gt; and in itself it starting to make sense but my understanding of the tutorial and &lt;/p&gt;&lt;p&gt;what I need to get done are two different things. And thanks in advance! R.&lt;/p&gt;&lt;/pre&gt;
&lt;pre class="prettyprint"&gt;namespace GridToExcel.Helper
{
    public class ExcelHelper
    {
        public class ColumnCaption
        {
            private static string[] Alphabets = { &amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;, &amp;quot;E&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;G&amp;quot;, &amp;quot;H&amp;quot;, &amp;quot;I&amp;quot;, &amp;quot;J&amp;quot;, &amp;quot;K&amp;quot;, &amp;quot;L&amp;quot;, &amp;quot;M&amp;quot;, &amp;quot;N&amp;quot;, &amp;quot;O&amp;quot;, &amp;quot;P&amp;quot;, &amp;quot;Q&amp;quot;, &amp;quot;R&amp;quot;, &amp;quot;S&amp;quot;, &amp;quot;T&amp;quot;, &amp;quot;U&amp;quot;, &amp;quot;V&amp;quot;, &amp;quot;W&amp;quot;, &amp;quot;X&amp;quot;, &amp;quot;Y&amp;quot;, &amp;quot;Z&amp;quot; };
            private static ColumnCaption instance = null;
            private List&amp;lt;string&amp;gt; cellHeaders = null;
            public static ColumnCaption Instance
            {
                get
                {
                    if (instance == null)
                        return new ColumnCaption();
                    else return ColumnCaption.Instance;
                }
            }

            public ColumnCaption()
            {
                this.InitCollection();
            }

            private void InitCollection()
            {
                cellHeaders = new List&amp;lt;string&amp;gt;();

                foreach (string sItem in Alphabets)
                    cellHeaders.Add(sItem);

                foreach (string item in Alphabets)
                    foreach (string sItem in Alphabets)
                        cellHeaders.Add(item + sItem);
            }

            public string Get(int rowIndex, int columnIndex)
            {
                return this.cellHeaders.ElementAt(columnIndex) + (rowIndex + 1).ToString();
            }
        }

        public static string ExportToExcel(DataTable table, DataTable table2, string fileName1,int interval, string source)
        {
            string excelfile = fileName1;
            using (SpreadsheetDocument excelDoc = SpreadsheetDocument.Create(excelfile, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook))
            {
                CreateExcelParts(excelDoc, table, table2, interval, source);
            }
            return excelfile;
        }

        private static void CreateExcelParts(SpreadsheetDocument spreadsheetDoc, DataTable data, DataTable data2 ,int interval,string source)
        {
            bool _multisheet = false;
            if (data2 != null)
                _multisheet = true;

            WorkbookPart workbookPart = spreadsheetDoc.AddWorkbookPart();
            CreateWorkbookPart(workbookPart, _multisheet);

            int workBookPartCount = 1;

            WorkbookStylesPart workbookStylesPart = workbookPart.AddNewPart&amp;lt;WorkbookStylesPart&amp;gt;(&amp;quot;rId&amp;quot; + (workBookPartCount++).ToString());
            CreateWorkbookStylesPart(workbookStylesPart);

            WorksheetPart worksheetPart = workbookPart.AddNewPart&amp;lt;WorksheetPart&amp;gt;(&amp;quot;rId&amp;quot; + (101).ToString());
            CreateWorksheetPart(workbookPart.WorksheetParts.ElementAt(0), data, interval, source);

            if (data2 != null)
            {
                WorksheetPart worksheetPart1 = workbookPart.AddNewPart&amp;lt;WorksheetPart&amp;gt;(&amp;quot;rId&amp;quot; + (102).ToString());
                CreateWorksheetPart2(workbookPart.WorksheetParts.ElementAt(1), data2, interval, source);
            }

            SharedStringTablePart sharedStringTablePart = workbookPart.AddNewPart&amp;lt;SharedStringTablePart&amp;gt;(&amp;quot;rId&amp;quot; + (workBookPartCount++).ToString());
            CreateSharedStringTablePart(sharedStringTablePart, data);
            CreateSharedStringTablePart2(sharedStringTablePart, data2);

            workbookPart.Workbook.Save();
        }

       private static void CreateSharedStringTablePart(SharedStringTablePart sharedStringTablePart, DataTable sheetData)
        {
            UInt32Value stringCount = Convert.ToUInt32(sheetData.Rows.Count) + Convert.ToUInt32(sheetData.Columns.Count);

            SharedStringTable sharedStringTable = new SharedStringTable()
            {
                Count = stringCount,
                UniqueCount = stringCount
            };

            for (int columnIndex = 0; columnIndex &amp;lt; sheetData.Columns.Count; columnIndex++)
            {
                SharedStringItem sharedStringItem = new SharedStringItem();
                Text text = new Text();
                text.Text = sheetData.Columns[columnIndex].ColumnName;
                sharedStringItem.Append(text);
                sharedStringTable.Append(sharedStringItem);
            }

            for (int rowIndex = 0; rowIndex &amp;lt; sheetData.Rows.Count; rowIndex++)
            {
                SharedStringItem sharedStringItem = new SharedStringItem();
                Text text = new Text();
                text.Text = sheetData.Rows[rowIndex][0].ToString();
                sharedStringItem.Append(text);
                sharedStringTable.Append(sharedStringItem);
            }

            sharedStringTablePart.SharedStringTable = sharedStringTable;
        }

        private static void CreateSharedStringTablePart2(SharedStringTablePart sharedStringTablePart, DataTable sheetData)
        {
            UInt32Value stringCount = Convert.ToUInt32(sheetData.Rows.Count) + Convert.ToUInt32(sheetData.Columns.Count);

            SharedStringTable sharedStringTable = new SharedStringTable()
            {
                Count = stringCount,
                UniqueCount = stringCount
            };

            for (int columnIndex = 0; columnIndex &amp;lt; sheetData.Columns.Count; columnIndex++)
            {
                SharedStringItem sharedStringItem = new SharedStringItem();
                Text text = new Text();
                text.Text = sheetData.Columns[columnIndex].ColumnName;
                sharedStringItem.Append(text);
                sharedStringTable.Append(sharedStringItem);
            }

            for (int rowIndex = 0; rowIndex &amp;lt; sheetData.Rows.Count; rowIndex++)
            {
                SharedStringItem sharedStringItem = new SharedStringItem();
                Text text = new Text();
                text.Text = sheetData.Rows[rowIndex][0].ToString();
                sharedStringItem.Append(text);
                sharedStringTable.Append(sharedStringItem);
            }

            sharedStringTablePart.SharedStringTable = sharedStringTable;
        }

        private static void CreateWorksheetPart(WorksheetPart worksheetPart, DataTable data, int interval, string source)
        {
            Worksheet worksheet = new Worksheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = &amp;quot;x14ac&amp;quot; } };
            worksheet.AddNamespaceDeclaration(&amp;quot;r&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot;);
            worksheet.AddNamespaceDeclaration(&amp;quot;mc&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;);
            worksheet.AddNamespaceDeclaration(&amp;quot;x14ac&amp;quot;, &amp;quot;http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac&amp;quot;);


            SheetViews sheetViews = new SheetViews();
            SheetView sheetView = new SheetView() { WorkbookViewId = (UInt32Value)0U };
            Selection selection = new Selection() { ActiveCell = &amp;quot;A1&amp;quot; };
            sheetView.Append(selection);
            sheetViews.Append(sheetView);

            PageMargins pageMargins = new PageMargins()
            {
                Left = 0.7D,
                Right = 0.7D,
                Top = 0.75D,
                Bottom = 0.75D,
                Header = 0.3D,
                Footer = 0.3D
            };

            SheetFormatProperties sheetFormatPr = new SheetFormatProperties()
            {
                DefaultRowHeight = 15D,
                DyDescent = 0.25D
            };

            SheetData sheetData = new SheetData();

            UInt32Value rowIndex = 1U;

            Row row1 = new Row()
            {
                RowIndex = rowIndex++,
                Spans = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;1:3&amp;quot; },
                DyDescent = 0.25D
            };

            // Creates the first row hearder of the spreadsheet
            for (int columnIndex = 0; columnIndex &amp;lt; data.Columns.Count; columnIndex++)
            {
                Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), columnIndex), DataType = CellValues.String };
                CellValue cellValue = new CellValue();

                // Format cells with Dates heading
                if (source == &amp;quot;&amp;quot;)
                {
                    if (columnIndex &amp;gt; 1)
                    {
                        string[] _dateParse;
                        string _year = string.Empty;
                        string _month = string.Empty;

                        if (interval == 3) // Interval: Total
                        {

                        }
                        else if (interval == 2)  // Interval: Year
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString();
                            cellValue.Text = _year;
                        }
                        else // IntgervalL Month
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString().Remove(0, 2);
                            _month = getMonthAccronyms(_dateParse[1].ToString());
                            cellValue.Text = _month + &amp;quot;-&amp;quot; + _year;
                        }

                        _dateParse = null;
                    }
                    else
                        cellValue.Text = data.Columns[columnIndex].ColumnName.ToString();
                }
                else
                {
                    if (columnIndex &amp;gt; 0)
                    {
                        string[] _dateParse;
                        string _year = string.Empty;
                        string _month = string.Empty;

                        if (interval == 3) // Interval: Total
                        {

                        }
                        else if (interval == 2)  // Interval: Year
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString();
                            cellValue.Text = _year;
                        }
                        else // IntgervalL Month
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString().Remove(0, 2);
                            _month = getMonthAccronyms(_dateParse[1].ToString());
                            cellValue.Text = _month + &amp;quot;-&amp;quot; + _year;
                        }

                        _dateParse = null;
                    }
                    else
                        cellValue.Text = data.Columns[columnIndex].ColumnName.ToString();
                }

                cell.Append(cellValue);

                row1.Append(cell);
            }
            sheetData.Append(row1);

            Row extraRow = new Row();

            for (int rIndex = 0; rIndex &amp;lt; data.Rows.Count; rIndex++)
            {
                Row row = new Row()
                {
                    RowIndex = rowIndex++,
                    Spans = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;1:3&amp;quot; },
                    DyDescent = 0.25D
                };

                for (int cIndex = 0; cIndex &amp;lt; data.Columns.Count; cIndex++)
                {
                    if (source == &amp;quot;&amp;quot;)
                    {
                        if (cIndex &amp;gt; 1)
                        {
                            Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.Number };
                            CellValue cellValue = new CellValue();
                            cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                            cell.Append(cellValue);

                            row.Append(cell);
                        }
                        else
                        {
                            Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.String };
                            CellValue cellValue = new CellValue();
                            cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                            cell.Append(cellValue);

                            row.Append(cell);
                        }
                    }
                    else
                    {
                        if (cIndex &amp;gt; 0)
                        {
                            Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.Number };
                            CellValue cellValue = new CellValue();
                            cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                            cell.Append(cellValue);

                            row.Append(cell);
                        }
                        else
                        {
                            Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.String };
                            CellValue cellValue = new CellValue();
                            cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                            cell.Append(cellValue);

                            row.Append(cell);
                        }
                    }
                }
                sheetData.Append(row);

                Cell extraCell = new Cell();
                CellValue extraCellValue = new CellValue();
                extraCellValue.Text = &amp;quot;**********&amp;quot;;
                extraCell.Append(extraCellValue);
                sheetData.Append(extraRow);
            }


            worksheet.Append(sheetViews);
            worksheet.Append(sheetFormatPr);
            worksheet.Append(sheetData);
            worksheet.Append(pageMargins);
            worksheetPart.Worksheet = worksheet;
        }

        private static void CreateWorksheetPart2(WorksheetPart worksheetPart, DataTable data, int interval, string source)
        {
            Worksheet worksheet = new Worksheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = &amp;quot;x14ac&amp;quot; } };
            worksheet.AddNamespaceDeclaration(&amp;quot;r&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot;);
            worksheet.AddNamespaceDeclaration(&amp;quot;mc&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;);
            worksheet.AddNamespaceDeclaration(&amp;quot;x14ac&amp;quot;, &amp;quot;http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac&amp;quot;);


            SheetViews sheetViews = new SheetViews();
            SheetView sheetView = new SheetView() { WorkbookViewId = (UInt32Value)0U };
            Selection selection = new Selection() { ActiveCell = &amp;quot;A1&amp;quot; };
            sheetView.Append(selection);
            sheetViews.Append(sheetView);

            PageMargins pageMargins = new PageMargins()
            {
                Left = 0.7D,
                Right = 0.7D,
                Top = 0.75D,
                Bottom = 0.75D,
                Header = 0.3D,
                Footer = 0.3D
            };

            SheetFormatProperties sheetFormatPr = new SheetFormatProperties()
            {
                DefaultRowHeight = 15D,
                DyDescent = 0.25D
            };

            SheetData sheetData = new SheetData();

            UInt32Value rowIndex = 1U;

            Row row1 = new Row()
            {
                RowIndex = rowIndex++,
                Spans = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;1:3&amp;quot; },
                DyDescent = 0.25D
            };

            for (int columnIndex = 0; columnIndex &amp;lt; data.Columns.Count; columnIndex++)
            {
                Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), columnIndex), DataType = CellValues.String };
                CellValue cellValue = new CellValue();

                if (source == &amp;quot;&amp;quot;)
                {

                    // Format cells with Dates heading
                    if (columnIndex &amp;gt; 1)
                    {
                        string[] _dateParse;
                        string _year = string.Empty;
                        string _month = string.Empty;

                        if (interval == 3) // Interval: Total
                        {

                        }
                        else if (interval == 2)  // Interval: Year
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString();
                            cellValue.Text = _year;
                        }
                        else // IntgervalL Month
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString().Remove(0, 2);
                            _month = getMonthAccronyms(_dateParse[1].ToString());
                            cellValue.Text = _month + &amp;quot;-&amp;quot; + _year;
                        }

                        _dateParse = null;
                    }
                    else
                        cellValue.Text = data.Columns[columnIndex].ColumnName.ToString();
                }
                else
                {// Format cells with Dates heading
                    if (columnIndex &amp;gt; 0)
                    {
                        string[] _dateParse;
                        string _year = string.Empty;
                        string _month = string.Empty;

                        if (interval == 3) // Interval: Total
                        {

                        }
                        else if (interval == 2)  // Interval: Year
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString();
                            cellValue.Text = _year;
                        }
                        else // IntgervalL Month
                        {
                            _dateParse = data.Columns[columnIndex].ColumnName.ToString().Split(&amp;#39;-&amp;#39;);
                            _year = _dateParse[0].ToString().Remove(0, 2);
                            _month = getMonthAccronyms(_dateParse[1].ToString());
                            cellValue.Text = _month + &amp;quot;-&amp;quot; + _year;
                        }

                        _dateParse = null;
                    }
                    else
                        cellValue.Text = data.Columns[columnIndex].ColumnName.ToString();
                }

                cell.Append(cellValue);

                row1.Append(cell);
            }
            sheetData.Append(row1);

            for (int rIndex = 0; rIndex &amp;lt; data.Rows.Count; rIndex++)
            {
                Row row = new Row()
                {
                    RowIndex = rowIndex++,
                    Spans = new ListValue&amp;lt;StringValue&amp;gt;() { InnerText = &amp;quot;1:3&amp;quot; },
                    DyDescent = 0.25D
                };

                for (int cIndex = 0; cIndex &amp;lt; data.Columns.Count; cIndex++)
                {
                    if (cIndex &amp;gt; 1)
                    {
                        Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.Number };
                        CellValue cellValue = new CellValue();
                        cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                        cell.Append(cellValue);

                        row.Append(cell);
                    }
                    else
                    {
                        Cell cell = new Cell() { CellReference = ExcelHelper.ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.String };
                        CellValue cellValue = new CellValue();
                        cellValue.Text = data.Rows[rIndex][cIndex].ToString();
                        cell.Append(cellValue);

                        row.Append(cell);
                    }
                }
                sheetData.Append(row);
            }

            worksheet.Append(sheetViews);
            worksheet.Append(sheetFormatPr);
            worksheet.Append(sheetData);
            worksheet.Append(pageMargins);
            worksheetPart.Worksheet = worksheet;
        }

       
        private static void CreateWorkbookStylesPart(WorkbookStylesPart workbookStylesPart)
        {
            Stylesheet stylesheet = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = &amp;quot;x14ac&amp;quot; } };
            stylesheet.AddNamespaceDeclaration(&amp;quot;mc&amp;quot;, &amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;);
            stylesheet.AddNamespaceDeclaration(&amp;quot;x14ac&amp;quot;, &amp;quot;http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac&amp;quot;);

            Fonts fonts1 = new Fonts() { Count = (UInt32Value)2U, KnownFonts = true };

            Font font1 = new Font();
            FontSize fontSize1 = new FontSize() { Val = 11D };
            Color color1 = new Color() { Theme = (UInt32Value)1U };
            FontName fontName1 = new FontName() { Val = &amp;quot;Calibri&amp;quot; };
            FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 };
            FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor };

            font1.Append(fontSize1);
            font1.Append(color1);
            font1.Append(fontName1);
            font1.Append(fontFamilyNumbering1);
            font1.Append(fontScheme2);

            Font font2 = new Font();
            Bold bold1 = new Bold();
            FontSize fontSize2 = new FontSize() { Val = 12D };
            Color color2 = new Color() { Theme = (UInt32Value)1U };
            FontName fontName2 = new FontName() { Val = &amp;quot;Calibri&amp;quot; };
            FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 };
            FontScheme fontScheme3 = new FontScheme() { Val = FontSchemeValues.Minor };

            font2.Append(bold1);
            font2.Append(fontSize2);
            font2.Append(color2);
            font2.Append(fontName2);
            font2.Append(fontFamilyNumbering2);
            font2.Append(fontScheme3);

            fonts1.Append(font1);
            fonts1.Append(font2);

            Fills fills1 = new Fills() { Count = (UInt32Value)4U };

            Fill fill1 = new Fill();
            PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None };

            fill1.Append(patternFill1);

            Fill fill2 = new Fill();
            PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 };

            fill2.Append(patternFill2);

            Fill fill3 = new Fill();

            PatternFill patternFill3 = new PatternFill() { PatternType = PatternValues.Solid };
            ForegroundColor foregroundColor1 = new ForegroundColor() { Theme = (UInt32Value)3U, Tint = 0.79998168889431442D };
            BackgroundColor backgroundColor1 = new BackgroundColor() { Indexed = (UInt32Value)64U };

            patternFill3.Append(foregroundColor1);
            patternFill3.Append(backgroundColor1);

            fill3.Append(patternFill3);

            Fill fill4 = new Fill();

            PatternFill patternFill4 = new PatternFill() { PatternType = PatternValues.Solid };
            ForegroundColor foregroundColor2 = new ForegroundColor() { Theme = (UInt32Value)0U, Tint = -0.249977111117893D };
            BackgroundColor backgroundColor2 = new BackgroundColor() { Indexed = (UInt32Value)64U };

            patternFill4.Append(foregroundColor2);
            patternFill4.Append(backgroundColor2);

            fill4.Append(patternFill4);

            fills1.Append(fill1);
            fills1.Append(fill2);
            fills1.Append(fill3);
            fills1.Append(fill4);

            Borders borders1 = new Borders() { Count = (UInt32Value)2U };

            Border border1 = new Border();
            LeftBorder leftBorder1 = new LeftBorder();
            RightBorder rightBorder1 = new RightBorder();
            TopBorder topBorder1 = new TopBorder();
            BottomBorder bottomBorder1 = new BottomBorder();
            DiagonalBorder diagonalBorder1 = new DiagonalBorder();

            border1.Append(leftBorder1);
            border1.Append(rightBorder1);
            border1.Append(topBorder1);
            border1.Append(bottomBorder1);
            border1.Append(diagonalBorder1);

            Border border2 = new Border();

            LeftBorder leftBorder2 = new LeftBorder() { Style = BorderStyleValues.Thin };
            Color color3 = new Color() { Theme = (UInt32Value)0U, Tint = -0.14996795556505021D };

            leftBorder2.Append(color3);

            RightBorder rightBorder2 = new RightBorder() { Style = BorderStyleValues.Thin };
            Color color4 = new Color() { Theme = (UInt32Value)0U, Tint = -0.14996795556505021D };

            rightBorder2.Append(color4);

            TopBorder topBorder2 = new TopBorder() { Style = BorderStyleValues.Thin };
            Color color5 = new Color() { Theme = (UInt32Value)0U, Tint = -0.14996795556505021D };

            topBorder2.Append(color5);

            BottomBorder bottomBorder2 = new BottomBorder() { Style = BorderStyleValues.Thin };
            Color color6 = new Color() { Theme = (UInt32Value)0U, Tint = -0.14996795556505021D };

            bottomBorder2.Append(color6);
            DiagonalBorder diagonalBorder2 = new DiagonalBorder();

            border2.Append(leftBorder2);
            border2.Append(rightBorder2);
            border2.Append(topBorder2);
            border2.Append(bottomBorder2);
            border2.Append(diagonalBorder2);

            borders1.Append(border1);
            borders1.Append(border2);

            CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)1U };
            CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U };

            cellStyleFormats1.Append(cellFormat1);

            CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)3U };
            CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U };
            CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyBorder = true };
            CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true };

            cellFormats1.Append(cellFormat2);
            cellFormats1.Append(cellFormat3);
            cellFormats1.Append(cellFormat4);

            CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U };
            CellStyle cellStyle1 = new CellStyle() { Name = &amp;quot;Normal&amp;quot;, FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U };

            cellStyles1.Append(cellStyle1);
            DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U };
            TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = &amp;quot;TableStyleMedium2&amp;quot;, DefaultPivotStyle = &amp;quot;PivotStyleLight16&amp;quot; };

            StylesheetExtensionList stylesheetExtensionList = new StylesheetExtensionList();
            StylesheetExtension stylesheetExtension = new StylesheetExtension() { Uri = &amp;quot;{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}&amp;quot; };
            stylesheetExtension.AddNamespaceDeclaration(&amp;quot;x14&amp;quot;, &amp;quot;http://schemas.microsoft.com/office/spreadsheetml/2009/9/main&amp;quot;);
            DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles slicerStyles = new DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles() { DefaultSlicerStyle = &amp;quot;SlicerStyleLight1&amp;quot; };
            stylesheetExtension.Append(slicerStyles);
            stylesheetExtensionList.Append(stylesheetExtension);

            //stylesheet.Append(stylesheetExtensionList);

            stylesheet.Append(fonts1);
            stylesheet.Append(fills1);
            stylesheet.Append(borders1);
            stylesheet.Append(cellStyleFormats1);
            stylesheet.Append(cellFormats1);
            stylesheet.Append(cellStyles1);
            stylesheet.Append(differentialFormats1);
            stylesheet.Append(tableStyles1);
            stylesheet.Append(stylesheetExtensionList);

            workbookStylesPart.Stylesheet = stylesheet;
        }

        /// &amp;lt;summary&amp;gt;
        /// Creates the workbook part.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name=&amp;quot;workbookPart&amp;quot;&amp;gt;The workbook part.&amp;lt;/param&amp;gt;
        private static void CreateWorkbookPart(WorkbookPart workbookPart, bool _multisheet)
        {
            Workbook workbook = new Workbook();
            Sheets sheets = new Sheets();

            if (_multisheet)
            {
                Sheet sheet1 = new Sheet()
                    {
                        Name = &amp;quot;Wuc Count JDD Output&amp;quot;,
                        SheetId = Convert.ToUInt32(101),
                        Id = &amp;quot;rId&amp;quot; + (101).ToString()
                    };
                sheets.Append(sheet1);
                
                Sheet sheet2 = new Sheet()
                {
                    Name = &amp;quot;WUC Count ESR Output&amp;quot;,
                    SheetId = Convert.ToUInt32(102),
                    Id = &amp;quot;rId&amp;quot; + (102).ToString()
                };
                sheets.Append(sheet2);
            }
            else
            {
                Sheet sheet1 = new Sheet()
                {
                    Name = &amp;quot;System R&amp;amp;M Risk Report Output&amp;quot;,
                    SheetId = Convert.ToUInt32(101),
                    Id = &amp;quot;rId&amp;quot; + (101).ToString()
                };
                sheets.Append(sheet1);
            }
            
            CalculationProperties calculationProperties = new CalculationProperties()
            {
                CalculationId = (UInt32Value)123456U  // some default Int32Value
            };

            workbook.Append(sheets);
            workbook.Append(calculationProperties);

            workbookPart.Workbook = workbook;
        }
    }
}&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Read and edit Word Files client-side only with JavaScript</title><link>http://openxmldeveloper.org/thread/160500.aspx</link><pubDate>Mon, 25 Feb 2013 13:23:20 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160500</guid><dc:creator>radu tut</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160500.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160500/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I would like to achieve the following functionality.&lt;/p&gt;
&lt;p&gt;Read a .docx file contents using JavaScript, process it with Open XML on the client ( replace some text) and then upload it to a new location, or trigger a download for the user.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Would this be possible?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>C# [Asp.NET MVC] Add Image to Header</title><link>http://openxmldeveloper.org/thread/160483.aspx</link><pubDate>Thu, 21 Feb 2013 11:31:31 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160483</guid><dc:creator>JacoPD</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160483.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160483/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi!&lt;br /&gt;I have a problem I cannot solve: I looked everywhere, in every dedicated thread in this forum and on the whole web, and I didn&amp;#39;t find out a way to manage my issue.&lt;br /&gt;So, I want to add an image to my header. I have to use my header, I can&amp;#39;t replace it with a new one cause in the preformatted one I have some text to dinamically manage in my code.&lt;br /&gt;So far, this is how I edit my header:&lt;/p&gt;
&lt;pre class="prettyprint"&gt;foreach (HeaderPart header in wordDoc.MainDocumentPart.HeaderParts)
                {
                    using (StreamReader sh = new StreamReader(header.GetStream()))
                    {
                        head = sh.ReadToEnd(); //head is a string
                    }
                    Regex npiano = new Regex(&amp;quot;{PLANNAME}&amp;quot;);
                    if (!String.IsNullOrWhiteSpace(piano.Avviso) || !String.IsNullOrWhiteSpace(piano.Fondo))
                        head = npiano.Replace(head, &amp;quot; n. &amp;quot; + piano.Avviso + &amp;quot; di &amp;quot; + piano.Fondo);
                    else
                        head = npiano.Replace(head, &amp;quot;&amp;quot;);
&lt;br /&gt;                   /* ... ... ... */
&lt;br /&gt;                    using (StreamWriter swh = new StreamWriter(header.GetStream(FileMode.Create)))
                    {
                        swh.Write(head);
                        swh.Flush();
                        swh.Close();
                    }
                }&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;and, for text-only parts it works.&lt;br /&gt;Now I&amp;#39;d need a method to add an image in that same &lt;em&gt;header&lt;/em&gt;, beneath every string I wrote.&lt;br /&gt;How can I do that?&lt;br /&gt;Hoping for your helps,&lt;br /&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Getting System.Runtime.InteropServices.COMException while accessing content control range wordopenxml</title><link>http://openxmldeveloper.org/thread/160465.aspx</link><pubDate>Tue, 19 Feb 2013 07:09:50 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160465</guid><dc:creator>sonu gupta</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160465.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160465/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am working on VSTO project, the requirement is something like to get wordopenxml on content control exit event, when i am accessing wordopenxml i am getting following error -&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;System.Runtime.InteropServices.COMException was unhandled by user code&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp; HelpLink=wdmain11.chm#25410&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp; Message=The object is not valid.&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp; Source=Microsoft Word&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp; ErrorCode=-2146822358&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp; StackTrace:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at Microsoft.Office.Interop.Word.Range.get_WordOpenXML()&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;if i quick watch the contentcontrol.range.wordopenxml, i didn&amp;#39;t get any exception, please guide me how can i handle this error.&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Adding image parts to a word document</title><link>http://openxmldeveloper.org/thread/160453.aspx</link><pubDate>Mon, 18 Feb 2013 08:19:29 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160453</guid><dc:creator>lohiarahul</dc:creator><slash:comments>0</slash:comments><comments>http://openxmldeveloper.org/thread/160453.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160453/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have attached a code snippet in which I copy data and images from a flat open xml source to a content control in the destination document. The images appear as a base64 string in the source which I convert to a stream and add it to the destination as an image part. &lt;/p&gt;
&lt;p&gt;However when I do this the file size increases exponentially even with very little data. If you open the document, edit it and save it the file size drops back to normal with the same content&lt;/p&gt;
&lt;p&gt; I previously used the AltChunk approach to copy data but it had the exactly same issues too.That is why I switched to manually copying data, but now I am back to square 1.&lt;/p&gt;
&lt;p&gt;I have multiple rich text content controls on the destination document and this problem is a show stopper. Even with 10-12 small images the file size may reach 20-30 MB. I am in a fix. Please help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Convert or remove AltChunk</title><link>http://openxmldeveloper.org/thread/160423.aspx</link><pubDate>Wed, 13 Feb 2013 11:20:50 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160423</guid><dc:creator>lohiarahul</dc:creator><slash:comments>4</slash:comments><comments>http://openxmldeveloper.org/thread/160423.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160423/rss.aspx</wfw:commentRss><description>&lt;p&gt;I have implemented a mechanism in which I copy complete documents to a content control using an &lt;code&gt;AltChunk&lt;/code&gt;. This implementation allows a user to change data frequently. When these changes are triggered I create yet another &lt;code&gt;AltChunk&lt;/code&gt;
 to replace the previous contents. However the older chunk still 
contributes to the file size and it increases until the file is manually
 opened and saved in &lt;code&gt;WinWord.Exe&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Scenario : I tried to insert 10 images using &lt;code&gt;AltChunk&lt;/code&gt; 
which increased the file size from 18K to 2187K. Next I tried to replace
 the 10 images with a plain small string. The document is updated with 
the new content but the size remained 2187K. And then when I opened the 
file manually in &lt;code&gt;WinWord.Exe&lt;/code&gt; and saved it, the size dropped back to 19K. On research I found that Word application converts the &lt;code&gt;AltChunk&lt;/code&gt; to Paragraphs and Runs.&lt;/p&gt;
&lt;p&gt;My question : Can I mimic this Word Application behavior in &lt;code&gt;Open Xml&lt;/code&gt;? &lt;/p&gt;
&lt;p&gt;If I could remove the previous AltChunk and replace it with the new one would also the trick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Word 2010 richtext content control selects all content at once</title><link>http://openxmldeveloper.org/thread/160410.aspx</link><pubDate>Tue, 12 Feb 2013 14:03:48 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160410</guid><dc:creator>sonu gupta</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160410.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160410/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have VSTO application in which when i going to click inside content control it select the whole text, there is no way to modify partial text.&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>AltChunk corrupts rich text content control</title><link>http://openxmldeveloper.org/thread/160409.aspx</link><pubDate>Tue, 12 Feb 2013 11:20:03 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160409</guid><dc:creator>lohiarahul</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160409.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160409/rss.aspx</wfw:commentRss><description>&lt;p&gt;I used altchunk object to copy data from a docx file to a rich text content control in another file. The copy works fine. But now the content control cannot be cast into a SdtElement in open xml nor to a ContentControl in VSTO.&lt;br /&gt;&lt;br /&gt;This is the code I used&lt;br /&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;SdtElement sdtElement = destinationdocument.MainDocumentPart.Document.Body.Descendants&amp;lt;SdtElement&amp;gt;().Where(b =&amp;gt; b.SdtProperties.GetFirstChild&amp;lt;Tag&amp;gt;() != null).FirstOrDefault();
string altChunkId = &amp;quot;AltChunkId&amp;quot; + Guid.NewGuid().ToString();
AlternativeFormatImportPart chunk = destinationdocument.MainDocumentPart.AddAlternativeFormatImportPart(AlternativeFormatImport    PartType.WordprocessingML, altChunkId);
chunk.FeedData(File.Open(&amp;quot;sourceFile&amp;quot;, FileMode.OpenOrCreate));
AltChunk altChunk = new AltChunk();
altChunk.Id = altChunkId;
sdtElement.RemoveAllChildren();
sdtElement.Append(altChunk);&lt;/pre&gt;
&lt;br /&gt;the first time the code works fine. But at the second run the first line throws an unable to cast exception. The same problem occurs while using VSTO at the client side the ContentControl object cannot hold the content control in which the altchunk was inserted. Somehow this procedure corrupts the rich text content control.&lt;br /&gt;&lt;br /&gt;Is there anything I am doing wrong? Or is there a better alternative?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Content control Range WordOpenXml get modified</title><link>http://openxmldeveloper.org/thread/160404.aspx</link><pubDate>Mon, 11 Feb 2013 10:07:15 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160404</guid><dc:creator>sonu gupta</dc:creator><slash:comments>2</slash:comments><comments>http://openxmldeveloper.org/thread/160404.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160404/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am getting the WordOpeXml from content control range object using VSTO Project. I am getting different WordOpenXMl on content control enter and exit event with any change in content control.&lt;/p&gt;
&lt;p&gt;on enter event i am getting wordopenxml like-&lt;/p&gt;
&lt;p&gt;&amp;lt;pkg:part pkg:name=&amp;quot;/word/document.xml&amp;quot; pkg:contentType=&amp;quot;application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml&amp;quot;&amp;gt;&lt;br /&gt;- &amp;lt;pkg:xmlData&amp;gt;&lt;br /&gt;- &amp;lt;w:document mc:Ignorable=&amp;quot;w14 wp14&amp;quot; xmlns:wpc=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas&amp;quot; xmlns:mc=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot; xmlns:o=&amp;quot;urn:schemas-microsoft-com:office:office&amp;quot; xmlns:r=&amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot; xmlns:m=&amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/math&amp;quot; xmlns:v=&amp;quot;urn:schemas-microsoft-com:vml&amp;quot; xmlns:wp14=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing&amp;quot; xmlns:wp=&amp;quot;http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing&amp;quot; xmlns:w10=&amp;quot;urn:schemas-microsoft-com:office:word&amp;quot; xmlns:w=&amp;quot;http://schemas.openxmlformats.org/wordprocessingml/2006/main&amp;quot; xmlns:w14=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordml&amp;quot; xmlns:wpg=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingGroup&amp;quot; xmlns:wpi=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingInk&amp;quot; xmlns:wne=&amp;quot;http://schemas.microsoft.com/office/word/2006/wordml&amp;quot; xmlns:wps=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingShape&amp;quot;&amp;gt;&lt;br /&gt;- &amp;lt;w:body&amp;gt;&lt;br /&gt;- &amp;lt;&lt;span style="background-color:#ffff00;"&gt;&lt;strong&gt;w:p w:rsidR=&amp;quot;00000000&amp;quot; w:rsidRDefault=&amp;quot;00747F03&amp;quot; w:rsidP=&amp;quot;00747F03&amp;quot;&amp;gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;On Exit &lt;/span&gt;&lt;/span&gt;event i am getting wordopenxml like-&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;- &amp;lt;pkg:part pkg:name=&amp;quot;/word/document.xml&amp;quot; pkg:contentType=&amp;quot;application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml&amp;quot;&amp;gt;&lt;br /&gt;- &amp;lt;pkg:xmlData&amp;gt;&lt;br /&gt;- &amp;lt;w:document mc:Ignorable=&amp;quot;w14 wp14&amp;quot; xmlns:wpc=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas&amp;quot; xmlns:mc=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot; xmlns:o=&amp;quot;urn:schemas-microsoft-com:office:office&amp;quot; xmlns:r=&amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot; xmlns:m=&amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/math&amp;quot; xmlns:v=&amp;quot;urn:schemas-microsoft-com:vml&amp;quot; xmlns:wp14=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing&amp;quot; xmlns:wp=&amp;quot;http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing&amp;quot; xmlns:w10=&amp;quot;urn:schemas-microsoft-com:office:word&amp;quot; xmlns:w=&amp;quot;http://schemas.openxmlformats.org/wordprocessingml/2006/main&amp;quot; xmlns:w14=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordml&amp;quot; xmlns:wpg=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingGroup&amp;quot; xmlns:wpi=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingInk&amp;quot; xmlns:wne=&amp;quot;http://schemas.microsoft.com/office/word/2006/wordml&amp;quot; xmlns:wps=&amp;quot;http://schemas.microsoft.com/office/word/2010/wordprocessingShape&amp;quot;&amp;gt;&lt;br /&gt;- &amp;lt;w:body&amp;gt;&lt;br /&gt;-&lt;span style="background-color:#ffff00;"&gt;&lt;strong&gt; &amp;lt;w:p w:rsidR=&amp;quot;00000000&amp;quot; w:rsidRDefault=&amp;quot;00144C37&amp;quot; w:rsidP=&amp;quot;00144C37&amp;quot;&amp;gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;please let me know how i can compare the rich text of a content control using VSTO&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffff00;"&gt;&lt;span style="background-color:#ffffff;"&gt;thanks in advance&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>How to copy the contents of a rich text content control to a content control in a  different word document</title><link>http://openxmldeveloper.org/thread/160377.aspx</link><pubDate>Thu, 07 Feb 2013 13:56:46 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160377</guid><dc:creator>lohiarahul</dc:creator><slash:comments>8</slash:comments><comments>http://openxmldeveloper.org/thread/160377.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160377/rss.aspx</wfw:commentRss><description>&lt;p&gt;I currently have this need to copy the contents of a rich text content control alongwith images and formatting and assign it to a similar content control in a different document.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have this contentControl.Range.WordOpenXml property in C#.NET which returns me a open xml with all the images inline in a byte stream.&lt;/p&gt;
&lt;p&gt;The XML begins something like this&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;yes&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;?mso-application progid=&amp;quot;Word.Document&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;pkg:package xmlns:pkg=&amp;quot;http://schemas.microsoft.com/office/2006/xmlPackage&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;pkg:part pkg:name=&amp;quot;/_rels/.rels&amp;quot; pkg:contentType=&amp;quot;application/vnd.openxmlformats-package.relationships+xml&amp;quot; pkg:padding=&amp;quot;512&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I want to add this content to the content control to the other file and I havent been able to find a single sample or an example to tell me how to do that. Is this even possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>How can i add summary slide into powerpoint with openxml, C# </title><link>http://openxmldeveloper.org/thread/160357.aspx</link><pubDate>Wed, 06 Feb 2013 09:53:08 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160357</guid><dc:creator>cYounes</dc:creator><slash:comments>12</slash:comments><comments>http://openxmldeveloper.org/thread/160357.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160357/rss.aspx</wfw:commentRss><description>&lt;p&gt;&lt;span style="font-size:small;font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Hi ,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I&amp;#39;ve a Powerpoint file generated with Openxml , i want to know if i can add a new slide in specified position (usually &lt;span style="background-color:#ffff00;"&gt;second&lt;/span&gt; slide) that contains a &lt;span style="background-color:#ffff00;"&gt;summary &lt;/span&gt;for all the titled slides in my presentation?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;If you have any code suggests please help me!&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Thanks&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Word found unreadable content in "XXX". Do you want to recover the contents of this document?</title><link>http://openxmldeveloper.org/thread/160336.aspx</link><pubDate>Mon, 04 Feb 2013 04:10:48 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160336</guid><dc:creator>jerltlim</dc:creator><slash:comments>10</slash:comments><comments>http://openxmldeveloper.org/thread/160336.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160336/rss.aspx</wfw:commentRss><description>&lt;p&gt;I have one issues when open word document &lt;br /&gt;it will prompt some error message, but when you save it again &lt;br /&gt;it will be fine. I had search the internet and find this cause by&lt;br /&gt;when using openxml altchunk function some content type didn&amp;#39;t &lt;br /&gt;append into [Content_Types].xml. This can be verify by change the &lt;br /&gt;extension from .docx to .zip, any zip archiver will be able to &lt;br /&gt;open it. In the archive you will find a couple of xml files, &lt;br /&gt;if you compare the [Content_Types].xml between export word &lt;br /&gt;document and after save again export word document there are &lt;br /&gt;some missing [Content_Types].xml. anyone can help on this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Server Side Docx Generation</title><link>http://openxmldeveloper.org/thread/160267.aspx</link><pubDate>Tue, 29 Jan 2013 10:50:14 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160267</guid><dc:creator>yvkevitch</dc:creator><slash:comments>1</slash:comments><comments>http://openxmldeveloper.org/thread/160267.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160267/rss.aspx</wfw:commentRss><description>&lt;p&gt;Hello everybody,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m currently working on a project. One part of this project is a word document generation web service.&lt;/p&gt;
&lt;p&gt;The process of generating a document should work like this.&lt;/p&gt;
&lt;p&gt;- Copy the template as the new document.&lt;/p&gt;
&lt;p&gt;- For each content control of the template&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; - Get the tag of the content control.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; - The tag indicate me the data to retrieve.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; - Get the data in database&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; - Fill the content control with the data.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve made some test and i&amp;#39;m able to put simple text in plain text content control when they are in a SdtRun element. But sometimes they are in a SdtBlock element.&lt;/p&gt;
&lt;p&gt;Another problem is that sometimes, data is not a simple text as a name, it&amp;#39;s a list of data.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going crazy with this f.....g document generation.&lt;/p&gt;
&lt;p&gt;Am i on the good option to do this with OpenXml? Some advices would be very appreciated.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Create Excel file using OpenXML</title><link>http://openxmldeveloper.org/thread/160228.aspx</link><pubDate>Thu, 24 Jan 2013 16:21:16 GMT</pubDate><guid isPermaLink="false">1ff61f26-0981-41c7-ad52-ff725e9b1da8:160228</guid><dc:creator>cms9651</dc:creator><slash:comments>1</slash:comments><comments>http://openxmldeveloper.org/thread/160228.aspx</comments><wfw:commentRss>http://openxmldeveloper.org/discussions/development_tools/f/35/t/160228/rss.aspx</wfw:commentRss><description>&lt;p&gt;hi there, hope in your help.&lt;/p&gt;
&lt;p&gt;i need&amp;nbsp;Create Excel file in ASP.NET C# using OpenXML and this is my example link:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-excel-file-in-asp-net-c-sharp/" title="http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-excel-file-in-asp-net-c-sharp/"&gt;http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-excel-file-in-asp-net-c-sharp/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;i tried this code but i have error:&lt;/p&gt;
&lt;pre class="prettyprint"&gt;&lt;span class="pln"&gt;CS0246&lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;The&lt;/span&gt;&lt;span class="pln"&gt; type &lt;/span&gt;&lt;span class="kwd"&gt;or&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;namespace&lt;/span&gt;&lt;span class="pln"&gt; name &lt;/span&gt;&lt;span class="str"&gt;&amp;#39;OpenXmlDataDataContext&amp;#39;&lt;/span&gt;&lt;span class="pln"&gt; could &lt;/span&gt;&lt;span class="kwd"&gt;not&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;be found &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;are you missing a &lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; directive &lt;/span&gt;&lt;span class="kwd"&gt;or&lt;/span&gt;&lt;span class="pln"&gt; an assembly reference&lt;/span&gt;&lt;span class="pun"&gt;?)&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="prettyprint"&gt;&lt;span class="pun"&gt;&lt;p&gt;Can you help me?&lt;br /&gt;Any other suggestion for my problem?&lt;/p&gt;&lt;p&gt;&lt;strong&gt;.aspx&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre class="prettyprint"&gt;&lt;span class="pun"&gt;&amp;lt;%&lt;/span&gt;&lt;span class="pln"&gt;@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeFile=&amp;quot;OpenXml.aspx.cs&amp;quot; Inherits=&amp;quot;OpenXml&amp;quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="dec"&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;html&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;xmlns&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt;&lt;span class="tag"&gt;&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;head&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;Head1&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;runat&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="tag"&gt;&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;form&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;form1&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;runat&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="tag"&gt;&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;asp:Button&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;ID&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;btn_Excel&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;runat&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;Text&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;Excel&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="atn"&gt;onclick&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt;btn_Excel_Click&lt;/span&gt;&lt;span class="atv"&gt;&amp;quot;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="tag"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="prettyprint"&gt;&lt;strong&gt;&lt;span class="tag"&gt;.cs&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;pre class="prettyprint"&gt;&lt;strong&gt;&lt;span class="tag"&gt;&lt;pre class="prettyprint"&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Collections&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Generic&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Data&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;IO&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Linq&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Reflection&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Web&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Web&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;UI&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Web&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;UI&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;WebControls&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;OfficeOpenXml&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="kwd"&gt;public&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;partial&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;class&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;OpenXml&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;:&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;System&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Web&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;UI&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Page&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Dt&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;object&lt;/span&gt;&lt;span class="pun"&gt;[]&lt;/span&gt;&lt;span class="pln"&gt; query&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;protected&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Page_Load&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;object&lt;/span&gt;&lt;span class="pln"&gt; sender&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;EventArgs&lt;/span&gt;&lt;span class="pln"&gt; e&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;if&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(!&lt;/span&gt;&lt;span class="typ"&gt;IsPostBack&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;private&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;GetRecoredForExcelfile&lt;/span&gt;&lt;span class="pun"&gt;()&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;OpenXmlDataDataContext&lt;/span&gt;&lt;span class="pln"&gt; db &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;OpenXmlDataDataContext&lt;/span&gt;&lt;span class="pun"&gt;())&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;var&lt;/span&gt;&lt;span class="pln"&gt; info &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;from&lt;/span&gt;&lt;span class="pln"&gt; p &lt;/span&gt;&lt;span class="kwd"&gt;in&lt;/span&gt;&lt;span class="pln"&gt; db&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;userinfos&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="kwd"&gt;select&lt;/span&gt;&lt;span class="pln"&gt; p&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;if&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;info &lt;/span&gt;&lt;span class="pun"&gt;!=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;null&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; query &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; info&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;ToArray&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;Dt&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;ConvertToDatatable&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;query&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;public&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;static&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;ConvertToDatatable&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;Object&lt;/span&gt;&lt;span class="pun"&gt;[]&lt;/span&gt;&lt;span class="pln"&gt; array&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;PropertyInfo&lt;/span&gt;&lt;span class="pun"&gt;[]&lt;/span&gt;&lt;span class="pln"&gt; properties &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; array&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;GetType&lt;/span&gt;&lt;span class="pun"&gt;().&lt;/span&gt;&lt;span class="typ"&gt;GetElementType&lt;/span&gt;&lt;span class="pun"&gt;().&lt;/span&gt;&lt;span class="typ"&gt;GetProperties&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; dt &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;CreateDataTable&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;properties&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;if&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;array&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Length&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;!=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;foreach&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;object&lt;/span&gt;&lt;span class="pln"&gt; o &lt;/span&gt;&lt;span class="kwd"&gt;in&lt;/span&gt;&lt;span class="pln"&gt; array&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;FillData&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;properties&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; dt&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; o&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;return&lt;/span&gt;&lt;span class="pln"&gt; dt&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="com"&gt;#region Private Methods&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;private&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;static&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;CreateDataTable&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;PropertyInfo&lt;/span&gt;&lt;span class="pun"&gt;[]&lt;/span&gt;&lt;span class="pln"&gt; properties&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; dt &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;DataColumn&lt;/span&gt;&lt;span class="pln"&gt; dc &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;null&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;foreach&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;PropertyInfo&lt;/span&gt;&lt;span class="pln"&gt; pi &lt;/span&gt;&lt;span class="kwd"&gt;in&lt;/span&gt;&lt;span class="pln"&gt; properties&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dc &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataColumn&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dc&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;ColumnName&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; pi&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Name&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Columns&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Add&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;dc&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;return&lt;/span&gt;&lt;span class="pln"&gt; dt&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;private&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;static&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;FillData&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;PropertyInfo&lt;/span&gt;&lt;span class="pun"&gt;[]&lt;/span&gt;&lt;span class="pln"&gt; properties&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;DataTable&lt;/span&gt;&lt;span class="pln"&gt; dt&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Object&lt;/span&gt;&lt;span class="pln"&gt; o&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;DataRow&lt;/span&gt;&lt;span class="pln"&gt; dr &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;NewRow&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;foreach&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;PropertyInfo&lt;/span&gt;&lt;span class="pln"&gt; pi &lt;/span&gt;&lt;span class="kwd"&gt;in&lt;/span&gt;&lt;span class="pln"&gt; properties&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dr&lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="pln"&gt;pi&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Name&lt;/span&gt;&lt;span class="pun"&gt;]&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; pi&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;GetValue&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;o&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;null&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Rows&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Add&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;dr&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="com"&gt;#endregion&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;protected&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; btn_Excel_Click&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;object&lt;/span&gt;&lt;span class="pln"&gt; sender&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;EventArgs&lt;/span&gt;&lt;span class="pln"&gt; e&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;GetRecoredForExcelfile&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;string&lt;/span&gt;&lt;span class="pln"&gt; newFilePath &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Server&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;MapPath&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;ExcelFile/ErrorList.xlsx&amp;quot;&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;string&lt;/span&gt;&lt;span class="pln"&gt; templateFilePath &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Server&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;MapPath&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;ExcelFile/ErrorListtemplate.xlsx&amp;quot;&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;FileInfo&lt;/span&gt;&lt;span class="pln"&gt; newFile &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;FileInfo&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;newFilePath&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;FileInfo&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;template&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;FileInfo&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;templateFilePath&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;using&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;ExcelPackage&lt;/span&gt;&lt;span class="pln"&gt; xlPackage &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;new&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;ExcelPackage&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;newFile&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;template&lt;/span&gt;&lt;span class="pun"&gt;))&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;foreach&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="typ"&gt;ExcelWorksheet&lt;/span&gt;&lt;span class="pln"&gt; aworksheet &lt;/span&gt;&lt;span class="kwd"&gt;in&lt;/span&gt;&lt;span class="pln"&gt; xlPackage&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Workbook&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Worksheets&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aworksheet&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Cell&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;).&lt;/span&gt;&lt;span class="typ"&gt;Value&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; aworksheet&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Cell&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;).&lt;/span&gt;&lt;span class="typ"&gt;Value&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;ExcelWorksheet&lt;/span&gt;&lt;span class="pln"&gt; worksheet &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; xlPackage&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Workbook&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Worksheets&lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;Sheet1&amp;quot;&lt;/span&gt;&lt;span class="pun"&gt;];&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;int&lt;/span&gt;&lt;span class="pln"&gt; startrow &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;5&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;int&lt;/span&gt;&lt;span class="pln"&gt; row &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;int&lt;/span&gt;&lt;span class="pln"&gt; col &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;for&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;int&lt;/span&gt;&lt;span class="pln"&gt; j &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt; j &lt;/span&gt;&lt;span class="pun"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Columns&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Count&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt; j&lt;/span&gt;&lt;span class="pun"&gt;++)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col&lt;/span&gt;&lt;span class="pun"&gt;++;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;for&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;int&lt;/span&gt;&lt;span class="pln"&gt; i &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt; i &lt;/span&gt;&lt;span class="pun"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Rows&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Count&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt; i&lt;/span&gt;&lt;span class="pun"&gt;++)&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; row &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; startrow &lt;/span&gt;&lt;span class="pun"&gt;+&lt;/span&gt;&lt;span class="pln"&gt; i&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="typ"&gt;ExcelCell&lt;/span&gt;&lt;span class="pln"&gt; cell &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; worksheet&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Cell&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;row&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; col&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cell&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Value&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Dt&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Rows&lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="pln"&gt;i&lt;/span&gt;&lt;span class="pun"&gt;][&lt;/span&gt;&lt;span class="pln"&gt;j&lt;/span&gt;&lt;span class="pun"&gt;].&lt;/span&gt;&lt;span class="typ"&gt;ToString&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xlPackage&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="typ"&gt;Save&lt;/span&gt;&lt;span class="pun"&gt;();&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>