Microsoft Office Excel cannot access the file ‘c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx’

Try this: Create the directory C:\Windows\SysWOW64\config\systemprofile\Desktop (for the 32-bit version of Excel/Office on a 64-bit Windows computer) or C:\Windows\System32\config\systemprofile\Desktop (for a 32-bit version of Office on a 32-bit Windows computer or a 64-bit version of Office on a 64-bit Windows computer). For the Desktop directory, add Full control permissions for the relevant user (for example … Read more

Optimal way to Read an Excel file (.xls/.xlsx)

Take a look at Linq-to-Excel. It’s pretty neat. var book = new LinqToExcel.ExcelQueryFactory(@”File.xlsx”); var query = from row in book.Worksheet(“Stock Entry”) let item = new { Code = row[“Code”].Cast<string>(), Supplier = row[“Supplier”].Cast<string>(), Ref = row[“Ref”].Cast<string>(), } where item.Supplier == “Walmart” select item; It also allows for strongly-typed row access too.

Closing Excel Application Process in C# after Data Access

Try this: excelBook.Close(0); excelApp.Quit(); When closing the work-book, you have three optional parameters: Workbook.close SaveChanges, filename, routeworkbook Workbook.Close(false) or if you are doing late binding, it sometimes is easier to use zero Workbook.Close(0) That is how I’ve done it when automating closing of workbooks. Also I went and looked up the documentation for it, and … Read more