excel-interop

Workaround to see if Excel is in cell-edit mode in .NET

I have an application written in VB.NET that interacts with Excel via interop. I eventually ran into the known issue of Cell-edit mode (see MSDN and stackoverflow for some background). I have been trying to convert the suggested code to VB.NET but keep getting the following error: Reference required to assembly 'office, Version=11.0....

Create UDF using VSTO and no VBA

Similar to this question (but in my case not VSTO SE), however, I just want to confirm that it is not possible to create a UDF using pure VSTO in Visual Studio 2005 and Excel 2003 - so, to absolutely clear, my question is: Is it possible to create a Excel 2003 UDF using Visual Studio 2005 and a VSTO solution without using any VBA or oth...

C# and Excel Interop issue, Saving the excel file not smooth

Hi, I could Open and Write to the excel file, but when I try to save the file by passing a path to it, the save operation prompts with the Save dialog. I was expecting it to quitely Save the file at the specified path The code is as below: excelApp.Save(exportToDirectory); excelApp.Quit(); where, exportToDirectory is: "C:\files\stri...

Excel Interop: Application and ApplicationClass differences

I'm running into a problem with excel interop. Basically, what I'm trying to do is call a macro in an excel workbook from .NET with a complex argument type. However, in doing so I'm running into some differences between Application and ApplicationClass that are giving me some headaches. Here is some code: Dim complexType As New BigBa...

Why is .NET Sql Server access faster than Excel Interop?

This might be a loaded question, and it might get voted down, but it completely frustrates me. When you use SQL Server in your development the data access is fast and efficient, but when you use COM to talk to Excel it is piggy slow. It doesn't matter what data access technology you use, ADO, ADO.NET, LINQ, Entity Framework, Astoria (A...

How can I Create an Excel Sheet with Microsoft.Office.Interop.Excel.dll?

How can I create an Excel sheet with Microsoft.Office.Interop.Excel.dll in ASP.NET? ...

How to write excel by opening it programmatically with Microsoft.Office.Interop.Excel dll ?

Hi to All, I want to use Microsoft.Office.Interop.Excel dll to write the data into excel sheet. I have a code: if (System.IO.File.Exists(strFileName)) { System.IO.File.SetAttributes(strFileName, FileAttributes.Normal); System.IO.File.Delete(strFileName); } // Open an instance of excel. Create a new workbook. // A workbook by d...

Use Excel Interop to grab image of Excel chart without writing to disk or using the clipboard

The interface to the chart object in Excel only allows access to the image representing the chart through two methods: export, which saves the image to a file CopyPicture, which saves the image to the clipboard Both of these options are problematic (saving to a file is really slow, and saving to the clipboard could clobber user data)...

Are we unable to use Interop objects in generic objects in .NET 4.0?

I'm working in VS 2010 and working on upgrading our application to .NET 4. The application is build with Excel as the base and we want to take advantage of some of the improvements to .NET for using Excel. But I ran across a strange error that seems to be caused by using an Excel Interop object in a generic dictionary. Here is the err...

How can I access the values from `Series.Values` (Excel Chart)

I am using the Microsoft.Office.Interop.Excel namespace and I am creating a chart. At a certain moment, I want to retrieve the values of a certain series. On MSDN it says that a Series object has a property Values. This returns either a Range object or an array of values, I assume an object[]. In my code I have the following statement: ...

Which Excel Interop objects to clean up myself and which to clean up by GC.Collect()

Question: I want to ask a question in response to Mike Rosenblum's answer to this question. The question was about cleaning up Excel interop objects. Several solutions where suggested (e.g. wrappers, not using more than one dot, killing the excel process), but I liked Mike Rosenblum's solution to this problem the most (lengthy article a...

C# Excel - Manage column properties.

Scenario is to generate an excel report that has ~ 150 data columns. Now I need to manage the column properties like Width, BackgroundColor, Font etc. The approach that I am using relies on reflection. I have a class that has ~ 150 constants for column header text. Another custom attribute class to store column properties. These attribu...

Load an assembly dynamically and create an variable of its type

I am trying to load an assembly dynamically and create an variable of its type: Assembly Ass= Assembly.LoadFrom(@"d:\abc\microsoft.office.interop.excel.dll"); foreach(Type Excel Assembly.Gettypes()) { // here now Type contains // Excel.nameSpace="microsoft.officce.interop.excel" // now i need to creae an variable of type ...

Microsoft Office Interop Excel 12.0 not working in IIS 7

Hi, I am creating a pivot table excel sheet in my ASP .NET web application using Microsoft Office Interop Excel 12.0 components. It is creating the excel file correctly, when i run it from my Visual Studio 2008 in Debug/Release mode. But when i deploy the solution in IIS 7, first i got some permission issues, which i resolved by givin...

COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

When I run the following code, I get the exception below: ''# NOTE: ExcelApp is a Private main form variable Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename) Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report") ''# Retreive data from sheet ReleaseCOM...

Display page numbers in a excel sheet generated using C#.NET

Hello Stackers Does anyone have an idea on how to include or input the page numbers in the excel sheet generated using C# code. I use the libraries available in Microsoft.Office.Interop.Excel to generate the file. However by default in the output i cannot see the page numbers. I know to enable this via excel options (View --> Header...

UDF in VSTO without creating a separate project

Hi there! Is there any way to implement an UDF in my Excel 2007 add-In without creating a separate project? Even if this requires using dirty tricks I'd like to know about it. Actually, I'd like to know about any exiting ways to do this. So, if I can't... I heard something about official MS response on this problem, but i can`t find it...

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 ExportReport { public void Export() { Excel.Application excelApp = new Microsoft.Offic...

Getting relative addresses in Excel Interop

In C# programs using the Excel Interop library, the Range.get_Address(...) method seems to return a relative address only if R1C1 format is specified. Does the library provide a simple way to get relative A1-style addresses? ...

Comparing Ranges in Excel

In the Excel Interop libraries, is there functionality to determine whether a given Range object is contained within another Range object? It would be simple enough for me to compare the row and column indices of each Range, but things become more complicated when you want to compare two ranges that may be on different worksheets. ...