Questions tagged [excel-interop]

Excel Interop is the layer using the COM Interop that allows .NET (VB or C#) to communicate with standard COM objects and libraries.

Excel Interop is part of the COM Office Interop. It allows .NET (VB or C#) to communicate with other COM objects and libraries.

1630 questions
23
votes
4 answers

Set cell value using Excel interop

Ok, so I'm trying to set the value of a cell with the excel interop library. I am able to do it with the following: sheet.Cells[row, col] = value; but it's terribly slow for how many I'm setting. So I'm trying to go this route: Range excelRange =…
Arthurdent510
  • 1,290
  • 6
  • 18
  • 32
22
votes
5 answers

Fastest method to remove Empty rows and Columns From Excel Files using Interop

I have a lot of excel files that contains data and it contains empty rows and empty columns. like shown bellow I am trying to remove Empty rows and columns from excel using interop. I create a simple winform application and used the following code…
Hadi
  • 36,233
  • 13
  • 65
  • 124
22
votes
3 answers

Microsoft.Office.Interop.Excel.ApplicationClass has no constructor defined

I tried to follow How to open an Excel file in C# tutorial, i.e. added a reference on the Com tab to Microsoft Office 14.0 Object Library and tried to compile code: using Excel = Microsoft.Office.Interop.Excel; //... Excel.Application…
horgh
  • 17,918
  • 22
  • 68
  • 123
21
votes
3 answers

How to Save/Overwrite existing Excel file with Excel Interop - C#

Is there a way to save changes to an excel spreadsheet through the excel interop (in this case I am adding a worksheet to it) without having it prompt the user if they want to overwrite the existing file with the changes. I do not want the user to…
user1546315
  • 683
  • 5
  • 16
  • 27
20
votes
3 answers

Why does Microsoft.Office.Interop.Excel.Application.Quit() leave the background process running?

The following code leaves a Microsoft Excel background process running, until after my program has exited: var excelApplication = new Application(); var workbooks = excelApplication.Workbooks; var workbook =…
skinnysoftware
  • 889
  • 1
  • 9
  • 14
19
votes
1 answer

How can I filter columns (rather than rows) in EPPlus?

Filtering rows in a particular column is as easy as pie in EPPlus: private ExcelWorksheet prodUsageWorksheet; . . . prodUsageWorksheet.Cells["A6:A6"].AutoFilter = true; This allows me to filter the rows in column A: I also need to filter certain…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
16
votes
7 answers

Changing an Excel cell's backcolor using hex results in Excel displaying completely different color in the spreadsheet

So I am setting an Excel cell's Interior Color to a certain value, like below: worksheet.Cells[1, 1].Interior.Color = 0xF1DCDB; However, when I then open up the spreadsheet in Excel, I see that the color that came out is completely different (in…
Amberite
  • 1,379
  • 3
  • 14
  • 27
15
votes
3 answers

How do I add a custom XML to an open Excel 2007 workbook using C#?

I'm trying to add a custom XML to an open Excel 2007 workbook using C#. I'm using Microsoft.Office.Interop.Excel as an interface. I've discovered there's a CustomXMLPart class but I can't figure out how to use it. Initially I expected the code to be…
TheMathemagician
  • 968
  • 9
  • 21
15
votes
6 answers

writing data from C# to Excel interrupted by opening Excel Window

While my C# program writes data continuously to an Excel spreadsheet, if the end user clicks on the upper right menu and opens the Excel Options window, this causes following exception: System.Runtime.InteropServices.COMException with HRESULT:…
Bertrand_Szoghy
  • 880
  • 1
  • 11
  • 26
15
votes
6 answers

Error uploading Excel file from ASP.NET application to MySQL

I'm working on a web application (ASP.NET) with a MySQL database. When I try to upload an Excel file (.xlsx) via this application I have no issues. The issue begins when the file is more than 24904 records. At that point I get the following…
14
votes
2 answers

Safely disposing Excel interop objects in C#?

i am working on a winforms c# visual studio 2008 application. the app talks to excel files and i am using Microsoft.Office.Interop.Excel; to do this. i would like to know how can i make sure that the objects are released even when there is an…
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
14
votes
8 answers

Delete Empty Rows with Excel Interop

I have user supplied excel files that need to be converted to PDF. Using excel interop, I can do this fine with .ExportAsFixedFormat(). My problem comes up when a workbook has millions of rows. This turns into a file that has 50k+ pages. That would…
Chris
  • 4,393
  • 1
  • 27
  • 33
14
votes
2 answers

Which One is Best OLEDB Or Excel Object Or Database

I need to work with Excel 2007 File for reading the data. for that which one is the best way to do that: Using OLEDB Provider Excel Interop Object Dump the Excel data to Database and Using Procedure kindly guide me to choose.
guna Samba
  • 474
  • 1
  • 7
  • 17
14
votes
1 answer

Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX) for System.Runtime.InteropServices.COMException

I have a part of code which tries to export data (from database) to Excel. When I am trying to perform this task, it is generating this error: System.Runtime.InteropServices.COMException occurred Additional information: Invalid index. (Exception…
Somdip Dey
  • 3,346
  • 6
  • 28
  • 60
13
votes
2 answers

Getting excel application process id

I am creating an excel application with c#. Since I will maintain the excel file in urgency I want to keep its handler open. I want to keep the excel process id so I will be able to kill it in case the system crashs. How can I get the Excel Pid when…
yoavba
  • 401
  • 2
  • 6
  • 13