简体   繁体   中英

Open Excel workbook in background using interop

I'm wanting to import data from an Excel workbook without actually displaying the open workbook.

I could have sworn I had used the following code on a previous project and it had worked:

var excelApp = new Excel.Application { Visible = false };
var workbook = excelApp.Workbooks.Open(filePath);

Unfortunately when the workbook opens it is displayed to the user which is unnecessary for this application.

I'm using Microsoft Excel 15.0 Object Library on this project when previously I think it was version 12 or 13. Maybe this is the problem, or is my memory fading and the code is incorrect?

I know this is old but just in case anybody still needs this answer...

excelApp.Visible = false;

(excelApp being the name of the variable used for the excel application)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM