Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created February 11, 2013 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yetanotherchris/4757418 to your computer and use it in GitHub Desktop.
Save yetanotherchris/4757418 to your computer and use it in GitHub Desktop.
Export to Excel in C#
var app = new ApplicationClass();
var book = app.Workbooks.Open(@"C:\test.xlsx", false, false, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
var sheet = (Worksheet) book.Worksheets[1];
var range = sheet.get_Range("D7", "D127");
var cell = (Range) range.Cells[1, 1]; // all indexes are 1 based. This gets the first row, column
string val = cell.Value2.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment