Mixing Spreadsheets and WPF

by clearoffice 13. July 2010 02:59

For quite some time, Clear Office has enabled software developers to host spreadsheets inside their WPF application.

Starting with version 1.0.2010.0710, Clear Office supports hosting WPF elements inside a worksheet. Clear Office supports hosting any descendant of FrameworkElement including any control, shape or panel. Here is a sample screen shot in Clear Office:

 

In this screen shoot, the button filled with an orange ellipse is a WPF button.

You can save spreadsheet documents with embedded WPF elements to a .xlsx file and open them with Excel. Here is a screen shot of the same file in Microsoft Excel

Rountripping is also supported: you can save files from Excel and reopen them in Clear Office.

How it works

Before this release,, worksheet anchors could contain only the following:

  • Shape, Picture, GroupShape and Connector from Office.Drawing
  • GraphicFrame from Office.Chart

This release introduces a new option for anchored content: XamlElement. XamlElement in turns contains a Content of type FrameworkElement.

Here is the code to add someElement inside a anchor of a worksheet

OneCellAnchor anchor = new OneCellAnchor(worksheet[3, 5]){Width=100, Height=100};

anchor.Content = new XamlElement{e.Content = someElement};

worksheet.Anchors.Add(anchor);

 XamlElement uses the standard WPF XAML serialization (XamlReader/XamlWriter) to serialize to file. As a result, any property / attached property and behavior will be serialized.

For example, have a look at the "EmbeddedObjectsSample" Sample of the Spreadsheet Framework. This sample demonstrates how to insert the button in the screen shot above and how to assign a click behavior similar to an Excel macro.

(This is a release candidate, details may change before a formal release)

Tags:

Comments

7/20/2010 8:03:16 PM #

trackback

Mixing Spreadsheets and WPF - part 2

Mixing Spreadsheets and WPF - part 2

Clear Office | Reply

8/5/2010 3:46:30 AM #

Air force one

So happy to enjoy such a insightful article that does not depend on base posturing to get the topic fulfilled. Thank you for an enjoyable read!

Air force one United States | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Clear Office

Official Clear Office blog

Page List