Patrick's Bytes

1, December 2008

My new blog address

In case you drop by here. Do check out my new blog site at http://patrickyong.net

I will stop posting at this side.

29, July 2008

Novell OpenOffice developer speaks on why we need client side apps

Filed under: OpenOffice,OpenXML — patrickyong @ 5:22 am

Some may look at this interview as a Sun bashing post but I think its more on why client side apps like OpenOffice (or MS Office) is still relevant despite more companies coming out with online apps like Google Apps

Also OpenOffice.org isn’t even finished right now and rewriting all of this in HTML and Javascript would be quite difficult, the web is not a beautiful, clean development environment. It’s actually very difficult to produce something which looks like you want it to look like. And that’s by design – it’s not a fixed layout, which is good for the web but when you try to layout documents you need more precision.

Meeks also mentioned why OpenOffice does not need to follow MS Office 2007 Ribbon interface but the problem with current OpenOffice UI

The current one is using a very inflexible widget toolkit called VCL and that is really something out of the Mid-Nineties – it’s a disaster. It hasn’t been improved substantially since then. So we are doing a whole lot of work to improve the widget toolkit inside OpenOffice.org, to introduce layout and that’s being funded by Novell and driven by us.

 

Then they chat about an alternative OpenOffice version named Go-OO

There also is the gstreamer audio/video-support which is not yet upstream, lots of that nasty Microsoft Works file format support, Mono-integration, better Chinese font rendering and so on. You can go to go-oo.org/discover and check the differences out for yourself.

Not to leave out is OOXML support in Go-OO

11, June 2008

OpenXML Format SDK v1.0 RTMed

Filed under: OpenXML — patrickyong @ 10:59 am

Erika Ehrli annouced the availability of OpenXML Format SDK 1.0 at her blog. I am downloading and testing it out now.

27, May 2008

Replace content of <w:t> element inside Content Controls with data bound value from Custom XML part

Filed under: LINQ,OpenXML,Word — patrickyong @ 4:47 pm

In my previous post I discovered that Content Controls in WordprocessingML files which has data binding to a CustomXML part will not render properly. However, this ONLY apply if you programmatically replaces the CustomXML part but never modify the value of <w:t> within the <w:sdt> element just like in this Eric White’s video on YouTube or as per mentioned in the book [Pro SharePoint Solution Development] in Chapter 7 .

To make things clearer, lets look at the screen shots below. For a Word 2007 document with CustomXML data bound(AND also with the CustomXML modified programmatically), below is what it looks like by default when you open it with Office 2003 (or XP and 2000), the data does not appear (below).

image

Even though you see there is no problem when open it up with Office 2007 (below)

image

This is because the Compatibility Pack for Office 2007 File Format does not render the value data bound inside the <w:databinding> element but instead its take the value in <w:t> element, shown below:

<w:sdt>
– <w:sdtPr>
<w:dataBinding w:xpath=”/root[1]/name[1]” w:storeItemID=”{b6aa39be-c6d5-40ca-a66e-93dbd069104f}” />
  <w:id w:val=”3411243″ />
– <w:placeholder>
  <w:docPart w:val=”DefaultPlaceholder_22675703″ />
  </w:placeholder>
  <w:showingPlcHdr />
  <w:text />
  </w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”006D15FD” w:rsidRDefault=”00F43988″>
– <w:r w:rsidRPr=”00583873″>
– <w:rPr>
  <w:rStyle w:val=”PlaceholderText” />
  </w:rPr>
<w:t>Click here to enter text.</w:t>
  </w:r>
  </w:p>
  </w:sdtContent>
  </w:sdt>

So I created a generic project using the latest OpenXML SDK (April 08 CTP) and together with LINQ to XML to modify the content within <w:t> element with the value from the CustomXML part. You can download my full source code here, but basically this is how my solution works:

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

        public void Convert(string fileName)
        {
            using (var wordDoc = WordprocessingDocument.Open(fileName, true))
            {
                var mainPart = wordDoc.MainDocumentPart;

                XmlReader reader;

                reader = XmlReader.Create(mainPart.GetStream(FileMode.Open, FileAccess.Read));

                XDocument mainXml = XDocument.Load(reader);

                string xpath;
                XElement t;
                var bindings = mainXml.Descendants(w + “dataBinding”);

This is where the magic works, grab XPath attribute value from all the <w:databinding> elements and then replace it into <w:t> element using GetValueFromCustomXmlParts method (details do refer my source code)

                foreach (XElement binding in bindings)
                {
                    xpath = binding.Attribute(w + “xpath”).Value.ToString();

                    t = binding.Parent.Parent.Descendants(w + “t”).First();
                    string textValue = GetValueFromCustomXmlParts(mainPart.CustomXmlParts, xpath, myns);

                    t.ReplaceNodes(textValue);

                }

                XmlDocument temp = new XmlDocument();
                temp.Load(mainXml.CreateReader());
                temp.Save(wordDoc.MainDocumentPart.GetStream(FileMode.Create, FileAccess.Write));
            }
        }

After that the Word 2007 document can be opened in Office 2003 and data are rendered successfully. This solution also works in other none-MS Office productivity suites such as ThinkOffice and WordPerfect.

image

Disclamer: This is just a quick fix or rather a proof of concept on how to solve the <w:databinding> element problem on a simple Word 2007 document, there are  many situations (or more complex document layout) I haven’t tested the solution on. Do download my solution at your own risk. If you bump into problems do let me know, but my help will only be on best effort basis.

By the way, here is Eric’s video on the new OpenXML SDK

[YouTube=http://www.youtube.com/watch?v=t_FYHd234ng]
YouTube – Open XML SDK demo and road map

image

23, May 2008

Compatibility Pack for Office 2007 file format does not render <w:dataBinding>

Filed under: OpenXML,Word — patrickyong @ 10:01 am

I created a Word 2007 file with data binding to a CustomXML part

clip_image001

When I open it in Word 2003 with the capability pack installed, the data is not displayed.

clip_image003

After some investigation, I open up the document.xml (just rename the word file extension to .zip instead of .docx) and realize that the compatibility pack only renders the content inside <w:t> tag and ignores the XPath binding on the <w:dataBinding> tag. Below is a part of my document.xml, notice the blue colored text.

<w:sdt>
– <w:sdtPr>
  <w:dataBinding w:xpath=”/root[1]/name[1]” w:storeItemID=”{b6aa39be-c6d5-40ca-a66e-93dbd069104f}” /> 
  <w:id w:val=”3411243″ />
– <w:placeholder>
  <w:docPart w:val=”DefaultPlaceholder_22675703″ />
  </w:placeholder>
  <w:showingPlcHdr />
  <w:text />
  </w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”006D15FD” w:rsidRDefault=”00F43988″>
– <w:r w:rsidRPr=”00583873″>
– <w:rPr>
  <w:rStyle w:val=”PlaceholderText” />
  </w:rPr>
 
<w:t>Click here to enter text.</w:t>
  </w:r>
  </w:p>
  </w:sdtContent>
  </w:sdt>

If you are creating a WordML document thru this manner and want to enable it for users of older version of Word, remember to update your <w:t> tag as well.

22, May 2008

Office 2007 SP2 to have wider document support

Filed under: Office,OpenXML — patrickyong @ 11:58 am

I believe Microsoft is really committed to promote interoperability with other vendors, even when they are direct competitors. Recently announcement on inclusion of ODF and PDF support into Office 2007 Service Pack 2 is a strong evidence.

image

Having said that, the above mentioned 2 document formats have already been supported via freely available addins

  1. PDF Save as in Office 2007
  2. ODF translator for Office 2007

The default and newer MS Office file format still has its own advantage over the others especially for integration works with line of business applications. So after acceptance by ISO, Microsoft will of course continue to work on this format for the benefits of its customers.

Another interoperability evidence would be support of Silverlight inside Linux by Novel, which I think is very cool.

18, April 2008

OpenXML Software Developer Kits Beta released

Filed under: OpenXML — patrickyong @ 6:34 am

Now that OpenXML got accepted as an ISO standard, the next thing for developers is how they can build application using the file format. There are tons of samples out there showing how to do it with any ZIP APIs (such as .NET System.IO.Packaging) and XML APIs but it is not so productive for this approach.

The better way would be someone (not just Microsoft) to come out with APIs or namely SDKs to give developers an easy way to manipulate the file format. Long awaited ones is  the .NET and Java SDK for OpenXML and they have released refreshed version of their SDKs.

The .NET based OpenXML Format SDK is developed by Microsoft and has LINQ for XML capabilities; which make it very productive. You can check out Erika’s blog post for more information. This SDK will have a version 1.0 RTM somewhere around May, and then follow up by works on version 2.0.

Then the second one is the open sources OpenXML4J APIs. This Java based SDK is a community effort (some blog even mentioned the involvement of developers from the POI project). It was in Alpha stage for sometime until I worry about it not moving forward anymore, but on 10 Apr 2008, they released the Beta version. Best of all they have came out with a roadmap.

9, April 2008

Office Developer Conference ’08 contents now online

image

The slides from ODC 2008 are made available on the OBA Central website.

The slides are categorized into a few categories:

  • Architecture (those planning a full scale deployment of OBA should read this!)
  • Client (incl. coverage of some lesser know product for OBA i.e. Access & Groove)
  • Executive
  • Server (ala SharePoint, look out for stuffs on BI and Authentication)
  • Services (SOA & S+S)

One of the cool thing I saw from the slides is a 3d Silverlight webpart for Plant Floor OBA RAP (pic below).

image

http://www.obacentral.com/ODC

2, April 2008

RosettaNet – Microsoft M’sia Standard Synergy Workshop – Penang

Filed under: OpenXML,RosettaNet — patrickyong @ 4:20 pm

I basically used one day to cover how to integrated RosettaNet PIP into a Word and Excel document using

  • Integrate Custom XML Part into Word with Content Controls
  • Integrate XML Schema into Excel documents
  • Customizing the Office 2007 Ribbon UI with customUI.xml
  • VBScript
  • .NET with Office Object Model
  • .NET with Packaging and XML API (for Server side solution)

Below are some photos captured by Stanley

 P3310422
Dr Dzahar on document interoperability

P3310417 
Shariffah on RAE

P4010455 - Copy
Me showing some C# coding

P3310413

P3310412
Workshop attendees

1, April 2008

Files to download from Standard Synergy Workshop

Filed under: OpenXML — patrickyong @ 11:57 pm

Word data binding toolkit. http://cid-732d1d42507315a3.skydrive.live.com/self.aspx/RosettaNet0804/WordDatabinding.zip

Using Packaging and XML API to extract Custom XML Part http://cid-732d1d42507315a3.skydrive.live.com/self.aspx/RosettaNet0804/WordCustomXmlExtract.zip

Using Word Object Model and .NET to export Custom XML Part http://cid-732d1d42507315a3.skydrive.live.com/self.aspx/RosettaNet0804/WordXmlExportAddin.zip

Using VBScript to extract and email XML data. http://cid-732d1d42507315a3.skydrive.live.com/self.aspx/RosettaNet0804/Invoice.xlsm

Next Page »

Blog at WordPress.com.