using System.Collections.Generic;
using NPOI.HSSF.UserModel;
using NPOI.XSSF.UserModel;
public static void Main()
Console.WriteLine("Hello World");
String filePath = @"C:\Users\UI158215\Desktop\TradeWeighting.xlsx";
Console.WriteLine(filePath);
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
IWorkbook workbook = null;
fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
if (filePath.IndexOf(".xlsx") > 0)
workbook = new XSSFWorkbook(fs);
else if (filePath.IndexOf(".xls") > 0)
workbook = new HSSFWorkbook(fs);
Console.WriteLine(workbook);
Console.WriteLine(filePath.IndexOf(".xlsx"));
Console.WriteLine(filePath.IndexOf(".xls"));
ISheet sheet = workbook.GetSheetAt(0);
int rowCount = sheet.LastRowNum;
for(int i=1; i<=rowCount; i++)
IRow curRow = sheet.GetRow(i);
var cellValue0 = curRow.GetCell(0).StringCellValue.Trim();
Console.WriteLine(cellValue0);