LinqToExcel icon indicating copy to clipboard operation
LinqToExcel copied to clipboard

Why Does It Open Excel File?

Open dchaffin opened this issue 11 years ago • 4 comments

I just ran across this and it looks promising for what I need. The only problem so far is it opens the file.

All I have so far is:

var excel = new ExcelQueryFactory(Server.MapPath("sample.xls")); var sheetNames = excel.GetWorksheetNames();

If I just run the first line, it's find. But as soon as I run a page with the 2nd line, it loads the page, but then it also opens the file in Excel.

What am I missing?

Thanks!

dchaffin avatar Jul 25 '14 19:07 dchaffin

Sorry, I've never ran into that issue before. I'll leave this issue open in case anyone else knows a solution to the problem though.

paulyoder avatar Jul 25 '14 19:07 paulyoder

I can reproduce this issue. I'm using VS2012 w/ Office 2013 I have a copy of Excel open for either of the coding snippets:

        excel.GetWorksheetNames();

or var pings = excel.WorksheetRange<FuelUsage>(cellStart, cellEnd, "Summary").OrderBy(b => b.Vehicle); foreach (var p in pings) // as soon as this statement is reached excel opens { }

Bit more information:

I'm using the LinqToExcel from nuget and it's version 1.10.1.0.

Forgetabull avatar Sep 01 '15 01:09 Forgetabull

Yes, It opens excel and does NOT close it. Leads to many orphaned instances of Excel running on Windows 2012R2 Standard server. using version 1.10.1.0 obtained via NuGet.

Using the following code

var excelFile = new ExcelQueryFactory(fileName) { TrimSpaces = TrimSpacesType.Both, UsePersistentConnection = true, ReadOnly = true };

                var sheetName = "Sheet1";
                var sheet = excelFile.Worksheet<ExcelTract>(sheetName).ToList();

                /* much code here */
               excelFile.Dispose();

DgreatGnazzini avatar Dec 18 '15 23:12 DgreatGnazzini

I know this is old but... I tried adding:

workbook.Close();

Referencing initialization of the workbook\file:

Excel.Workbook workbook = app.Workbooks.Open(filename);

The Excel process closes when I close my application. Unfortunately, it does not close after the data is collected from the spreadsheet. But hey, it's better than nothing.

theshiv303 avatar Dec 01 '17 00:12 theshiv303