openxml

Validate a Word 2007 Template file

I'm developing a solution that allows people to upload a DOCX file as a template. This template is used for generating Word documents with database info. What I would like to do is once a template gets uploaded, to check it for errors. (I don't want my parser crashing when a template is used.) I've seen the question about checking a ...

Can't get value from openxml when element has xmlns attribute

The xmlns attribute in the following code stops me getting the value I need. Works fine with any other attribute but not xmlns. I have no control over the xml I'm given - how can I get the CrpId value? declare @CrpId int, @i int, @xml xml set @xml = '<NewProgressReportResult xmlns="http://myDomain.com/crp"&gt; <CrpId>2160</CrpId> </New...

How do you open encrypted OOXML document in C#?

I want to open encrypted OOXML files, which are stored as streams inside a compound OLE file. Microsoft has an API for OOXML, (OOXML Format SDK 2.0, but it seems to lack a way to manipulate encrypted OOXML documents. So, this breaks into two questions. How do you open compound OLE documents in C#? I found this very similar question,...

How to grab text from word (docx) document in C#?

Hey all, I'm trying to get the plain text from a word document. Specifically, the xpath is giving me trouble. How do you select the tags? Here's the code I have. public static string TextDump(Package package) { StringBuilder builder = new StringBuilder(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(package.GetP...

Use System.IO.Packaging for FlatOPC

I develop a software that uses FlatOPC files. I need to manipulate several parts of the File. System.IO.Packaging offers the classes ZipPackage and ZipPackagePart for manipulation .docx files. There is no implementation for FlatOPC. So I've built my own. The Problem is, that using the FlatOPCPackage with a WordprocessingDocument causes ...

Strange WCF Error - IIS hosted - context being aborted

I have a WCF service that does some document conversions and returns the document to the caller. When developing locally on my local dev server, the service is hosted on ASP.NET Development server, a console application invokes the operation and executes within seconds. When I host the service in IIS via a .svc file, two of the documen...

Duplicating Word document using OpenXml and C#

I am using Word and OpenXml to provide mail merge functionality in a C# ASP.NET web application: 1) A document is uploaded with a number of pre-defined strings for substitution. 2) Using the OpenXML SDK 2.0 I open the Word document, get the mainDocumentPart as a string and perform the substitution using Regex. 3) I then create a new d...

Using reflection with generic types and implicit conversions

I'm trying to use reflection to set properties on some OpenXML types (e.g. Justification). Assigning a value by enumerating all possibilities is straight-forward: // attr is an XmlAttribute, so .Name and .Value are Strings if (attr.Name == "Val") { if (element is Justification) { ((Justification)element).Val = (Justific...

Office Open XML: Relationship not used in the document

I have an Open Office XML document where a relationship that is defined in a relationship part is not used anywhere in the document, neither in the MainDocumentPart nor in any other part. Is this an invalid OpenXML Documment or not. Are unsues relationships allowed do the cause the document to be invalid? ...

XLSX- how to get rid of the default namespace prefix x: ?

I'm generating XLSX spreadsheet using OOXML SDK, and I need to get rid of x: namespace prefix. How can I achieve this? using (SpreadsheetDocument doc = SpreadsheetDocument.Open("template.xlsx", true)) { //Save the shared string table part if (doc.WorkbookPart.GetPartsOfType().Count() > 0) ...

Saving an OpenXML Document (Word) generated from a template

I have a bit of code that will open a Word 2007 (docx) document and update the appropriate CustomXmlPart (thus updating the Content Controls in the document itself as they are mapped to the CustomXmlPart) but can't work out how to save this as a new file.! Surely it can't be that hard! My current thinking is that I need to open the temp...

Inserting a Table into a Word Document using OpenXML SDK

I'm trying to insert a new table into a document but have run into a frustrating problem. The insertion point is currently defined by a Bookmark and I want to be able to add the table between the BookmarkStart and BookmarkEnd elements but have found that if they reside within a Paragraph element then Word won't open the resulting docum...

OPENXML Remote Scan Performance

I'm looking for some advice on OPENXML. Specifically, the performance. I am seeing very slow performance on a very small piece of XML. Something about this is causing a Remote Scan. Any ideas on how to go about tuning it? DECLARE @idoc int EXEC sp_xml_preparedocument @idoc OUTPUT, @ResourceXML DECLARE @tmpRes TABLE (ResourceID...

Embedding an OpenXML document within another OpenXml document

I have a need to gather a number of .docx files in a folder and "chain" them into a single document that will be displayed to the user. Now I've read Brian Jones' article but while it sounded promising I have encountered a problem. When I perform the actions manually using Word 2007 I end up with a copy of the docx file in the /embeddi...

opening .xlsx in office 2003

Hi, I have created a .xlsx using openxml. I am not able to open this file in office 2003.. I have also tried using compatibility pack but still the file does not open. What can be done if i need to generate .xlsx that can be opened in office 2003 as well. Code i am using to generate .xlsx is : public static void HelloWorldXlsx(string ...

SQL, OPENXML and DateTime conversations...

Hi, I've inherited a mass of stored procedures that take as their only parameter a block of XML, the author then cracks it (using OPENXML) and then updates the a row. I've come across a problem while updating a table that has datetime columns, the following is a snippet of data that currently fails: declare @stuff nvarchar (max); set...

adding images to openxml doc created from altchunk

I need an automated process for creating docx files from xhtml source. The xhtml files contain images (<img> elements) whose "src" attributes point to an external reference. But the docx files need to be readable without a network connection, so I need to find a way to embed the images directly into the docx package (namely, in the /medi...

How can I query a Word docx in an ASP.NET app?

I would like to upload a Word 2007 or greater docx file to my web server and convert the table of contents to a simple xml structure. Doing this on the desktop with traditional VBA seems like it would have been easy. Looking at the WordprocessingML XML data used to create the docx file is confusing. Is there a way (without COM) to nav...

Document Protection with OpenXML SDK 2

I am programmatically creating a DOCX file using OpenXML SDK v2. One of the requirements of the document is it be protected to avoid editing. This is accomplished using the DocumentProtection object like: new DocumentProtection { Edit = DocumentProtectionValues.ReadOnly, Enforcement = BooleanValues.One, CryptographicProvid...

Will Subversion efficiently store OpenXML Office documents?

Hello, I have been managing Subversion as an engineering document storage repository for my company. It is working fairly well, however I have a question about how MS Office 2007 formats are (should be) handled by Subversion. I'm looking at an Excel 2007 spreadsheet (extension .xlsx) in my working copy that Subversion has applied the ...