Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 835
Darren Young Avatar asked Jan 22 '26 14:01

Darren Young


1 Answers

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)

like image 70
Michael Avatar answered Jan 24 '26 04:01

Michael