I have a list array which contains some data. Currently I can see the output in the console and now trying to add to an excel file. Can anyone explain me how to do that. Here is the code to create an excel sheet and write something to it. But how do I combine both of this codes to see the output in excel. I tried several combinations but couldn't write to excel. I'm newbie to c#.Thanks in advance!
foreach (Match m in linkParser.Matches(html))
{
list.Add(m.Value);
Console.WriteLine(m.Value);
}
Excel.Application oApp; // to open excel
Excel.Worksheet oSheet;
Excel.Workbook oBook;
oApp = new Excel.Application();
oBook = oApp.Workbooks.Add();
oSheet = (Excel.Worksheet)oBook.Worksheets.get_Item(1);
string fileTest = "output123.xlsx";
if (File.Exists(fileTest))
{
File.Delete(fileTest);
}
oSheet.Cells[1, 1] = "some value";
oBook.SaveAs(fileTest);
oBook.Close();
oApp.Quit();