It seems that Microsoft has lost a lawsuit over their custom xml implementation for Office Open XML. This was about the worst news I could get just before the holidays since I have been working on creating solutions around just that feature. To me it is the most flexible part of the OOXML standard and crosses all types of Office documents. I can only hope that they settle this dispute so we can get back to moving forward document generation processes.
I am starting to write a new blog with my co-worker Andy Schwantes on open document standards and development. I will be cross-posting much of the content here. Check it out.
In an effort to better serve the Chicago architecture community here is a preview of upcoming topics.
January – Dependency Injection and Inversion of Control Containers
February – Amazon Cloud Service
March – Data Integration Architecture
Document Generation Architecture
Shared strings are the way that Excel reduced redundant data in a worksheet. They are also important if you are working with charts in Word documents or PowerPoint slide decks. Instead of inserting string constants into a cell you give it the index of the string from the SharedStringTable and mark the cell as having a shared string reference.
So what does it take to work with the SharedStringTable
The first thing you need to do is retrieve the existing shared string table. This is a fairly simple operation as is demonstrated below.
SharedStringTablePart sharedStrings = tempSpreadsheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
Another operation that you will want to do is finding strings within the table since the entire purpose of using it is to eliminate redundancy. I handled this by creating a simple method after converting the SharedStringItems of the table into a List<T>.
private static int GetIndexOfSharedString(List<spreadsheet.SharedStringItem> items, string text)
int result = -1;
for (int index = 0; index < items.Count(); index++)
if (items[index].Descendants<spreadsheet.Text>().First().Text.Trim() == text.Trim())
Lastly you will want to add new strings to the table. This is fairly straight forward, but note the last three lines. If you don’t update the counts you will find your new items never save.
sharedItem = new spreadsheet.SharedStringItem();
That is really all there is to it.
(Note: for those who have complained about the code formatting I hope this is better)
The Chicago Architects Group will be holding its next meeting on January 19th. Please come and join us and get involved in our architect community.
Presenter: Tim Murphy
Topic: Dependency Injection and Inversion of Control Containers
Location: Illinois Technology Association
200 S. Wacker Dr., Suite 1500
Chicago, IL 60606
Time: 5:30 - Doors open at 5:00
On December 7th I presented at the nPlus1.org ArcSummit. My talk was on Dependency Injection and Inversion of Control containers. Thank you to all those who attended.
When we were done Chris Woodruff and I were asked to record an episode of The Thirsty Developer. It was a great experience seeing how these shows are put together and being able to just sit down and talk with Dave Bost, Clark Sell and Chris Woodruff. I’ll post again when the episode comes out.
The slides for the presentation are available here.
The code is available here.