Last active
December 16, 2015 18:39
-
-
Save Oblongmana/5478795 to your computer and use it in GitHub Desktop.
This contains #Extension methods for #Excel objects. At present, just contains a method for simplifying getting the #Value2 for a particular column/row in a particular worksheet. This gives the value back, and takes care of the COM management stuff nicely, so you can just call worksheetInstance.GetCellValue2(colInt,rowInt) without thinking too h…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Excel = Microsoft.Office.Interop.Excel; | |
using MyExtensions | |
namespace MyExtensions | |
{ | |
public static class ExcelExtensions | |
{ | |
public static dynamic GetCellValue2(this Excel._Worksheet theWorksheet, int column, int row) //lolwut:static dynamic | |
{ | |
Excel.Range theRange = (Excel.Range)theWorksheet.Cells[row, column]; | |
dynamic theValue = theRange.Value2; | |
theRange.CloseReleaseAndNullComObject(); | |
return theValue; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment