openxml

Serializing Hashset contents to a SQL table

I have a hashset that I want to serialize to a SQL Server table. When serialized hashset looks like this... <InstallerContactIds> <int>153771</int> <int>209572</int> </InstallerContactIds> I am using the following to insert the XML into the table... INSERT INTO dbo.cv_AssessorActionPlanInstallers SELECT @AssessorActionPlanId...

Returning Explicit Open XML results sets from a Table Value Function

I'm trying to return rows in Open XML form from a table value function in SQL Server (2008). I'm occasionally getting errors when I select the results with "for xml explicit" which suggest that the order of the results is not guaranteed to be the same as the order I insert into the output of the TVF. So my first question is: is that th...

Microsoft Word Document Controls not accepting carriage returns

So, I have a Microsoft Word 2007 Document with several Plain Text Format (I have tried Rich Text Format as well) controls which accept input via XML. For carriage returns, I had the string being passed through XML containing "\r\n" when I wanted a carriage return, but the word document ignored that and just kept wrapping things on the ...

How to replace content in template docx document and Open XML SDK 2.0 (Aug 09)?

I have a "template" docx document which contains the desired layout, and wish to insert content using C#, but I cannot find a way to uniquely address specific sections of the document, such as paragraphs or tables. What is the best way to uniquely identify elements in the document? Thanks, Matt Sharpe. ...

Different types of hyperlinks in Word document

I'm writing a small app the takes a path as input and then fetches every docx file in that path, replacing every hyperlink with a keyword. The strange thing is that I found two sorts of hyperlinks, the first one is from WordprocessingDocument ExternalRelationships and the other one is from finding every xml-node matching <w:insrText/> s...

OpenXML - CellFormats - Do I really need to configure one for every single permutation??

I'm currently working with v2.0 of the SDK to generate an Excel workbook and it was all going well until I came to apply the cell formatting. I've created a few CellFormats and successfully applied them but there are a few more permutations that I need to configure: 4 fonts (normal, bold, italic and bold+italic) 5 number formats 3 ali...

How to get parent element name using OpenXML in sqlserver

If I have some xml: <Users> <User> <property1>sdfd</property1> ... <User> ... </Users> And my sql is: SELECT * FROM OpenXML(@idoc, '/Users/User') WITH ( [property1] varchar(50) 'property1', ... ) How can I get the name of the parent element and return that in the d...

Parsing older SpreadsheetML Schemas

I need to parse report files that are generated in an old version of the SpreadsheetML formats (See the HTML Header of the file below) in order to merge multiple single-page reports into a single tabbed workbook with all formatting and contents intact. <HTML xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsof...

OPENXML with xmlns:dt

Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt element in xml? For example, get a result set of two rows that list product id and country code. 121403 GBR 121403 USA declare @xmldata xml set @xmldata = '<?xml version="1.0"?> <data xmlns="http://www.aaa.com/master_browse_response" xmlns:dt="http://w...

How to extract plain text from a DOCX file using the new OOXML support in Apache POI 3.5?

On September 28, 2009 the Apache POI project released version 3.5 which officially supports the OOXML formats introduced in Office 2007, like DOCX and XLSX. Please provide a code sample for extracting a DOCX file's content in plain text, ignoring any styles or formatting. I am asking this because I have been unable to find any Apache P...

OpemXML Namespaces

How do I get the namespaces of specific nodes in the OpenXML standard? Here is an example of using them: NameTable nt = new NameTable(); XmlNamespaceManager nsManager1 = new XmlNamespaceManager(nt); nsManager1.AddNamespace("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); BUT I still need to know how / where she gets th...

Renaming OpenXML Styles

In my attempt to go through and rename styles before feeding multiple docx's into a merge library I have created a large and complicated routine that modifies the <w:style w:styleId="..."> and <w:name w:val="..."> attributes of the style element. Then modifies any reference to old style id's in the rest of the docx. This seems as if it ...

Installing open XML sdk on 64-bit Windows 2003

I intend to use the Open XML Format SDK 2.0 on 64-bit Windows Server 2003. I have IIS running in 32-bit emulation mode. How should I install the Open XML MSI? Should I leave the default options for installation path? ...

How to exporting data from a List<T> to excel file?

Hi All, I have a List<Person> which is bound to a grid view. I want to export all the values to an excel file. My person class is as follows: class Person { public string Name{get;set;} public string City{get;set;} public int Age{get;set;} } Is there any way to do it? Please suggest.... ...

How to create a excel file with sheets in C#?

Hi All, I want to create an excel file say personinfo.xls with one work sheet say "Person". Is there a way in C# to do it, please suggest. ...

What is the difference between Office Automation, VSTO, and Open XML SDK?

What is the difference between Office Automation, VSTO, and Open XML SDK? Do we need all of them or some of them are obsolete? ...

Simple Example of creating a PowerPoint file

I'm looking for some sample code on how to add an image and text & output it as a PowerPoint file. The host server does not have Office and I'm not allowed to install anything so the "Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Format API " will not help me. Below is the code the output the PowerPoint. I just don'...

Insert OpenXmlElement after word bookmark in Open XML SDK

I was able to access a bookmark in my word document using this code: var res = from bm in mainPart.Document.Body.Descendants<BookmarkStart>() where bm.Name == "BookmarkName" select bm; Now I want to insert a paragraph and a table after this bookmark. How do I do that? (exampl...

Open XML SDK 2.0 inserting PDF to Word

Hello everybody, has anyone tried to insert pdf document into word using open xml sdk 2.0 ? Thank You! ...

Problem setting content control with OpenXML SDK 2.0

I have a Word 2007 doc with content control, title and tag set to "Control1" and the value "X". I am trying to change the value of Control1 to "Y" string sdtName = "Control1"; SdtBlock sdt = mainPart.Document.Descendants<SdtBlock>() .Where(s => s.GetFirstChild<SdtProperties>().GetFirstChild<Alias>().Val.Value...