<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Darkroastjava&#039;s Public Notebook</title>
	<atom:link href="http://darkroastjava.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://darkroastjava.wordpress.com</link>
	<description>Noteworthy notes from my daily life with computers</description>
	<lastBuildDate>Thu, 15 Dec 2011 19:29:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='darkroastjava.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Darkroastjava&#039;s Public Notebook</title>
		<link>http://darkroastjava.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://darkroastjava.wordpress.com/osd.xml" title="Darkroastjava&#039;s Public Notebook" />
	<atom:link rel='hub' href='http://darkroastjava.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using Eric Hynds&#8217; multiselect with knockout</title>
		<link>http://darkroastjava.wordpress.com/2011/11/17/using-eric-hynds-multiselect-with-knockout/</link>
		<comments>http://darkroastjava.wordpress.com/2011/11/17/using-eric-hynds-multiselect-with-knockout/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 11:52:58 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[erichynds]]></category>
		<category><![CDATA[jquery-ui-multiselect]]></category>
		<category><![CDATA[knockout]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=123</guid>
		<description><![CDATA[Eric Hynds has crafted an awesome enhanced multiselection dropdown as a jQuery UI widget which enhances a normal  list. Unfortunately, as many jQuery UI widgets, it manipulates the original HTML when being applied, which renders the normal use of the  knockout data-bindings in-effective. However, there is good news: With a little trick, we can make use of the knockout bindings for the original select list.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=123&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Eric Hynds has crafted an <a href="http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/">awesome enhanced multiselection dropdown</a> as a jQuery UI widget which enhances a normal &lt;select multiple&gt; list. Unfortunately, as many jQuery UI widgets, it manipulates the original HTML when being applied, which renders the normal use of the &lt;select&gt; knockout data-bindings in-effective.</p>
<p>Classical knockout binding for multiselect dropdowns:</p>
<pre>&lt;select multiple="multiple" data-bind="
    options: data.selectList,
    optionsText: 'Name',
    optionsValue: 'Value',
    selectedOptions: data.selectedOptions"&gt;</pre>
<p>This select HTML element is replaced by the UI widget. The user then interacts with a set of buttons, divs, checkboxes, and more.</p>
<p>However, the good news to that is that the UI widget is designed such as to simply <em>hide</em> rather than removing the original element. Even better, when the user selects items in the UI widget, they also get selected in the original &lt;select&gt; element. Therefore with a little trick, we can make use of the knockout bindings for the original select list.</p>
<p>Simply add &#8220;multiselect: true&#8221; to the data-bind attribute:</p>
<pre>&lt;select multiple="multiple" data-bind="
    options: data.selectList,
    optionsText: 'Name',
    optionsValue: 'Value',
    selectedOptions: data.selectedOptions,
    multiselect: true"&gt;</pre>
<p>We then define a new custom knockout binding called &#8220;multiselect&#8221;:</p>
<pre>ko.bindingHandlers.multiselect = {
    init: function (element) {
        $(element).bind("multiselectclick", function () {
            $.data(element, 'donotrefresh', true);
        });
    },
    update: function (element) {
        var doNotRefresh = !!($.data(element, 'donotrefresh'));
        if (!doNotRefresh) { $(element).multiselect("refresh"); }
        $.data(element, 'donotrefresh', false);
    }
};</pre>
<p>The core part to this is the $(element).multiselect(&#8220;refresh&#8221;), which causes the UI widget to re-build its select list based on the hidden original &lt;select&gt; list, which in turn is updated by knockout based on the model.</p>
<p>The other direction (view -&gt; model) is covered by the UI widget itself: The widget updates the hidden select list, knockout consequently updates the model. There is one minor caveat though: The model update in turn triggers the &#8220;update&#8221; method of our custom binding. In this case, if we tried and called &#8220;refresh&#8221; on the UI widget, an error would occur. In order to prevent that, we hook into the click event, set a flag called &#8220;donotrefresh&#8221; and check it before calling &#8220;refresh&#8221;.</p>
<p>This way, the &#8220;refresh&#8221; method on the UI widget is only called if the model was changed from the &#8220;outside&#8221;, yet is <em>not</em> called if the model was changed due to user interaction with the widget.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=123&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2011/11/17/using-eric-hynds-multiselect-with-knockout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Two Useful Classes When Using Excel COM Interop</title>
		<link>http://darkroastjava.wordpress.com/2010/09/03/two-useful-classes-when-using-excel-com-interop/</link>
		<comments>http://darkroastjava.wordpress.com/2010/09/03/two-useful-classes-when-using-excel-com-interop/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 16:48:42 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[MS Office]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[interop]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=86</guid>
		<description><![CDATA[There are two known problems when working with Excel Interop.

   1. After having used Excel and shut down your application, an Excel process still "hangs" in background.
   2. When your Excel installation is English (en-US) only, but your Windows is configured for a different language (e.g. de-DE), some calls to the Interop fail with a COMException.

Luckily there are also workarounds for this problem which you can easily find when googling for them. Two classes have been handy for me to encapsulate these workarounds.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=86&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are two known problems when working with Excel Interop.</p>
<ol>
<li>After having used Excel and shut down your application, an Excel process still &#8220;hangs&#8221; in background.</li>
<li>When your Excel installation is English (en-US) only, but your Windows is configured for a different language (e.g. de-DE), some calls to the Interop fail with a COMException.</li>
</ol>
<p>Luckily there are also workarounds for this problem which you can easily find when googling for them. The following classes have been handy for me to encapsulate these workarounds. Both providing <strong>IDisposable</strong>.</p>
<p>This way, you can use them as follows:</p>
<pre>Excel.Workbooks myWorkbooks
        = myExcelApplication.Workbooks;
Excel.Workbook myWorkbook;

using (new Disposer(myWorkbooks))
    using (new EnUsCulture())
        myWorkbook = myWorkbooks.Open(fileName, [...]);
</pre>
<p>The Disposer takes care of properly disposing of the COM object. The EnUsCulture switches the current thread&#8217;s culture to en-US right on creation. On Dispose(), it switches the culture back to what it was before. Using &#8220;using&#8221; you make sure the thread&#8217;s culture is switched back even if an error occurs.</p>
<p><strong>Disposer:</strong></p>
<pre>    public class Disposer : IDisposable
    {
        private object _comObject;

        public Disposer(object comObject)
        {
            _comObject = comObject;
        }

        public void Dispose()
        {
            if (_comObject != null)
            {
                Marshal.ReleaseComObject(_comObject);
                _comObject = null;
                GC.Collect();
            }
        }
    }
</pre>
<p>&nbsp;<br />
<strong>EnUsCulture:</strong></p>
<pre>    public class EnUsCulture : IDisposable
    {
        private CultureInfo _oldCulture;

        public EnUsCulture()
        {
            if (Thread.CurrentThread.CurrentCulture
                .Equals(new CultureInfo("en-US")))
            {
                _oldCulture = null;
            }
            else
            {
                _oldCulture = Thread.CurrentThread.CurrentCulture;
                Thread.CurrentThread.CurrentCulture
                    = new CultureInfo("en-US");
            }
        }

        public void Dispose()
        {
            if (_oldCulture != null)
                Thread.CurrentThread.CurrentCulture = _oldCulture;
        }
    }
</pre>
<p>Note that the Dispose() method only resets the thread&#8217;s culture if it wasn&#8217;t already en-US before. This is to prevent the following situation:</p>
<pre>    EnUsCulture c1 = new EnUsCulture(); // switch from de-DE to en-US
    EnUsCulture c2 = new EnUsCulture(); // switch from en-US to en-US
    c1.Dispose(); // switch back to de-DE
    c2.Dispose(); // switch back to en-US
</pre>
<p>The thread would end up with the en-US culture if c2 is disposed after c1. To prevent that, we make c2 notice on its creation that the culture has already been switched before, so it won&#8217;t have any effect at all:</p>
<pre>    EnUsCulture c1 = new EnUsCulture(); // switch from de-DE to en-US
    EnUsCulture c2 = new EnUsCulture(); // no effect
    c1.Dispose(); // switch back to de-DE
    c2.Dispose(); // no effect
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=86&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2010/09/03/two-useful-classes-when-using-excel-com-interop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Calling an Oracle Stored Proc with CLOB from System.Data.OracleClient</title>
		<link>http://darkroastjava.wordpress.com/2010/08/25/calling-an-oracle-stored-proc-with-clob-from-system-data-oracleclient/</link>
		<comments>http://darkroastjava.wordpress.com/2010/08/25/calling-an-oracle-stored-proc-with-clob-from-system-data-oracleclient/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:58:34 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LOBs]]></category>
		<category><![CDATA[Stored-Procedures]]></category>
		<category><![CDATA[System.Data.OracleClient]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=83</guid>
		<description><![CDATA[You might have stumbled upon this and it might have made you tear your hair just as it did to me. When you try to call a stored procedure from .NET using System.Data.OracleClient, you won't be able to pass a CLOB parameter value &#62; 4000 Bytes. In fact, the solution, or rather workaround, is quite simple!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=83&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You might have stumbled upon this and it might have made you tear your hair just as it did to me. When you try to call a stored procedure from .NET using System.Data.OracleClient, you won&#8217;t be able to pass a CLOB parameter value &gt; 4000 Bytes.</p>
<p>I got the following error message when trying to do so:</p>
<p><strong>ORA-01460 &#8211; unimplemented or unreasonable conversion requested</strong></p>
<p>This issue has been reported in lots of places on the web already. Unfortunately I wasn&#8217;t able to find the right hint to remedy this problem &#8211; <strong>until a fellow employee of mine saved my day!</strong></p>
<p>In fact, the solution, or rather workaround, is quite simple and can be found on <a href="http://henbo.spaces.live.com/blog/cns!2E073207A544E12!332.entry">http://henbo.spaces.live.com/blog/cns!2E073207A544E12!332.entry</a>:</p>
<blockquote><p>Set the System.Data.OracleClient.OracleParameter.OracleDbType property to System.Data.OracleClient.OracleType.Clob.<br />
- AND -<br />
Set the parameter value when BeginTransaction has already been called on the DbConnection.</p></blockquote>
<p>Don&#8217;t let the &#8220;OracleDbType&#8221; (implying that the guy speaks about Oracle&#8217;s version of the client) derange you: The trick works for the Microsoft client just as well!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=83&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2010/08/25/calling-an-oracle-stored-proc-with-clob-from-system-data-oracleclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating an excel-like grid for ASP.NET</title>
		<link>http://darkroastjava.wordpress.com/2010/04/28/creating-an-excel-like-grid-for-asp-net/</link>
		<comments>http://darkroastjava.wordpress.com/2010/04/28/creating-an-excel-like-grid-for-asp-net/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 09:21:26 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[gridview]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=59</guid>
		<description><![CDATA[I have been searching around for a while because I was in the need for an ASP.NET control similar to asp:GridView, but with following huge differences: All rows and their cells must be in edit mode all the time. You should be able to navigate through the cells using the arrow keys. You should be able to copy-paste multiple cells at a time from Excel into the grid. Read this post to find how I managed to solve that (more or less)...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=59&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been searching around for a while because I was in the need for an ASP.NET control similar to asp:GridView, but with following huge differences:</p>
<ul>
<li><strong>All rows and their cells must be in edit mode all the time.</strong> On postback (e.g. using a &#8220;Save&#8221; button), the data must be written back to the datasource.<br />
In GridView, in contrast, you need to hit a row&#8217;s  &#8220;Edit&#8221; to turn the row into edit mode, and hit the row&#8217;s &#8220;Update&#8221; button to save its changes to the datasource.</li>
<li><strong>You should be able to navigate through the cells using the arrow keys.</strong><br />
In GridView, this doesn&#8217;t even apply since only one row at a time is in edit mode.</li>
<li><strong>You should be able to copy-paste multiple cells at a time from Excel into the grid.</strong> If you copy 3&#215;2 cells in Excel, paste the cursor on a cell in the grid and Hit Ctrl+V, the cell values must be spread over the cells below and right from the selected cell.<br />
In GridView, in contrast, all cell values are pasted as a concatenated string into the selected cell.</li>
<li><strong>The grid should work in IE, Firefox and possibly other browsers. </strong>Well, I have to admit that my solution presented here <em><strong>only works for IE so far</strong></em>, but it should be feasible to extend the code for Firefox and Safari.</li>
</ul>
<p>Having searched for quite a long time, the only really interesting thing I found was Srikanth Reddy&#8217;s Blog <em>&#8220;Creating an Excel Like GridView&#8221;</em>. His solution was really close to what I needed, and I want to thank Srikanth in this place for sharing his work. The original blog is not available anymore, but there now is a copy of Srikanth&#8217;s post at: <a href="http://rschandrastechblog.blogspot.com/2010/11/client-gridview-iii-httpwwwaspboycomcat.html">http://rschandrastechblog.blogspot.com/2010/11/client-gridview-iii-httpwwwaspboycomcat.html</a>. Yet I decided to post the whole of my code (which is mostly to be attributed to Srikanth) in this blog.</p>
<p>His version didn&#8217;t support pasting cells either, but it was quite easy to extend it such that this is now supported, too.</p>
<p>Apart from the new features, I also changed the structure of the code a bit. Let&#8217;s have closer look at the new code:</p>
<p><strong>1. General Methods for Navigation</strong></p>
<ul>
<li>There are 4 methods &#8220;getLeftNeighbor&#8221;, &#8220;getRightNeighbor&#8221;, &#8220;getAboveNeighbor&#8221; and &#8220;getBelowNeighbor&#8221;. They find and return the cell that is found right next to the given one.</li>
<li>The code to actually select a certain cell is found in &#8220;NavigateToCell&#8221;.</li>
<li>The code to format the previously selected and newly selected cells is found in the onfocus event. It&#8217;s the best place to do the formatting becausee it will take place no matter whether you click a cell, or use the arrows, tab or shift-tab to navigate to a neighbored cell.</li>
</ul>
<p><strong>2. Intercepting the paste event and spreading multiple values over the grid</strong></p>
<p>When the user copies multiple cells from an Excel sheet and pastes it in a cell, you&#8217;d expect the values to be spread over multiple rows and columns, just like they would in Excel. However, the default behavior of a HTML textbox is to regard the string as a single value and paste everything in that particular text box.</p>
<p>Suppose that the user copies the following 3 x 2 cells from excel:</p>
<table style="border-collapse:collapse;border:1pt solid black;" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td style="border:1pt solid black;">a</td>
<td style="border:1pt solid black;">b</td>
</tr>
<tr>
<td style="border:1pt solid black;">c</td>
<td style="border:1pt solid black;">d</td>
</tr>
<tr>
<td style="border:1pt solid black;">e</td>
<td style="border:1pt solid black;">f</td>
</tr>
</tbody>
</table>
<p>These values are represented in the clipboard as a text formatted as &#8220;<strong>a</strong><span style="color:#888888;">\t</span><strong>b</strong><span style="color:#888888;">\r\n</span><strong>c</strong><span style="color:#888888;">\t</span><strong>d</strong><span style="color:#888888;">\r\n</span><strong>e</strong><span style="color:#888888;">\t</span><strong>f</strong><span style="color:#888888;">\r\n</span>&#8220;.</p>
<p>In order to have these values be spread over the appropriate text boxes we need to intercept the paste event, split the clipboard text into a 2-dimensional array of values and then reuse our get-neighbor methods to find the cells below and right from the selected cell:</p>
<pre>    function tupelizeText(text) {
        text = text.replace(/\r\n/g, '\n');
        text = text.replace(/\r/g, '\n');

        var tmparray = text.split("\n");
        var result = new Array();

        for (var i = 0; i &lt; tmparray.length - 1; i++) {
            result[i] = tmparray[i].split('\t');
        }

        return result;
    }

    function txt_paste(element) {
        var strPasteData = window.clipboardData.getData("Text");
        var values = tupelizeText(strPasteData);
        var leftAreaBorderCell = curCell;
        for (i = 0; i &lt; values.length; i++) {
            var pasteCell = leftAreaBorderCell;
            for (j = 0; j &lt; values[i].length; j++) {
                pasteCell.firstChild.innerText = values[i][j];

                if (getRightNeighbor(pasteCell) != null)
                    pasteCell = getRightNeighbor(pasteCell);
                else
                    break;
            }

            if (getLowerNeighbor(leftAreaBorderCell) != null)
                leftAreaBorderCell = getLowerNeighbor(leftAreaBorderCell);
            else
                break;
        }

        return false;
    }</pre>
<p>Imagine the special case where the selection in our grid is placed such that not all values from the clipboard can be pasted. To cover this we always check whether there is another row below or another column at the right. If not, we break that particular iteration.</p>
<p>To register the onpaste event I added a line in the C# code. I also added the onfocus event and a css class:</p>
<pre>txt.Attributes.Add("onfocus", "txt_focus(this)");
txt.Attributes.Add("onpaste", "return txt_paste(this)");
txt.Attributes.Add("class", "SpreadsheetView-TextBox");</pre>
<p>So much about some particularities. I don&#8217;t (yet) take the effort to explain the parts that Srikanth already introduced&#8230; I trust in your own development skills <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  So as promised, the full code below.</p>
<p>I hope this inspires you. If there are things unclear, please let me know! And again, much credits to Srikanth Reddy for his post. If you improve or extend this code (e.g. make it work in Firefox and/or Safari), please let me know! <strong>If you publish this code or an adaption of it, please attribute and put a link on this blog post.</strong></p>
<h2><strong>SpreadsheetView.ascx<br />
</strong></h2>
<pre>&lt;%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="SpreadsheetView.ascx.cs"
Inherits="WebBased.SpreadsheetView" %&gt;

&lt;div id="divSpreadsheetView" onkeydown="divSpreadsheetView_keydown(event)"&gt;
&lt;table ID="tblTable" cellspacing="0" cellpadding="0" runat="server"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="text" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="text" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;script language="javascript" type="text/javascript"&gt;

var curCell = null;

// Called when user clicks on the textbox of a SpreadsheetView cell, selects the cell.
function txt_focus(element) {
if (curCell != null) curCell.className = "SpreadsheetView-Cell";
curCell = element.parentNode;
curCell.className = "SpreadsheetView-SelectedCell";
curCell.firstChild.select();
}

// Returns the cell left from the given cell, or null if the given cell is the left-most.
function getLeftNeighbor(cell) {
if (cell.previousSibling != null) {
return cell.previousSibling;
} else {
return null;
}
}

// Returns the cell right from the given cell, or null if the given cell is the right-most.
function getRightNeighbor(cell) {
if (cell.nextSibling != null) {
return cell.nextSibling;
} else {
return null;
}
}

// Returns the cell above the given cell, or null if the given cell is the top-most (excluding header).
function getUpperNeighbor(cell) {
if (cell.parentNode.previousSibling.rowIndex != 0) {
return cell.parentNode.previousSibling.children[cell.cellIndex];
} else {
return null;
}
}

// Returns the cell below the given cell, or null if the given cell is the bottom-most.
function getLowerNeighbor(cell) {
if (cell.parentNode.nextSibling != null) {
return cell.parentNode.nextSibling.children[cell.cellIndex];
} else {
return null;
}
}

// Helper method to select a cell.
function NavigateToCell(cell) {
cell.firstChild.focus();
}

// Called when user hits an arrow key while focus is on the SpreadsheetView, selects a neighbor cell.
function divSpreadsheetView_keydown(event) {
var keyCode;

if (!event) event = window.event;

if (event.which) {
keyCode = event.which;
} else if (event.keyCode) {
keyCode = event.keyCode;
}

if (keyCode == 37 &amp;&amp; getLeftNeighbor(curCell) != null) {
NavigateToCell(getLeftNeighbor(curCell));
}
else if (keyCode == 38 &amp;&amp; getUpperNeighbor(curCell) != null) {
NavigateToCell(getUpperNeighbor(curCell));
}
else if (keyCode == 39 &amp;&amp; getRightNeighbor(curCell) != null) {
NavigateToCell(getRightNeighbor(curCell));
}
else if (keyCode == 40 &amp;&amp; getLowerNeighbor(curCell) != null) {
NavigateToCell(getLowerNeighbor(curCell));
}
}

// Register keydown event.
//document.getElementById("divSpreadsheetView").onkeydown = divSpreadsheetView_keydown;

// Parses a string containing a copy of multiple excel cells and returns the cells in an array of arrays.
function tupelizeText(text) {
text = text.replace(/\r\n/g, '\n');
text = text.replace(/\r/g, '\n');

var tmparray = text.split("\n");

var result = new Array();

// text copied from excel always ends with a \n too much, so ignore last element.
for (var i = 0; i &lt; tmparray.length - 1; i++) {
result[i] = tmparray[i].split('\t');
}

return result;
}

// Called when user pasts text in a textbox. If consists of multiple cells, spreads the values among textboxes.
function txt_paste(element) {
var strPasteData = window.clipboardData.getData("Text");

if (curCell == element.parentNode) {
var values = tupelizeText(strPasteData);

// this variable will iterate down the rows but always be the left-most of the area to paste into
var leftAreaBorderCell = curCell;

for (i = 0; i &lt; values.length; i++) {

// this variable will iterate through all cells of the row
var pasteCell = leftAreaBorderCell;

for (j = 0; j &lt; values[i].length; j++) {
pasteCell.firstChild.innerText = values[i][j];

if (getRightNeighbor(pasteCell) != null) {
pasteCell = getRightNeighbor(pasteCell);
} else {
break;
}
}

if (getLowerNeighbor(leftAreaBorderCell) != null) {
leftAreaBorderCell = getLowerNeighbor(leftAreaBorderCell);
} else {
break;
}
}

return false;
}

return true;
}

&lt;/script&gt;</pre>
<h2>SpreadsheetView.ascx.cs</h2>
<pre>using System;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI;

namespace WebBased
{
public partial class SpreadsheetView : System.Web.UI.UserControl
{
public DataTable Model { get; set; }

public override void DataBind()
{
tblTable.Rows.Clear();
GenerateHeaderRow(tblTable, Model);

for (int iRow = 0; iRow &lt; Model.Rows.Count; iRow++)
{
GenerateDataRow(tblTable, iRow, Model);
}
}

protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
// Read data from UI back into DataTable
for (int iRow = 1; iRow &lt; tblTable.Rows.Count; iRow++)
{
for (int iCol = 0; iCol &lt; tblTable.Rows[iRow].Cells.Count; iCol++)
{
HtmlTableCell cell = tblTable.Rows[iRow].Cells[iCol];
TextBox txt = cell.Controls[0] as TextBox;
Model.Rows[iRow - 1][iCol] = txt.Text;
}
}
}
}

private static void GenerateDataRow(HtmlTable tblTable, int iRow, DataTable dtDataTable)
{
HtmlTableRow row = new HtmlTableRow();
tblTable.Rows.Add(row);
row.Attributes.Add("class", "SpreadsheetView-Row");

for (int iCol = 0; iCol &lt; dtDataTable.Columns.Count; iCol++)
{
HtmlTableCell cell = new HtmlTableCell();
row.Cells.Add(cell);
cell.Attributes.Add("class", "SpreadsheetView-Cell");

TextBox txt = new TextBox();
txt.ID = String.Format("txt_{0}_{1}", iRow, iCol);
txt.Width = Unit.Percentage(100);
txt.Text = dtDataTable.Rows[iRow][iCol].ToString();
txt.Attributes.Add("onfocus", "txt_focus(this)");
txt.Attributes.Add("onpaste", "return txt_paste(this)");
txt.Attributes.Add("class", "SpreadsheetView-TextBox");

cell.Controls.Add(txt);
}
}

private static void GenerateHeaderRow(HtmlTable tblTable, DataTable dtDataTable)
{
HtmlTableRow rowHeader = new HtmlTableRow();
tblTable.Rows.Add(rowHeader);
rowHeader.Attributes.Add("class", "SpreadsheetView-HeaderRow");

for (int iCol = 0; iCol &lt; dtDataTable.Columns.Count; iCol++)
{
HtmlTableCell cellHeader = new HtmlTableCell("th");
rowHeader.Cells.Add(cellHeader);
cellHeader.Attributes.Add("class", "SpreadsheetView-HeaderCell");

cellHeader.InnerText = dtDataTable.Columns[iCol].Caption;
}
}

}
}</pre>
<h2>Putting it into Action</h2>
<p>To use the control, just add a tag to your asp.net code:</p>
<pre>&lt;%@ Register TagPrefix="x" TagName="SpreadsheetView" Src="~/SpreadsheetView.ascx" %&gt;

&lt;x:SpreadsheetView ID="SpreadsheetView1" runat="server"/&gt;</pre>
<p>and feed it with an empty grid of your required size:</p>
<pre>DataTable dataTable = new DataTable();

dataTable.Columns.Add("A");
dataTable.Columns.Add("B");
dataTable.Columns.Add("C");
dataTable.Columns.Add("D");

dataTable.Rows.Add(new string[] { "", "", "", "" });
dataTable.Rows.Add(new string[] { "", "", "", "" });
dataTable.Rows.Add(new string[] { "", "", "", "" });
dataTable.Rows.Add(new string[] { "", "", "", "" });
dataTable.Rows.Add(new string[] { "", "", "", "" });

SpreadsheetView1.Model = dataTable;
SpreadsheetView1.DataBind();</pre>
<p>For completeness, these are some of the resources I found before trying it myself:</p>
<ul>
<li><a href="http://aspnetrealworldcontr.codeplex.com/" target="_blank">http://aspnetrealworldcontr.codeplex.com/</a><br />
(the only &#8220;excel-like&#8221; thing is frozen headers&#8230;)</li>
<li><a href="http://www.nitobi.com/products/grid/copypaste/" target="_blank">http://www.nitobi.com/products/grid/copypaste/</a><br />
Allows for copy-paste! But is commercial and very buggy.</li>
<li><a href="http://stackoverflow.com/questions/587120/good-asp-net-excel-like-grid-control" target="_blank">http://stackoverflow.com/questions/587120/good-asp-net-excel-like-grid-control</a><br />
Thread on stack overflow to this question.</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=982B0359-0A86-4FB2-A7EE-5F3A499515DD&amp;displaylang=EN" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyID=982B0359-0A86-4FB2-A7EE-5F3A499515DD&amp;displaylang=EN</a><br />
(activex object)</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=59&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2010/04/28/creating-an-excel-like-grid-for-asp-net/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint traps when developing for multiple languages</title>
		<link>http://darkroastjava.wordpress.com/2010/03/09/sharepoint-tras-when-developing-for-multiple-languages/</link>
		<comments>http://darkroastjava.wordpress.com/2010/03/09/sharepoint-tras-when-developing-for-multiple-languages/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 07:47:31 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=50</guid>
		<description><![CDATA[I've just been programming some SharePoint extensions for a company running a german SharePoint (MOSS 2007) site, and I was astonished/amazed/annoyed by the fact that some parts of the SharePoint object model are heavily language-dependent. I mean such things as that the "official", compile-time, property "Title" of a ListItem does simply not work in a german site collection. This is why I will list some points what you should beware of if you want your thing to run in other languages than 1033.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=50&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been programming some SharePoint extensions for a company running a german SharePoint (MOSS 2007) site, and I was astonished/amazed/annoyed by the fact that some parts of the SharePoint object model are heavily language-dependent. I mean such things as that the &#8220;official&#8221;, compile-time, property &#8220;Title&#8221; of a ListItem does simply not work in a german site collection, because it relies on the display name of the corresponding column.</p>
<p>This is why I will list some points what you should beware of if you want your thing to run in other languages than 1033:</p>
<ul>
<li><strong>Do not use ListItem.Title</strong> &#8211; as mentioned above. If you use ListItem.Title, the property (IMHO) searches the ListItem for a field whose <em>display name</em> is &#8220;Title&#8221; and returns its value. I used that to access the &#8220;TemplateTitle&#8221; of a site template in the site templates gallery. In a german environment that column has &#8220;Tit<strong><em>el</em></strong>&#8221; as its display-name, thus the property &#8220;Title&#8221; throws a RuntimeException. Instead, I used <strong>ListItem.GetFormattedValue(&#8220;TemplateTitle&#8221;),</strong> which is the internal column name which does not depend on language and cannot be changed by a user.</li>
<li><strong>Do not use &#8220;Full Control&#8221;, &#8220;Contribute&#8221;, &#8230; to refer to certain role definitions</strong> &#8211; I tried that, already sensing it might lead to troubles in a german environment. Of course, the role definitions are called &#8220;Vollzugriff&#8221;, etc. Thus, if you want to get a RoleDefinition object for &#8220;Full Control&#8221; / &#8220;Vollzugriff&#8221;, beware of using <strong>Web.RoleDefinitions["Full Control"]</strong>. Instead, use the SPRoleType constants:  <strong>Web.RoleDefinitions.GetByType(SPRoleType.Administrator)</strong></li>
<li><strong>Do not use ~site/Pages/default.aspx as a hardcoded string </strong>- You guess it: In a german site collection, the thing is called <strong>~site</strong><strong>/Seiten/default.aspx</strong>. Besides, noone prevents a user from changing that URL in the document library&#8217;s settings. In WSS3, the default.aspx does not even reside in a document library but in the root path of the subsite: <strong>~site</strong><strong>/default.aspx</strong>. I have to admit that I&#8217;ve not yet discovered the correct way to get a site&#8217;s default.aspx page.</li>
<li>I will expand this post as soon as i&#8217;ll stumble over another language hurdle.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=50&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2010/03/09/sharepoint-tras-when-developing-for-multiple-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Having Word update all fields at once</title>
		<link>http://darkroastjava.wordpress.com/2009/09/16/having-word-update-all-fields-at-once/</link>
		<comments>http://darkroastjava.wordpress.com/2009/09/16/having-word-update-all-fields-at-once/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 09:36:00 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[MS Office]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Fields]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Update Fields]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=31</guid>
		<description><![CDATA[Who out there has not encountered this nasty issue yet? I have a Word Document with fields in it, some in the header, some in the footer, some in the text... If I want to update all fields, there is no option to do that. You have to "select all", then hit F9 or open the context menu and select "Update Fields". This must be done for the header, footer and inline text separately. If you have various header definitions, you need to do that for each section. On my research I found two helpful tips to get rid of that issue...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=31&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Who out there has not encountered this nasty issue yet? I have a Word Document with fields in it, some in the header, some in the footer, some in the text&#8230; If I want to update all fields, there is no option to do that. You have to &#8220;select all&#8221;, then hit F9 or open the context menu and select &#8220;Update Fields&#8221;. This must be done for the header, footer and inline text separately. If you have various header definitions, you need to do that for each section&#8230;</p>
<p>On my research I found two helpful tips to get rid of that issue:</p>
<ul>
<li><strong>Set the word option to update all fields when printing.</strong><br />
(<a href="http://tortoiseshell.net/coffeebreak/blog/index.php/139/word-2007-make-updating-fields-easier.html" target="_blank">http://tortoiseshell.net/coffeebreak/blog/index.php/139/word-2007-make-updating-fields-easier.html</a>) &#8211; Once you set that option, you can update the fields by printing the document. I tried to use print preview as stated in the referenced blog, however that did not work for me in Word 2007. Anyway, if you have PDFCreator installed, you can use the print command without wasting paper and toner.</li>
<li><strong>Create a simple makro and a button to invoke it</strong><br />
(<a href="http://www.devblog.com/2007/12/update-all-fields-in-word-document.html" target="_blank">http://www.devblog.com/2007/12/update-all-fields-in-word-document.html</a>) &#8211; Save the makro in your Normal.dot, so you have the functionality in all your future documents. Have a look to Curtis&#8217; blog at the referenced URL, especially to <em>izogi&#8217;s comment</em>, since Curtis&#8217; orginial source code seems not to work in all cases.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=31&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2009/09/16/having-word-update-all-fields-at-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Enterprise Architect: Beware of for-each loops!</title>
		<link>http://darkroastjava.wordpress.com/2009/09/01/enterprise-architect-beware-of-for-each-loops/</link>
		<comments>http://darkroastjava.wordpress.com/2009/09/01/enterprise-architect-beware-of-for-each-loops/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 15:32:11 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Enterprise Architect]]></category>
		<category><![CDATA[Add-in]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[EA]]></category>
		<category><![CDATA[Sparx]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=18</guid>
		<description><![CDATA[While developing a C#-based add-in for Sparx Enterprise Architect, I just encountered a very nasty bug: System.AccessViolationException: Attempted to read or write protected memory. And this is the "evil" code: foreach (EA.Element element in package.Elements). After some googling I found that the translation of "foreach" to a COM operation fails in that specific case. Use the following workaround to get rid of the issue...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=18&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While developing a C#-based add-in for Sparx Enterprise Architect, I just encountered a very nasty bug:</p>
<blockquote><p>System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.<br />
at VariantClear(tagVARIANT* pvarg)<br />
at System.Runtime.InteropServices.CustomMarshalers<br />
.EnumeratorViewOfEnumVariant.MoveNext()<br />
at Foo.bar()</p></blockquote>
<p>The exception only arises when I deploy the add-in as a compiled (Release build) DLL. When debugging the add-in from within Visual Studio, it worked fine. And this is the &#8220;evil&#8221; code in Foo.bar():</p>
<pre>foreach (EA.Element element in package.Elements)
{
    doSomething();
}</pre>
<p>A second glance to the exception stack trace and a reading of <a href="http://social.msdn.microsoft.com/Forums/en-US/clr/thread/9a4e8bbb-efbd-4a90-9549-4e1795198800" target="_blank">this thread</a> made me clear that the translation of &#8220;foreach&#8221; to a COM operation fails in that specific case. Use the following workaround to get rid of the issue:</p>
<pre>for (short i = 0; i &lt; package.Elements.Count; i++)
{
    EA.Element element =
        (EA.Element) package.Elements.GetAt(i);
    doSomething();
}</pre>
<p>Much thanks to R Henry who had the same problem and posted his findings in the above-mentioned thread!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=18&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2009/09/01/enterprise-architect-beware-of-for-each-loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful desktop tools</title>
		<link>http://darkroastjava.wordpress.com/2009/06/16/useful-desktop-tools/</link>
		<comments>http://darkroastjava.wordpress.com/2009/06/16/useful-desktop-tools/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:10:58 +0000</pubDate>
		<dc:creator>darkroastjava</dc:creator>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[3d Desktop]]></category>
		<category><![CDATA[Organize icons]]></category>
		<category><![CDATA[Screen capture]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Virtual Desktops]]></category>
		<category><![CDATA[Workspaces]]></category>

		<guid isPermaLink="false">http://darkroastjava.wordpress.com/?p=3</guid>
		<description><![CDATA[These are some allday's desktop features I simply cannot do without (anymore): Virtual desktops / workspaces, a good screen shot utility, and a tool to organize my desktop icons. On the search for good and free solutions I stumbled upon following tools...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=3&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>These are some allday&#8217;s desktop features I simply cannot do without (anymore):</p>
<ul>
<li><strong>Virtual desktops </strong>/ workspaces, known from Apple and *ix, but not available ootb in windows.</li>
<li>A <strong>screen shot</strong> utility that immediately saves new shots into a specified folder without the need of any interaction.</li>
<li>A tool to <strong>organize shortcuts</strong> on the desktop.</li>
</ul>
<p>On the search for a good and free solution I stumbled upon following tools:</p>
<ul>
<li><strong>yodm3d </strong>- Freeware desktop manager. Provides 4 desktops on a nice semi-transparent 3d cube; download e.g. from <a title="http://www.klitetools.com/comments.php?catid=58&amp;id=5280" href="http://www.klitetools.com/comments.php?catid=58&amp;id=5280">http://www.klitetools.com/comments.php?catid=58&amp;id=5280</a>. Unfortunately I found that yodm3d is no longer available as freeware. Starting from version 1.5, the product is called &#8220;<strong>DeskSpace</strong>&#8221; and sold as Shareware.</li>
<li><a href="http://technet.microsoft.com/en-us/sysinternals/cc817881.aspx" target="_blank"><strong>sysinternals desktops</strong></a> &#8211; Advertised on Microsoft Technet, claims to be less error-prone than other tools because it uses Windows internal objects to manage multiple Desktops.</li>
<li><a href="http://lightscreen.sourceforge.net/" target="_blank"><strong>lightscreen</strong></a> &#8211; Open source screen shot utility. Very intuitive and lightweight.</li>
<li>After being used to manipulate the background image and insert semitransparent boxes into it faking organisational units for shortcuts, I found now <a href="http://www.stardock.com/products/fences/" target="_blank"><strong>fences</strong></a> which provides such organisational units. fences is free for personal use.</li>
</ul>
<p>My experiences with them:</p>
<ul>
<li><strong>yodm3d: </strong>The last version 1.4 seems to have some bugs (at least in Windows Vista). The worst bug: Sometimes, during rotating the cube, yodm3d silently closes some arbitrary open window/does not open it again when switching to the corresponding Desktop. Thus I sometimes lost a program&#8217;s state or even some unsaved data. This led me to remove the tool again.</li>
<li><strong>Desktops </strong>has several disadvantages and also bugs<strong>:</strong>
<ul>
<li>You cannot move a window from one Desktop to another. You have to open it on the right Desktop from the beginning.</li>
<li>The systray icons and bubbles showing up are only visible on the Desktop on which the program has been started.</li>
<li>Some programs, e.g. PDFCreator, always display their dialog on the first Desktop, even though it was triggered from another Desktop.</li>
<li>After some time a very strange behavior showed up: On pressing &#8220;Enter&#8221; in an arbitrary program, the input was ignored by the program and the Windows Media Center was started instead. This only occured as soon as I had multiple desktops.</li>
</ul>
<p>This led me to uninstall the program again.</li>
<li><strong>Fences</strong> dramatically compromised performance of Windows Vista with and without SP2.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkroastjava.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkroastjava.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkroastjava.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=darkroastjava.wordpress.com&amp;blog=7827506&amp;post=3&amp;subd=darkroastjava&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://darkroastjava.wordpress.com/2009/06/16/useful-desktop-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5bda6fbfe012c78d7b16fce7d9a4d377?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkroastjava</media:title>
		</media:content>
	</item>
	</channel>
</rss>
