There is a new requirement for my project to read various types of Excel files. I am able to read .xls and .xlsx files using the ExcelDataReader dll from Codeplex. The problem is when I try to read .xlsb files. ExcelDataReader cannot read from .xlsb files. Is there any other efficient way of reading xlsb files apart from using Microsoft.Office.Interop.Excel
dll in server based applications .
IExcelDataReader excelReader = fileName.EndsWith(".xlsx")
? ExcelReaderFactory.CreateOpenXmlReader(stream)
: ExcelReaderFactory.CreateBinaryReader(stream);
while (excelReader.Read())
{
//myStuff read the file
}
LinqToExcel supports xlsb as well as xls and xlsx.
Basic usage of this library looks like this:
using (var excelQueryFactory = new ExcelQueryFactory(filePath))
{
//access your worksheet LINQ way
var worksheet = excelQueryFactory.Worksheet("worksheetName").Where(...);
}