Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

How to get selected columns data from Excel sheet at runtime using C# [closed]

$
0
0

Please help me to get data from columns of an Excel sheet at runtime using C#. I want to develop a VSTO addin for adding the columns values at runtime.

Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddIn.Application.ActiveSheet;
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
Excel.Range firstRow = activeWorksheet.get_Range("A1");

var cellValue = (string)(activeWorksheet.Cells[10, 2] as Excel.Range).Value;
string sValue = (activeWorksheet.Cells[11,2] as Microsoft.Office.Interop.Excel.Range).Value2.ToString();

//~~> Range for sum output
Excel.Range Sum_Range = activeWorksheet.get_Range("A11", "A11");

//~~> Find Sum of say A1:A10 and display it in A11
Sum_Range.Formula = "=sum(A1:A10)";

Viewing all articles
Browse latest Browse all 88054

Trending Articles