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
98
votes
22 answers

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 excel file. See my Task Manager after multiple runs…
Javad Yousefi
  • 2,250
  • 4
  • 35
  • 52
85
votes
8 answers

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 Requirement : Read a file to a DataTable / CUstom Entities…
Ankesh
  • 4,847
  • 4
  • 38
  • 76
74
votes
5 answers

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 Microsoft.Office.Interop; public class…
Nick O
  • 3,716
  • 6
  • 38
  • 50
57
votes
9 answers

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…
Shubh
  • 6,693
  • 9
  • 48
  • 83
49
votes
10 answers

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 cell that has data. So in the above example, I want to…
pjj
  • 499
  • 1
  • 5
  • 4
48
votes
9 answers

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, Type.Missing, Type.Missing, Type.Missing,…
Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59
37
votes
11 answers

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 I have also tried all the solutions given on the…
Sameer S
  • 1,011
  • 1
  • 9
  • 9
37
votes
8 answers

Class not registered error when creating Excel workbook in C#

When I try to access an Excel spreadsheet using the following code I get a "Library not registered' error when defining the workbook object wrkbuk using C# from Visual Studio 2012 with Office 2007 (ver 12)…
SimonKravis
  • 429
  • 1
  • 5
  • 8
37
votes
16 answers

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.Application(); excel.Visible =…
provençal le breton
  • 1,428
  • 4
  • 26
  • 43
31
votes
1 answer

How to close-without-save an Excel /xlsm workbook, w/ a custom function, from C#

I have an Excel workbook with a custom non-time-dependent cell function that I am opening from a C# WindowsForms application using Interop.Excel. I read four values from it, perform no explicit changes/calculations, then close it from C#. When I try…
Jack Huang
  • 531
  • 1
  • 5
  • 12
31
votes
28 answers

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, 1], cell.Cells[nRowCount, nColumnCount]]; Here my…
Cannon
  • 2,725
  • 10
  • 45
  • 86
28
votes
13 answers

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
  • 440
  • 2
  • 9
  • 15
27
votes
7 answers

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 uses MS Office Interop (Microsoft Excel 14.0 Object…
engg
  • 343
  • 1
  • 4
  • 12
25
votes
6 answers

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 worksheet or column names, so I need to allow for…
Justin Morgan - On strike
  • 30,035
  • 12
  • 80
  • 104
24
votes
2 answers

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 rows? I have Excel._Worksheet worksheet =…
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
1
2 3
99 100