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
Filter by
Sorted by
Tagged with
31 votes
28 answers
223k views

HRESULT: 0x800A03EC on Worksheet.range

I am getting HRESULT: 0x800A03EC on Worksheet.range method. Number of rows are more than 70K. Office 2007. Code: Microsoft.Office.Interop.Excel.Range neededRange = currentWS.Range[cell.Cells[1, ...
Cannon's user avatar
  • 2,775
37 votes
18 answers
64k views

Cannot close Excel.exe after Interop process

I'm having an issue with Excel Interop. The Excel.exe doesn't close even if when I realease instances. Here is my code : using xl = Microsoft.Office.Interop.Excel; xl.Application excel = new xl....
provençal le breton's user avatar
50 votes
10 answers
145k views

Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))

I am trying to convert a .xls file to an .xlsx file on the server-side using Microsoft.Office.Interop.Excel.Workbook class as follows: workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook,...
Tamas Ionut's user avatar
  • 4,350
22 votes
5 answers
28k views

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 ...
Hadi's user avatar
  • 36.8k
13 votes
3 answers
20k views

Export the dataGridView to Excel with all the cells format

I have this code that I know that it works fast CopyAlltoClipboard(dataGridViewControl); Microsoft.Office.Interop.Excel.Application xlexcel; Microsoft.Office.Interop.Excel.Workbook xlWorkBook; ...
Ștefan Blaga's user avatar
102 votes
22 answers
206k views

Closing Excel Application Process in C# after Data Access

I'm writing an application in C# that opens an Excel template file for read/write operations. I want to when user closes the application, excel application process has been closed, without saving ...
Javad Yousefi's user avatar
49 votes
10 answers
348k views

How to count the number of rows in excel with data?

column A has data like this (ie frequent blank cells): HEADING <-- this is A1 kfdsl fdjgnm fdkj gdfkj 4353 fdjk <-- this is A9 I would like to be able to get the cell reference of the last ...
pjj's user avatar
  • 499
85 votes
8 answers
279k views

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

I know that there are different ways to read an Excel file: Iterop Oledb Open Xml SDK Compatibility is not a question because the program will be executed in a controlled environment. My ...
Ankesh's user avatar
  • 4,865
58 votes
9 answers
88k views

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

I have my code as follows :- Microsoft.Office.Interop.Excel.Application oXL = null; Microsoft.Office.Interop.Excel.Sheets sheets; Application excel = new Microsoft.Office.Interop.Excel.Application(); ...
Shubh's user avatar
  • 6,693
38 votes
11 answers
150k views

System.Runtime.InteropServices.COMException (0x800A03EC)

Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs() method is working fine on Windows server 2003 and also on XP but not on Windows server 2008. I copied it as it is gave all Dll's and permissions ...
Sameer S's user avatar
  • 1,031
20 votes
3 answers
25k views

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 ...
skinnysoftware's user avatar
25 votes
6 answers
154k views

How do I import from Excel to a DataSet using Microsoft.Office.Interop.Excel?

What I want to do I'm trying to use the Microsoft.Office.Interop.Excel namespace to open an Excel file (XSL or CSV, but sadly not XSLX) and import it into a DataSet. I don't have control over the ...
Justin Morgan's user avatar
5 votes
4 answers
18k views

extract image from word file

I have been trying the following C# code to extract image from the doc file but it is not working: object missing = System.Reflection.Missing.Value; Microsoft.Office.Interop....
fawad's user avatar
  • 1,323
78 votes
5 answers
148k views

How do I auto size columns through the Excel interop objects?

Below is the code I'm using to load the data into an Excel worksheet, but I'm look to auto size the column after the data is loaded. Does anyone know the best way to auto size the columns? using ...
Nick O's user avatar
  • 3,796
24 votes
2 answers
74k views

C# - How do I iterate all the rows in Excel._Worksheet?

I am looking to programmatically pull data from an Excel worksheet and insert it into a database table. How do I determine the number of columns and rows in a worksheet or otherwise iterate the ...
P.Brian.Mackey's user avatar
11 votes
4 answers
2k views

Moq & Interop Types: works in VS2012, fails in VS2010?

I have a .NET library project with about 500 unit tests. All these tests run fine in Visual Studio 2012. However, some of my tests fail in Visual Studio 2010. In these failing tests, I use Moq to mock ...
Martin Devillers's user avatar
5 votes
7 answers
18k views

Accessing an open Excel Workbook in C#

I need to access an excel file that is already open. I thought just inspecting the .Workbooks property that it would be there but it isn't. What is the right way to get a reference to the open ...
Jon Erickson's user avatar
14 votes
2 answers
23k views

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 ...
Alex Gordon's user avatar
  • 59.6k
7 votes
2 answers
16k views

How to access an already opened Excel file in C#?

I have an excel workbook opened via double-clicking it in windows explorer but cannot access it in code Excel.Application xlApp = (Application)Marshal.GetActiveObject("Excel.Application"); Excel....
Jon Erickson's user avatar
5 votes
3 answers
23k views

Copy format from one row to another using c#

This question is quite similar to the one asked here. But the answer given suggests copying the format along with the data. I have a excel sheet (.xlsx) that I generate using SSIS. Now I have set the ...
trailblazer's user avatar
  • 1,421
2 votes
3 answers
4k views

Eliminating use of '2 dots' when using Excel Interop Com Objects - C#

I am having trouble releasing Excel Interop Com Objects which is causing my c# application to crash when I attempt to save and then close an Excel workbook created via Excel Interop. I feel the issue ...
user1546315's user avatar
28 votes
13 answers
165k views

Exporting the values in List to excel

Hi I am having a list container which contains the list of values. I wish to export the list values directly to Excel. Is there any way to do it directly?
susanthosh's user avatar
13 votes
2 answers
40k views

microsoft.interop.excel Formatting cells

I am building a report using the microsoft.interop.excel library in C#. I have something like this: Range rangeTarget; . . . rangeTarget = worksheet.get_Range("C" + row, "N" + row); I want the ...
Jonny's user avatar
  • 2,817
13 votes
2 answers
27k views

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 ...
yoavba's user avatar
  • 401
10 votes
1 answer
47k views

Get all worksheet names in plaintext from Excel with C# Interop?

I'm using VS2010 + Office Interop 2007 to attempt to get a few specific spreadsheet names from an Excel spreadsheet with 5-6 pages. All I am doing from there is saving those few spreadsheets I need ...
Franklin_Skipdiddle's user avatar
5 votes
2 answers
2k views

.NET 4.0 Excel Interop issues with dynamic collections

In Excel you can return a dynamic array System.Object[*], from a series object using XValues. In .NET 3.5 you can access the elements in this object by casting it to and array, i.e.: var values = (...
J Pullar's user avatar
  • 1,925
5 votes
1 answer
49k views

How to generate a chart from an Excel sheet?

I can generate an Excel file when I pass a datatable into the below function: public static void ExportDataTableToExcel(DataTable dt, string filepath) { object missing = Type.Missing; object ...
user3467827's user avatar
4 votes
5 answers
8k views

Why would the Excel Interop remove an image after processing a file?

Excel Interop is removing images from processed files. I’m using the Excel Interop, no third-party components are present (that I'm aware of). The workflow is -- create a copy (target) of a file (...
Michael Paulukonis's user avatar
27 votes
7 answers
130k views

How to fix 'Microsoft Excel cannot open or save any more documents'

I am running C# ASP.NET 4.5 web application on Windows 7 64-bit using IIS 7.5. The application pool it uses has the name 'ASP.NET v4.0' and its identity is ApplicationPoolIdentity. The application ...
engg's user avatar
  • 343
13 votes
4 answers
14k views

how to detect merged cells in c# using MS interop excel

I want to detect merged cells either in a row/entire sheet(preferable).Here is my code Microsoft.Office.Interop.Excel.Application xl = new Microsoft.Office.Interop.Excel.Application(); ...
sadhana's user avatar
  • 167
12 votes
6 answers
12k views

Excel won't open/launch VSTO AddIn when running in debug mode of Visual Studio 2010

I had previously installed the VS11 beta, and had some issues with my Visual Studio 2010 instance, which you can see here how they were resolved: Excel AddIn Click Once deployment issue. Now I have a ...
mservidio's user avatar
  • 12.9k
12 votes
3 answers
23k views

Excel Get_Range with multiple areas

I'm trying to get a range from Excel, which has multiple areas specified, essentially I've got... int StartColumn int EndColumn int[] ColumnsToSkip When you combine these it's possible to produce a ...
Ian's user avatar
  • 34.1k
11 votes
3 answers
2k views

Excel interop prevent showing password dialog

I am writing a program to clean excel files from empty rows and columns, i started from my own question Fastest method to remove Empty rows and Columns From Excel Files using Interop and everything is ...
Hadi's user avatar
  • 36.8k
9 votes
2 answers
9k views

Trying to exit C# Excel Workbook without a dialog box

I am using Microsoft Office Interop to edit some excel files and when I close them I use outputExcelWorkBook.Close(false, paramMissing, paramMissing); But a dialog box still comes up, even though ...
azrosen92's user avatar
  • 8,717
9 votes
2 answers
31k views

How to rename excel sheet name dynamically in C#

I have created an excel workbook with many sheets like sheet1, sheet2,... etc. How can I rename these tab names dynamically in C#?
Dark Knight's user avatar
  • 3,547
8 votes
2 answers
45k views

How to iterate through Excel Worksheets only extracting data from specific columns

How do you iterate through an excel workbook with multiple worksheets only extracting data from say columns "C", "E" & "F"? Here is the code I have thus far: public static string ExtractData(...
RobHurd's user avatar
  • 2,041
4 votes
2 answers
40k views

Writing to an existing Excel File using c#

I am trying to open (or create a new xls) Excel file and write some values to it. Although, the program below works just fine if I simply create a new xls file, I encounter the some problem in line **...
SLearner's user avatar
  • 1,429
3 votes
1 answer
10k views

Microsoft.Office.Interop.Excel or EPPlus for read a huge (or not) Excel file

I wrote a code to read a column from a Excel file. I use Microsoft.Office.Interop.Excel on this, first read the entire Range and then write in System.Array after that I do some operations with the ...
Reynier's user avatar
  • 2,450
2 votes
3 answers
3k views

How to release excel process?

I'm using the Excel interop and it seems to be creating a process every time I call new Microsoft.Office.Interop.Excel.Application() And never ending the process even though I call xlApp.Quit(); ...
C. Ross's user avatar
  • 31.5k
2 votes
2 answers
5k views

How can I programmatically create an Excel "sort/Filter combobox"?

I'm reverse-engineering a manually created spreadsheet for dynamic creation. Most of the cells are populated with simple data, but there are a couple that are "sort/Filter" dropdowns like so: How can ...
B. Clay Shannon-B. Crow Raven's user avatar
2 votes
1 answer
2k views

WinForms COM Exception opening Excel workbook

I'm writing a very basic WinForms app using VB.Net, everything is going smoothly until I try and open an Excel file that I've written to the tempLocation via a Stream object (The workbook is in my ...
SierraOscar's user avatar
  • 17.5k
2 votes
1 answer
2k views

Why does this attempt to create a PivotTable (Excel Interop) fail?

Based on code I found here, I'm trying to create a Pivot Table like so: var range = _xlSheet.Range[_xlSheet.Cells[6, 1], _xlSheet.Cells[6, _grandTotalsColumn]]; ListObject ...
B. Clay Shannon-B. Crow Raven's user avatar
1 vote
3 answers
13k views

Exporting Several XtraGrid Controls to a Single Excel File

I've got several XtraGrid Controls each one containing different information, I get some information about the way in which you can export a XtraGrid to an Excel file in the following direction http://...
richardtk_1's user avatar
0 votes
3 answers
2k views

.Net Interop Excel ExportAsFixedFormat() Exception HResult: 0x800A03EC

I'm currently implementing a method that generated multiple sheets and export them as PDF. For this I'm using the Microsoft.Office.Interop Library (v14.0.0.0) with .NET 4.5.2 . Running Office is 2016 ...
dpa's user avatar
  • 167
-2 votes
1 answer
2k views

How do I fix the HRESULT: 0x800A03EC error when loading data from a DataTable?

First of all I know there are some answers to this error messsage, but nothing has helped, whether it is the removal of 0 indexing etc. The part where I export the data from my SQL query to the ...
Dr.rektalius's user avatar
23 votes
4 answers
96k views

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. ...
Arthurdent510's user avatar
22 votes
3 answers
42k views

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....
horgh's user avatar
  • 18.3k
21 votes
3 answers
63k views

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 ...
user1546315's user avatar
12 votes
3 answers
35k views

How to Delete a Column Programmatically?

How does one delete a column (or multiple columns) in Excel? eg. How to delete column C and shift the rest left?
Aximili's user avatar
  • 29k
10 votes
2 answers
26k views

Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Excel.Worksheet'. An explicit conversion exists (are you missing a cast?)

Here I'm opening excel and writing to excel sheet. I'm changing my windows application to asp website and seen this error. I have added all the references and libraries. Don't know what I am missing ...
221B's user avatar
  • 831

1
2 3 4 5