FAQ Database Discussion Community


How to generate Table Of Contents using OpenXML SDK 2.5?

c#,ms-word,openxml-sdk
I've read and understand this and this Stackoverflow question but there all about OpenXML SDK 2.0. In OpenXML SDK 2.0 there is no real way to update the Table of Content (ToC). There are a few workarounds like marking the document dirty which will ask the user to update the...

How to create Excel file using OpenXML without creating a local file?

c#,excel,openxml,openxml-sdk
Is it possible to create and edit an excel document using OpenXML SDK without creating a local file? As per the documentation the "Create" method demands for a filepath, which creates a local copy of the file. SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook); I'm referring the MSDN article here: https://msdn.microsoft.com/en-us/library/office/ff478153.aspx My...

Setting DefinedNames in OpenXML to set Print Titles for all worksheets in Excel

c#,excel,openxml,openxml-sdk
My end aim is to programatically set Excel's "Print Titles" value of Page Setup for all worksheets in my document. Initially I tried looking at using the SpreadsheetPrintingParts object (based on this question) - however, that requires generating a base 64 string, which seemingly has to come from an exisiting...

How to insert line break into Word (docx) document using OpenXMLPowerTools?

c#,.net,openxml,docx,openxml-sdk
I'm writing a library which generates Word documents based on a template. Some text needs to be replaced with another text. Everything seems to be working, there is a TextReplacer class which may perform replacements. The things become worse when I need to replace a single-line part of text with...

C# OpenXML memory leak

c#,memory-leaks,openxml-sdk
I had noticed memory leak in my application and tried to find it out. I don't know good and free memory leaking discovering techniques (any suggestions?) so I made it simple - inserted memory usage prints (with and without GC) and then dig deeper where biggest leak was. Fixable I...

Excel Open xml sdk - Copy formula between cells with range modification

c#,excel,openxml,openxml-sdk
I have a cell with formula (CellFormula). I don't know the formula content (Might be Sum, ifs or any other calculation). The formula might include range. When you drag the cell to other cells (manually at excel application itself) the formula range get updated. I want the formula programatic copy...

How to set Excel “Print Titles” with OpenXML

c#,excel,openxml,openxml-sdk
How can I set the "Print Titles" property of a spreadsheet with OpenXML, to have a row show at the top of every printed page? ...

Which references am I missing?

c#,visual-studio-2013,openxml-sdk
I am missing one reference for .Cells and the picture shows all the references that I have tried. Which one am i still missing? ...

Why cannot read excel file version older than 2013 with XML SDK 2.0 C#

c#,openxml-sdk
So I wrote some code basically trying to read excel file using XML SDK. And here is the code I wrote with C# on Visual Studio 2010. I put my code at the bottom but basically the problem I am having is it will read any excel file that is...

How to use xmlDocument to check if certain attributes of the document exist

c#,xml,openxml,openxml-sdk,wordprocessingml
So I am trying to check whether a document has certain attributes. For example, I have a sample master thesis and one of the things I have to check is whether or not the title is centered on the title page. So far, I have created an xmlDocument object of...

Find a Word check box control by its Tag property using Open XML SDK

c#,openxml-sdk,word-2010,word-2013
I have a Word 2013 document containing a check box control. I have set this checkbox's Tag property to fooCheckBox: Now I would like to programmatically find and manipulate that particular checkbox using Open XML SDK 2.5. I know how to find/enumerate checkboxes, but I don't know how to find...

OpenXml.WordProcessing.Justification always comes as OpenXmlUnknownElement

.net,ms-office,openxml,openxml-sdk
I'm building a table using OpenXml and setting the Justification property for every cell. It doesn't really matter where I assign this property, either in the Run element or as a TableCellProperty, when the document is open using the Productivity Tool for MS Office the Justification element always comes as...

Problems retrieving content controls with Open XML sdk

ms-office,sharepoint-2013,openxml,openxml-sdk
I am developing a solution that will generate word-documents. The word-documents are generated on the basis of a template document which has defined content controls. Everything was working good for me when I had only one content control in my template, but after expanding the template document with more content...

How to get rowspan and cospan of word document table using openXML

c#,vsto,openxml,openxml-sdk
i m very new to openXML, i m trying to get the colspan and rowspan value of the table in wordprocessingML. can any one explain how can i get these two values using openXML Thanks in advance...

create a copy of template presentation “.potx” to a new “.pptx” using openXML

c#,powerpoint,openxml-sdk
I have a powerpoint template with .potx extension, i need to create a copy of the template file, but the created file does not have any content present in it, it is a blank presentation, below is the function i am using to create a destination file using template file....

Read uploaded pptx file with Open XML SDK

c#,asp.net,vb.net,visual-studio-2013,openxml-sdk
I'm trying to build a website where one can upload a .pptx file, and a few aspects would be checked (e.g. slide count). I have the Open XML SDK 2.5 and I have added a reference to it. Yet, when I try to use commands from the SDK, they are...

OpenXml can't open docx file after vertically merged cells,

openxml-sdk
string path = @"D:\newdoc.docx" ; using (WordprocessingDocument doc = WordprocessingDocument.Create(path, WordprocessingDocumentType.Document)) { MainDocumentPart mainpart = doc.AddMainDocumentPart(); mainpart.Document = new Document(); Body body = mainpart.Document.AppendChild(new Body()); Table t = new Table(); TableProperties tpr = new TableProperties(new TableWidth(){Width="0",Type=TableWidthUnitValues.Auto},new TableLook(){Val="04A0"}); t.Append(tpr); TableGrid tg = new TableGrid(new GridColumn() { Width = "4261" }, new...

Using WordprocessingDocument error: Unable to create mutex

c#,.net,openxml,docx,openxml-sdk
I'm using this simple pattern to create a docx file in an ASP.NET app: var outputFileName = "creating some file name here..."; var outputFile = string.Format("~/App_Data/files/{0}.docx", outputFileName); // creating a file stream to write to var outputStream = new FileStream(HttpContext.Current.Server.MapPath(outputFile), FileMode.OpenOrCreate); // creating the default template using (var sr =...