<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Jackhu&amp;#39;s Blog</title><subtitle type="html" /><id>http://blogs.msdn.com/b/jackhu/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/jackhu/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2009-09-02T13:51:00Z</updated><entry><title>Fsharp &amp; Excel: Reading and writing from and to Excel</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/archive/2011/04/19/fsharp-amp-excel-io-reading-and-writeing-to-excel.aspx" /><id>http://blogs.msdn.com/b/jackhu/archive/2011/04/19/fsharp-amp-excel-io-reading-and-writeing-to-excel.aspx</id><published>2011-04-19T21:32:19Z</published><updated>2011-04-19T21:32:19Z</updated><content type="html">&lt;p&gt;&lt;font size="2"&gt;To help people to get start with programing Excel in Fsharp, I will show several common scenarios for reading and writing data from and to excel spreadsheet. The scenarios are:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Example 0: Opening an exiting\Creating a new excel worksheet&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Example 1: Reading\Writing a cell value &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Example 2: Reading\Writing a row of values&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Example 3: Reading\Writing a column of values&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Example 4: Reading\Writing a Range of values&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Example 4: Writing a Jagged array to excel&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Example file Input.xlsx: &lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6136.image001_5F00_27823CA0.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0654.image001_5F00_7BD172A3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image001" border="0" alt="image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0272.image001_5F00_thumb_5F00_59F64FC6.png" width="404" height="239" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Example 0: Opening an exiting\Creating a new excel worksheet&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// read and write data to\from a excel workbook&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;#r&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#800000"&gt;&amp;quot;Microsoft.Office.Interop.Excel&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;#r&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#800000"&gt;&amp;quot;office&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;open&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt; Microsoft.Office.Interop&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// Start Excel, Open a exiting file for input and create a new file for output&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt; xlApp = &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt; Excel.ApplicationClass()&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt; xlWorkBookInput = xlApp.Workbooks.Open(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#800000"&gt;@&amp;quot;C:\Users\jackhu\Desktop\Input.xlsx&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt; xlWorkBookOutput = xlApp.Workbooks.Add()&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#000000"&gt;xlApp.Visible &amp;lt;- &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font color="#0000ff"&gt;true&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; background: white; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class="MsoNormal"&gt;&lt;span style="font-family: ; color: ; mso-fareast-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// Open input's 'Sheet1' and create a new worksheet in output.xlsx&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; xlWorkSheetInput = xlWorkBookInput.Worksheets.[&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;Sheet1&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;] :?&amp;gt; Excel.Worksheet&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; xlWorkSheetOutput = xlWorkBookOutput.Worksheets.[1] :?&amp;gt; Excel.Worksheet&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;xlWorkSheetOutput.Name &amp;lt;- &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;OutputSheet1&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7026.image002_5F00_6D92F9B3.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5543.image002_5F00_4D0BBA01.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image002" border="0" alt="image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7140.image002_5F00_thumb_5F00_6B6AC49D.png" width="373" height="274" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;First, I make reference to office interop dlls. I open an exiting excel workbook for input and create a new workbook for output by calling Workbooks.Open and Workbooks.Add(). The xlApp.Visible &amp;lt;- true property is set to display the workbooks. I then find the “Sheet1” from the input workbook by calling Worksheets.[&amp;quot;Sheet1&amp;quot;]and get the first worksheet from the output worksheet by indexing Worksheets.[1] into it. 
    &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Example 1: Reading\Writing a cell value&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 1: Reading\Writing a cell value using cell index&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; value1 = xlWorkSheetInput.Cells.[10,5]&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;xlWorkSheetOutput.Cells.[10,5] &amp;lt;- value1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 1.1: Reading\Writing a cell value using range&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; value2 = xlWorkSheetInput.Cells.Range(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;E10&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;E10&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;).Value2&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;xlWorkSheetOutput.Cells.Range(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;E10&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;E10&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;).Value2 &amp;lt;- value2&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6567.image003_5F00_5921FDDB.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image003" border="0" alt="image003" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3252.image003_5F00_thumb_5F00_18EBE461.png" width="377" height="254" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2"&gt;I show two ways of accessing a cell value. One method is by using array indexer. Inheriting from VB array indexing convention, the Excel indexer starts from 1 instead from 0. Another method is using the Range by specifying the starting cell location and ending cell location. In my example, since I only have one cell, E10 is used for both the starting and the ending position. 
    &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Example 2: Reading\Writing a row&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 2: Reading\Writing a row&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; row = xlWorkSheetInput.Cells.Rows.[1] :?&amp;gt; Excel.Range&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;(xlWorkSheetOutput.Cells.Rows.[1] :?&amp;gt; Excel.Range).Value2 &amp;lt;- row.Value2&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face="Calibri"&gt;&lt;font color="#000000" size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/2804.image004_5F00_3AC2F33F.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5531.image004_5F00_4C9F870C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image004" border="0" alt="image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/2766.image004_5F00_thumb_5F00_3F4DC7AC.png" width="292" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;In above code snippet, I use :?&amp;gt; to up-cast object to Excel range type, so that I gets intellisense\error checking support for the row value. To figure out the exact code, I also used the debugger to exampling the values to help me figuring out the correct type casting.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3225.image005_5F00_215AF005.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/4466.image005_5F00_333783D2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image005" border="0" alt="image005" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3821.image005_5F00_thumb_5F00_6306EF46.png" width="412" height="195" /&gt;&lt;/a&gt; 

    &lt;br clear="all" /&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;
      &lt;br clear="all" /&gt;Example 3: Reading\Writing a column&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 3: Reading\Writing a column&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; column1 = xlWorkSheetInput.Cells.Range(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;A:A&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;xlWorkSheetOutput.Cells.Range(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;A:A&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;).Value2 &amp;lt;- column1.Value2&lt;br clear="all" /&gt;&lt;br clear="all" /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7633.image006_5F00_50BE2884.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image006" border="0" alt="image006" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5327.image006_5F00_thumb_5F00_629ABC51.png" width="318" height="301" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2"&gt;Similar to the row example, we can also use a column index to select a range xlWorkSheetInput.Cells.Columns.[1] :?&amp;gt; Excel.Range. Instead, I use the range parameter “A:A” for the column ( I may use “1:1” is for a row). 
    &lt;br clear="all" /&gt;

    &lt;br clear="all" /&gt;

    &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Example 4: Reading\Writing a Range&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 4: Reading\Writing a Range&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; inputRange = xlWorkSheetInput.Cells.Range(&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;A1&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#800000"&gt;&amp;quot;E10&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; i &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; 1 .. inputRange.Cells.Rows.Count &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; j &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; 1 .. inputRange.Cells.Columns.Count&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; xlWorkSheetOutput.Cells.[i,j] &amp;lt;- inputRange.[i,j]&lt;br clear="all" /&gt;&lt;br clear="all" /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/4745.image007_5F00_3756254A.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image007" border="0" alt="image007" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5482.image007_5F00_thumb_5F00_622E895C.png" width="345" height="270" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2"&gt;Of course, there are many other ways to read and write a large range of the data. Here, I show how a two nested for loops for iterate through the worksheet as a 2D array. 
    &lt;br clear="all" /&gt;

    &lt;br clear="all" /&gt;

    &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;Example 5: Writing a Jagged array&lt;/b&gt; &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#008000" size="2"&gt;// EXAMPLE 5: Writing an Jagged arrays&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;let&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; data =  [|  [|0 .. 1 .. 2|];&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;                [|0 .. 1 .. 4|];&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;                [|0 .. 1 .. 6|] |]&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; i &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; 1 .. data.Length &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt;    &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; j &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#000000"&gt; 1 .. data.[i-1].Length &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; color: "&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000" size="2"&gt;        xlWorkSheetOutput.Cells.[j, i] &amp;lt;- data.[i-1].[j-1]&lt;br clear="all" /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br clear="all" /&gt;&lt;/pre&gt;

&lt;pre style="list-style-type: disc; margin: 0in 0in 0pt; background: white"&gt;&lt;font color="#000000" size="2" face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6567.image008_5F00_68755FEA.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image008" border="0" alt="image008" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3252.image008_5F00_thumb_5F00_3D30C8E3.png" width="296" height="247" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2"&gt;When your data does not conform to M by N size, the jagged array is a more practical approach. I hope a few simple examples can help you to get started with excel. Happy coding!&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10155965" width="1" height="1"&gt;</content><author><name>Jackhu MSFT</name><uri>http://blogs.msdn.com/hxh8309_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Fsharp &amp; Excel: Creating Excel charts from F# FSI</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/archive/2011/04/15/creating-excel-charts-from-f-fsi.aspx" /><id>http://blogs.msdn.com/b/jackhu/archive/2011/04/15/creating-excel-charts-from-f-fsi.aspx</id><published>2011-04-15T22:40:00Z</published><updated>2011-04-15T22:40:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2"&gt;Following up with the recent announcement on F# &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/dsyme/archive/2011/04/01/fsharpchart-wrapping-the-system-windows-forms-datavisualization-charting-charting-types.aspx"&gt;&lt;font size="2"&gt;EasyChart&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;, I like to point out a few .net charting libraries that can potentially be applied to the interactive development environment like the F# FSI window. &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://vslab.codeplex.com/"&gt;&lt;font size="2"&gt;VSLAB&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; – lots feature in 3D plot, can be run as VS2010 add-in &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devexpress.com/Products/NET/Controls/Charting/2d_charting.xml"&gt;&lt;font size="2"&gt;XtraCharts&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; – Industry strength, good for drag and drop designer type of development, but not great for FSI &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx"&gt;&lt;font size="2"&gt;Microsoft Chat Controls&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; – it is the base for EasyChart, it is good for apps &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.dotnetcharting.com/overview.aspx"&gt;&lt;font size="2"&gt;DotnetCharting&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; – has a several unique charts, it is good for domain specific applications. &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;In this blog, I also like to demonstrate how to call Excel chart libraries from the FSI window. There are several benefits for using the excel charts from FSI &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Popularities&lt;/strong&gt;: most people has experience with excel charting. It is easy to prettify, add a title, copy and paste the chart into your presentation. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Community&lt;/strong&gt;: there are plenty C# to Excel code example. To find out how to do a 3D plot, you can simply Bing it. &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font color="#333333"&gt;&lt;strong&gt;Step0: Software Setup&lt;/strong&gt;&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;VS2010 + Office 2010 &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Step1: Past in following code in FSI&amp;#160; &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;&lt;font size="2"&gt;       &lt;br clear="all" /&gt;&lt;/font&gt;&lt;/strong&gt;    &lt;blockquote&gt;     &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;#r&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.5pt" color="#800000"&gt;&amp;quot;Microsoft.Office.Interop.Excel&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;#r&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.5pt" color="#800000"&gt;&amp;quot;office&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;open&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; Microsoft.Office.Interop&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; dataX = [|0.0 .. 0.1 .. 10.|]&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;font color="#000000"&gt; dataY = [|&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;[|&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; f &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dataX &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;-&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; cos f|];&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;[|&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; f &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; dataX &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;-&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; sin f|] |]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Update the excel charting object&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;font color="#000000"&gt; xlApp = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Excel.ApplicationClass()&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; xlWorkBook = xlApp.Workbooks.Add()&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; xlWorkSheet = xlWorkBook.Worksheets.[1] :?&amp;gt; Excel.Worksheet&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; xlCharts = xlWorkSheet.ChartObjects() :?&amp;gt; Excel.ChartObjects&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; xlChart = xlCharts.Add(1., 1., 460., 380.)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; myChart = xlChart.Chart&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Fill in a excel worksheet with data from dataY[][]&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;for&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;font color="#000000"&gt; i &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; 1 .. dataY.Length &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.5pt" color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; j &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; 1 .. dataY.[i-1].Length &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.5pt" color="#0000ff"&gt;do&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;xlWorkSheet.Cells.[j, i] &amp;lt;- dataY.[i-1].[j-1]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.5pt"&gt;let&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt; xlRange = xlWorkSheet.Cells.CurrentRegion&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;myChart.SetSourceData(xlRange)&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: ; color: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Set Plot type and show chart&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt" color="#000000"&gt;myChart.ChartType &amp;lt;- Excel.XlChartType.xlXYScatterLines&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p style="list-style-type: disc; margin: 0in 0in 0pt; text-autospace: ; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 9.5pt"&gt;xlApp.Visible &amp;lt;- &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.5pt" color="#0000ff"&gt;true&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/blockquote&gt; &lt;/p&gt;     &lt;pre class="csharpcode"&gt;It result in:&lt;/pre&gt;

&lt;pre&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3644.I1_5F00_41A28459.jpg"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6355.I1_5F00_02152109.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="I1" border="0" alt="I1" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1854.I1_5F00_thumb_5F00_1F786AB3.jpg" width="538" height="459" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2" face="Segoe UI"&gt;FSharp language services Intellisense fairly useful to select a right chart. &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3225.I2_5F00_7D9EA041.jpg"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3225.I2_5F00_7D9EA041.jpg"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/8037.I2_5F00_5664570C.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="I2" border="0" alt="I2" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0601.I2_5F00_thumb_5F00_65AB2789.jpg" width="476" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;Happy coding&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10154657" width="1" height="1"&gt;</content><author><name>Jackhu MSFT</name><uri>http://blogs.msdn.com/hxh8309_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Fsharp &amp; Excel: Calling Excel Math Functions From F# FSI</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/archive/2011/04/05/using-excel-math-functions-from-f-fsi.aspx" /><id>http://blogs.msdn.com/b/jackhu/archive/2011/04/05/using-excel-math-functions-from-f-fsi.aspx</id><published>2011-04-05T21:45:56Z</published><updated>2011-04-05T21:45:56Z</updated><content type="html">&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:88454a80-8e4f-448c-8901-b08da9a42b33" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/F%23" rel="tag"&gt;F#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Fsharp" rel="tag"&gt;Fsharp&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FSI" rel="tag"&gt;FSI&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Excel" rel="tag"&gt;Excel&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VS2010" rel="tag"&gt;VS2010&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font size="2"&gt;While I am working on compiling a list of .Net math libraries, I found a simple way to call Excel math library from F# FSI. In the following example, I will show how to use Excel’s Median, StDev and MInverse functions from F# scripting environment (FSI).&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;&lt;a&gt;     &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;   &lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3288.image_5F00_7D390209.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/8407.image_5F00_thumb_5F00_5545DCDD.png" width="503" height="772" /&gt;&lt;/a&gt;&lt;/blockquote&gt;  &lt;p&gt;&lt;font size="2"&gt;Software setup: VS2010 Sp1 with Office 2010 installed. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;There are few benefits of using Excel math libraries:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Correctness&lt;/strong&gt;: you can almost certain the correctness of the excel math functions. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Popularities&lt;/strong&gt;: most the financial excel guru knows one thing or another about the excel math functions. This allow them to pickup these familiar functions very quickly.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3"&gt;&lt;font size="2"&gt;&lt;strong&gt;IDE support: &lt;/strong&gt;Basic intellisense support is very important for the user. Just a little bit of UI hit can void breaking user’s code flow experience.&lt;/font&gt; &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6825.image_5F00_0D8453F6.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/4784.image_5F00_thumb_5F00_4D4E3A7B.png" width="617" height="216" /&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size="2"&gt;but, there are also issues:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Debugging:&lt;/strong&gt; When the math function is not working, debugging them is troublesome. you may get a comException gives no clue about the problem. A good way to debug these issues is to start with a small dataset, try it out inside the excel first.&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/4377.image_5F00_2613F146.png"&gt;&lt;img style="display: inline" title="image" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5861.image_5F00_thumb_5F00_17D57856.png" width="671" height="232" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size="2"&gt;Both F# and C# Code example @ &lt;/font&gt;&lt;a title="http://code.msdn.microsoft.com/Calling-Excel-Math-6b811836" href="http://code.msdn.microsoft.com/Calling-Excel-Math-6b811836"&gt;&lt;font size="2"&gt;http://code.msdn.microsoft.com/Calling-Excel-Math-6b811836&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;Happy Coding!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;-jack&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10150214" width="1" height="1"&gt;</content><author><name>Jackhu MSFT</name><uri>http://blogs.msdn.com/hxh8309_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>F# Code-First Development with Entity Framework 4.1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/archive/2011/04/01/f-code-first-development-with-entity-framework-4-1.aspx" /><id>http://blogs.msdn.com/b/jackhu/archive/2011/04/01/f-code-first-development-with-entity-framework-4-1.aspx</id><published>2011-04-01T13:33:00Z</published><updated>2011-04-01T13:33:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2"&gt;As the word “code-first” implies, the EF 4.1 offers a code centric data programming paradigm. From a coder’s point of view, it requires little effort to map a very clean object model to a database. This style of programming is idea for explorative, bottom-up kind fsharp programmers. Since EF 4 CTP4 release, there have already been many buzzes. The following two blogs have in-depth EF 4.1 feature overview. &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-model-amp-database-first-walkthrough.aspx"&gt;&lt;font size="2"&gt;EF 4.1 Model &amp;amp; Database First Walkthrough&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx"&gt;&lt;font size="2"&gt;Code-First Development with Entity Framework 4&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;In this blog, I demonstrate how to use EF 4.1 Code-first in Fsharp 2.0 to save a record into a SQL CE. I also provide workarounds for several practical issues may block fsharp programmers. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Step0: Install Software Packages &lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2dc5ddac-5a96-48b2-878d-b9f49d87569a&amp;amp;displaylang=en"&gt;&lt;font size="2"&gt;ADO.NET Entity Framework 4.1 Release Candidate&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=033cfb76-5382-44fb-bc7e-b3c8174832e2"&gt;&lt;font size="2"&gt;Microsoft SQL Server Compact 4.0&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/sqlservercompact/archive/2011/03/15/sql-server-compact-4-0-tooling-support-in-visual-studio-2010-sp1-and-visual-web-developer-express-2010-sp1.aspx"&gt;&lt;font size="2"&gt;SQL Server Compact 4.0 Tooling for VS2010&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Step1: Create a New F# Application&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3581.image001_5F00_34F5F271.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image001" border="0" alt="image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/2018.image001_5F00_thumb_5F00_4BD4C3ED.png" width="599" height="409" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;u&gt;Add Project references&lt;/u&gt;: Unlike C#, Fsharp compiler requires additional references from System.Data and System.Data.Entity to resolve base types inherited by EF 4.1 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1351.image002_5F00_20902CE6.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image002" border="0" alt="image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1263.image002_5F00_thumb_5F00_326CC0B3.png" width="402" height="350" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The EntityFramework.dll is under $\Program Files (x86)\Microsoft ADO.NET Entity Framework Feature CTP5\Binaries\EntityFramework.dll&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Step2: Create a Model&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In this example, I create a CLCars class. The class contains a single DbSet of Cars. In Car class I have a field of ID (serve as the primary key) and a field of Name.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6138.image003_5F00_593AD6F3.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image003" border="0" alt="image003" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/3007.image003_5F00_thumb_5F00_4AFC5E03.png" width="731" height="573" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In the driver code, I create a new CLCars database, added a Car to it and flush out to the database. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7711.image004_5F00_38B39741.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image004" border="0" alt="image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/8875.image004_5F00_thumb_5F00_787D7DC6.png" width="416" height="281" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Step3: Pointing to a Database&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;I love SQL CE 4.0, especially because user no longer needs to generate a primary key while adding a record. Yeah! In this example, I add an app.config file and embed the database connection string. I also make sure the connectionString Name property is the same as my DbContext class name, so that the EF 4.1 automatically generates a database at runtime.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7536.image005_5F00_0A5A1194.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image005" border="0" alt="image005" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7612.image005_5F00_thumb_5F00_631FC85E.png" width="693" height="289" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Step4: Run and Verify data&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;After build and run app, I use &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/sqlservercompact/archive/2011/03/15/sql-server-compact-4-0-tooling-support-in-visual-studio-2010-sp1-and-visual-web-developer-express-2010-sp1.aspx"&gt;&lt;font size="2"&gt;SQL Server Compact 4.0 Tooling for VS2010&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; to verify the database, the table and the data are added correctly.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1856.image006_5F00_37DB3157.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image006" border="0" alt="image006" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0383.image006_5F00_thumb_5F00_10A0E822.png" width="692" height="358" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;During the ad-hocking, I also encountered several issues. Here is how I work around them. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Issue#1: EF 4.1 does not support nested type; the model can NOT be used inside a Module or a Script&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;Trying to put the model inside a module, I got a run time exception: “The type 'Program+Car' is not a supported entity type.”&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/2425.image007_5F00_506ACEA7.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image007" border="0" alt="image007" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6237.image007_5F00_thumb_5F00_29308572.png" width="880" height="246" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;Digging into fsharp assembly using reflector, we can see the Fsharp script and module generate a nested-type which is not supported in EF 4.1 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1351.image008_5F00_68FA6BF7.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image008" border="0" alt="image008" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0777.image008_5F00_thumb_5F00_41C022C2.png" width="562" height="389" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The work around is to put the model code inside a namespace DataModel&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The VB module shares the same limitation. The work around in below example is to move the Car and CLCars class outside the Module1. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7026.image009_5F00_4FC2F269.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7610.image009_5F00_086D9C77.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image009" border="0" alt="image009" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6052.image009_5F00_thumb_5F00_4C532ED3.png" width="850" height="538" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Issue#2: Property initialization on DBContext class need to use [&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee353743.aspx"&gt;&lt;b&gt;&lt;font size="2"&gt;DefaultValue&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;font size="2"&gt;&amp;gt;] attribute with &lt;/font&gt;&lt;/b&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd469494.aspx"&gt;&lt;b&gt;&lt;font size="2"&gt;Explicit Fields&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;During EF DbContext construction, it will reflect on all its properties and initialized them with database mapping values. After base construction, if the inhered Fsharp class calls its constructor with property initialization, it will override the property value that base class already initialized. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In the following example, the DbContext constructor will initialize m_cars to a DbSet&amp;lt;Car&amp;gt; mapping value, but the inhered CLCars constructor will reinitialize n_cars to NULL. This could cause a NullReferenceException at runtime. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/0741.image010_5F00_61335341.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/5554.image010_5F00_39F90A0C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image010" border="0" alt="image010" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/1777.image010_5F00_thumb_5F00_79D44E96.png" width="570" height="188" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/4466.image011_5F00_79C2F091.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/7026.image011_5F00_1971CA5A.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image011" border="0" alt="image011" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-28-70-metablogapi/6064.image011_5F00_thumb_5F00_2B5FBC2C.png" width="871" height="414" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;EF 4.1 code-first is a great tool for F# 2.0 data programming. As Fsharp 3.0 features become clearer in the next few months, I am supper exited and feel good about them. I expect Fsharp 3.0 will take these experiences to the next level. Happy coding!&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Code example is published @ &lt;a title="http://code.msdn.microsoft.com/F-Code-First-Development-326dede1" href="http://code.msdn.microsoft.com/F-Code-First-Development-326dede1"&gt;http://code.msdn.microsoft.com/F-Code-First-Development-326dede1&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10148993" width="1" height="1"&gt;</content><author><name>Jackhu MSFT</name><uri>http://blogs.msdn.com/hxh8309_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Testing out MSDN Blog using Window Live Writer</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/jackhu/archive/2009/09/02/testing-out-msdn-blog-using-window-live-writer.aspx" /><id>http://blogs.msdn.com/b/jackhu/archive/2009/09/02/testing-out-msdn-blog-using-window-live-writer.aspx</id><published>2009-09-02T23:51:00Z</published><updated>2009-09-02T23:51:00Z</updated><content type="html">&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b1a7988d-38d6-4e1e-a8f1-8b14d3af6a27 class=wlWriterEditableSmartContent&gt;Technorati Tags: &lt;A href="http://technorati.com/tags/live+writer" rel=tag mce_href="http://technorati.com/tags/live+writer"&gt;live writer&lt;/A&gt;,&lt;A href="http://technorati.com/tags/Visual+Studio" rel=tag mce_href="http://technorati.com/tags/Visual+Studio"&gt;Visual Studio&lt;/A&gt;,&lt;A href="http://technorati.com/tags/Pasting+Tool" rel=tag mce_href="http://technorati.com/tags/Pasting+Tool"&gt;Pasting Tool&lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;trying out &lt;A href="http://get.live.com/writer/overview" mce_href="http://get.live.com/writer/overview"&gt;Windows Live Writer&lt;/A&gt; for Blogging. Here are some screen shots&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=image src="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_thumb.png" width=396 height=92 mce_src="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=image src="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_thumb_2.png" width=155 height=244 mce_src="http://blogs.msdn.com/blogfiles/jackhus_blog/WindowsLiveWriter/TestingoutMSDNBlog_A18F/image_thumb_2.png"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I installed Visual &lt;A href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&amp;amp;l=8" mce_href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&amp;amp;l=8"&gt;Studio Pasting tool&lt;/A&gt;, here I go. it works. &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Module &lt;/SPAN&gt;Module1

    &lt;SPAN style="COLOR: blue"&gt;Sub &lt;/SPAN&gt;Main()

    &lt;SPAN style="COLOR: blue"&gt;End Sub

End Module
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9890575" width="1" height="1"&gt;</content><author><name>Jackhu MSFT</name><uri>http://blogs.msdn.com/hxh8309_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Visual Studio" scheme="http://blogs.msdn.com/b/jackhu/archive/tags/Visual+Studio/" /></entry></feed>