using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
static void Main(string[] args)
Console.WriteLine("Please Copy Folder and paste it here ");
var dirPath = @"" + Console.ReadLine();
Console.WriteLine("Please Create output txt file and pate its path here: \n example ((c:/output.txt))");
var outPath = @"" + Console.ReadLine();
var filesss = Directory.GetFiles(dirPath);
Console.WriteLine("How many Cells you need to fetch: ");
var noOfCells = int.Parse(Console.ReadLine());
List<Cell> cellvalues = new List<Cell>(noOfCells);
Console.WriteLine("Please Enter Cell name , Cell Row ,Cell Column ((Comma Separated))");
for (int i = 0; i < noOfCells; i++)
var read = Console.ReadLine();
var cellname = read.Split(',')[0];
var cellrow = read.Split(',')[1];
var cellcolumn = read.Split(',')[2];
cellvalues.Add(new Cell(Convert.ToInt32(cellrow), Convert.ToInt32(cellcolumn), cellname));
for (int i = 0; i < filesss.Length; i++)
var excelfile = new ExcelReader(filesss[i], 1);
List<string> res = new List<string>();
for (int j = 0; j < noOfCells; j++)
res.Add(excelfile.ReadCell(cellvalues[j].row, cellvalues[j].col));
string[] thearray = res.Select(h => h.ToString()).ToArray();
var result = string.Join(",", thearray);
File.AppendAllText(outPath, result + Environment.NewLine);
Console.WriteLine("Done");
public string cellName="";
public Cell(int x, int y, string z)
_Application excel = new Excel.Application();
object misvalue = System.Reflection.Missing.Value;
public ExcelReader(string path, int sheet)
wb = excel.Workbooks.Open(path);
ws = wb.Worksheets[sheet];
public string ReadCell(int i, int j)
return ws.Cells[i, j].Value2.ToString();
wb.Close(false, misvalue, misvalue);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(excel);