Windows Phone Developers

Friday, July 30, 2010

C#/VB.NET Excel Autofilter - Specify Multiple Criteria using Array

C#/VB.NET Excel Autofilter - Only Last Value is Displayed

Here is a simple example of Filtering ListObjects using Excel AutoFilter function. This example uses the following spreadsheet



The following C# code will filter 'Apple' and 'Orange' using an Array


private void ExcelFilterExample() { String[] FilterList = {"Apple","Orange"}; Excel.Workbook oWB = Globals.ThisAddIn.Application.Workbooks.Open(@"C:\Users\comp\Documents\FreshFruitsnVegetables.xls"); Excel.Worksheet oWS = oWB.Worksheets[1]; oWS.ListObjects.AddEx (Excel.XlListObjectSourceType.xlSrcRange, oWS.UsedRange, System.Type.Missing ,Excel.XlYesNoGuess.xlYes).Name = "FruitList"; oWS.ListObjects["FruitList"].Range.AutoFilter(2, FilterList, Excel.XlAutoFilterOperator.xlFilterValues ); }
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

VB.NET Excel Offset Function / C# Excel Offset Function

How to Offset Excel Ranges using VB.NET / C#

The following code gives you a better insight into offsetting a range using C#. The code uses get_Offset method to Offset the range

private void MathTableExample()
        {
            Microsoft.Office.Interop.Excel.Range oRng;
            oRng = Globals.ThisAddIn.Application.get_Range("A1");

            for (int i = 1; i <= 10; i++)
            {
                // Uses Offset Method of Excel     
                oRng.get_Offset(i, 0).Value2 = "9 x " + i.ToString() + " = " + (i * 9).ToString();
            }


        }

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Thursday, July 22, 2010

How to disable/suppress Addin Errors in Excel/ Word

Disable/suppress Addin Errors while loading in Excel/ Word (VSTO/.NET)

If you don't want to show your users the following kind of embarrassing errors:

Use the following option from Excel/Word Options --> Advanced

Disable Errors while Loading Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Sunday, July 18, 2010

NOT Operator in C# (.NET)

What is the equivalent for VB NOT operator in C#

VB Programmers use NOT operator often. For example,


If Not Range is nothing


or


FlagDone = Not Failed



You can do the same in C# as shown below:

Microsoft.Office.Interop.Excel.Range oRng;

            oRng = null;
            if (object.ReferenceEquals(oRng,null)) 
            {
                oRng = null;
            }

and also in the following context to toggle the Button and TaskPane

Globals.Ribbons.RibbonFB.button1.Enabled  =(!CusPane.Visible);
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Monday, July 5, 2010

How to make .NET application compatible to all platforms 32 bit and 64 bit

How to convert a 32 bit .NET application to 64 bit

If you have developed application for 32 bit and want to make the application work in all platforms, change the Platform target to all from Project properties

Platform Compatibility (32 bit, 64 bit) for .NET application
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon