Welcome to MSDN Blogs Sign in | Join | Help
Eric White's Blog Map

Sections

SharePoint Web Services / LINQ to XML / Open XML Tutorial

SharePoint

Open XML

Functional Programming / LINQ to XML

PowerTools for Open XML

Useful Code Snippets

Writing / Other

SharePoint Web Services / LINQ to XML / Open XML Tutorial

Web services are one of the most convenient and powerful approaches for a casual developer to access SharePoint programmatically.  The follow set of posts are a tutorial in leveraging SharePoint web services, LINQ to XML, and the Open XML SDK.

 

1.       Getting Started with SharePoint (WSS) Web Services using LINQ to XML

2.      Modifying Open XML Documents that are in SharePoint Document Libraries using
Web Services

3.      Accepting Revisions, Removing Comments, and Removing Personal Info from a SharePoint Document Library using Web Services

 

In the future, I’ll be presenting posts on using Web Services to interact in interesting ways with SharePoint wikis and lists of other types.

SharePoint

Removing Comments and Personal Information, and Accepting Revisions in an Open XML Document Stored in SharePoint

Modifications to web.config for Debugging SharePoint Components

SharePoint at the Intersection

Modifying Open XML Documents from within the SharePoint Object Model

 

Open XML

Open XML SDK and LINQ to XML

Using LINQ to Query Excel Tables

Transforming Open XML Documents using XSLT

Transforming Open XML Documents to Flat OPC Format

Transforming Flat OPC Format to Open XML Documents

The Flat OPC Format

Creating Data-Bound Content Controls using the Open XML SDK and LINQ to XML

Create a List of All Parts in an Open XML Document

OpenXmlCodeTester: Validating Code in Open XML Documents

Using LINQ to XML to Retrieve Content Controls in Word 2007

Remove Comments

Remove Personal Information

Accept Revisions

Automated Processing of Open XML Documents using PowerShell

Extract Comments

OpenXML Content Types in an XML Document

Bulk Convert DOC to DOCX

The Legacy Hashing Algorithm in Open XML

How to Use altChunk for Document Assembly

Inserting / Deleting / Moving Paragraphs in an Open XML Document

Remove Rsid Elements and Attributes before Comparing Open XML Documents

Inner Join of Two Excel Tables

Joining LINQ to SQL and LINQ to Excel

Working with In-Memory Open XML Documents

 

Functional Programming / LINQ to XML

Functional Programming Tutorial – C# 3.0

Functional Programming Tutorial – VB 9.0

Using Annotations to Transform LINQ to XML Trees in an XSLT Style

Performance of LINQ to XML

Performance of Chained Queries

Atomized XName and XNamespace Objects

Preatomization of XName Objects

Statically Compiled Queries

Writing Robust LINQ to XML Code that Performs Well

Closures

LINQ to TEXT and LINQ to CSV

Chunking a Collection into Groups of Three

Use a Lambda Expression for an Event Handler

Find Duplicates using LINQ

Generating a LINQ to XML Tree from Anonymous Types

How to Create Hierarchy from Flat Data using LINQ

The GroupAdjacent Extension Method

The SkipLast Extension Method

Formatting LINQ Code

Using LINQ to XML Events and Annotations to Track if an XML Tree has Changed

OpenXmlCodeTester: Validating Code in Open XML Documents

Use INFER.EXE to Create XML Schemas

Are Developers Using LINQ?

Are Developers Using LINQ? (Part 2)

Anders Hejlsberg Introduces C# 4.0 at PDC 2008

Debugging LINQ Queries

Comparing LINQ to XML and XPath

A More Robust Approach for Handling XName Objects in LINQ to XML

Writing Succinct Code to move XElement and XAttribute Objects from One LINQ to XML Tree to Another

Align Attributes when Formatting XML using LINQ to XML

Getting Started with SharePoint (WSS) Web Services using LINQ to XML

 

PowerTools for Open XML

Automated Processing of Open XML Documents using PowerShell

Detailed Description of PowerTools for Open XML cmdlets

 

Useful Code Snippets

Fastest Start for LINQ to SQL

Running an Executable and Collecting the Output

 

Writing / Other

Writing for Professional Developers

Thoughts on Technical Writing for a Large Audience

An Approach to Reading Specifications Quickly

 

 

Posted: Monday, October 20, 2008 12:06 PM by EricWhite
Filed under:

Comments

krishnaramuu said:

Hi Eric,

I have gone through some of your blogs related to openxml and they really helped me alot to learn and use openxml concepts in my current project that i'm working on. I have few issues in coding to extract embedded objects like excel, ppt from word document using openxml, C# and linQ.

var runs = from l_run in paragraph.Runs

                              let l_run_styleNode = l_run

                                          .Elements(w + "rPr")

                                          .FirstOrDefault()

                              let l_run_inheritStyle = l_run

                                          .Elements(w + "rPr")

                                          .Elements(w + "rStyle")

                                          .FirstOrDefault()

                              let l_run_graphics = l_run

                                          .Elements(w + "drawing")

                              let l_run_Objects=l_run

                                           .Elements(w + "object")

                              select new

                              {

                                  Run = l_run,

                                  RunType = l_run.Name.LocalName,

                                  CssStyles = l_run_styleNode != null ? CreateCssProperties(l_run_styleNode.CreateReader()) : "",

                                  CssClass = l_run_inheritStyle != null ? (string)l_run_inheritStyle.Attribute(w + "val") : "",

                                  Text = l_run.Descendants(w + "t").StringConcatenate(element => (string)element),

                                  BreakBefore = l_run.Element(w + "br") != null,

                                  ExternalRelationId = (l_run.Name == w_hyperlink ? (string)l_run.Attribute(rels + "id") : ""),

                                  Graphics = l_run_graphics,

                                  Excels=l_run_Objects

                              };

.....

.....

.....

.....

by using above query i could able to fetch the object from the document.xml file but retrieving the actual object from that is not working ... the code is here...

foreach (var run in runs)

                   {

var excels = from l_excels in run.Excels

                                    let l_excels_oleobject = l_excels

                                               .Descendants(a + "imagedata")

                                               .Where(xlz => xlz.Attributes(rels + "id") != null)

                                               .FirstOrDefault()

                                    select new

                                    {

                                        XLExternalRelationId = l_excels_oleobject != null ? (object)l_excels_oleobject.Attributes(rels + "id") : ""

                                    };

}

the above query didn't return any data from it...so can you plz guide me on this....

Thanks,

Ramakrishna

# March 11, 2009 8:58 AM

krishnaramuu said:

           XNamespace w = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";

           XNamespace rels = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";

           XNamespace a = "http://schemas.openxmlformats.org/drawingml/2006/main";

these are the namespaces i'm using....for the above post...

# March 11, 2009 8:59 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker