interop

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

强颜欢笑 提交于 2019-12-01 04:23:15
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 here. Getting error as mentioned below. Please help me. Excel.Application excel = new Excel.Application(); excel.Visible = false; // to hide the processing Excel.Workbook wb = excel.Workbooks.Add(); Excel.Worksheet sh = wb.Sheets.Add(); // Error at wb sh.Name = "Links"; for (int i = 1; i < list.Count; i++) { sh.Cells[i.ToString(), "A"].Value2 = list[i]; //Error at .Value2 } you have to create a new

Killing an interop Application process

坚强是说给别人听的谎言 提交于 2019-12-01 04:12:34
问题 I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim eApp As New Excel.Application Dim w As Excel.Workbook w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True) .. Processing Code .. //Attempts at killing the excel application w.Close() eApp.Workbooks.Close() eApp.Quit() End Class When I run this a couple of times, I get a bunch of EXCEL.EXE instances in my task manager. How can I kill these processes in code? All of the ones in

ASP.NET web app calling Delphi DLL on IIS webserver, locks up when returning PChar string

不羁的心 提交于 2019-12-01 04:12:30
问题 Works fine if I don't return anything, or I return an integer. But if I try to return a PChar, ie.. result := PChar('') or result:= PChar('Hello') The web app just freezes up and I watch its memory count gradually get higher and higher in task manager. The odd thing is that the DLL works fine on the VStudio debug server, or through a C# app. The only thing I can think of that would make a difference is that the IIS server is running in 64bit Windows. It doesn't appear to be a compatability

P/Invoke with arrays of double - marshalling data between C# and C++

别说谁变了你拦得住时间么 提交于 2019-12-01 04:11:39
I've read the various MSDN pages on C++ Interop with P/Invoke here and here but I am still confused. I have some large arrays of doubles that I need to get into native code, and some resulting arrays that need to get back. I do not know the sizes of the output arrays in advance. For simplicity, I will use only a single array in the example. The platform is x64; I read that marshalling internals are quite different between 32- and 64-bit environments so this might be important. C# [DllImport("NativeLib.dll")] public static extern void ComputeSomething(double[] inputs, int inlen, [Out] out

COM Exception 80040154 When creating an Excel Application

十年热恋 提交于 2019-12-01 04:03:18
问题 I'm trying to run my application on a server which does not and will not have Office installed on it. using EXCEL = Microsoft.Office.Interop.Excel; ... EXCEL.Application app = new EXCEL.Application();//Exception thrown here The code is working fine on my own system, but on the server it gives the following exception: Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {...} failed due to the following error: 80040154

Find and replace text in excel with specified font name

余生颓废 提交于 2019-12-01 04:03:03
问题 I'm using Microsoft Excel 12.0 Object Library. My goal is to find text with specified font name and replace with new text. Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); xlApp.FindFormat.Font.Name = "Arial"; workSheet.Cells.Replace('a', 'b', Type.Missing, Type.Missing, Type.Missing, Type.Missing, xlApp.FindFormat, Type.Missing); but it does not works. So how to find string with specified font name and replace with new string? Thank you!

Windows Phone 8 (C++ Only) - Possible to access device manufacturer?

痞子三分冷 提交于 2019-12-01 03:19:24
Currently developing a Windows Phone 8 application in pure C++/Direct3D. We now need to access the Device Manufacturer name but it seems to only be available under C# which, according to my research is not accessible from this type of application. This page lists some of the calls I would like to use: http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.info.devicestatus(v=vs.105).aspx . // If only I could call this line from C++ DeviceStatus.DeviceManufacturer; Is there anyway to get this information without having to refactor the app as a XAML/C++ hybrid application

Cannot access excel file

烂漫一生 提交于 2019-12-01 03:16:07
I'm developing a windows service, generating a report. This report has a template. This template is prepared in an excel file. This file is copied to the output folder. While developing I launched the service like a console application and had no problems accessing this file. Then I prepared a service installer. The service is installed under Local System account. So this excel template file is marked as content and copied to the installation directory together with the executable as well. But when the service is launched excel appears to have no access to this file. The service is installed

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005

…衆ロ難τιáo~ 提交于 2019-12-01 03:13:17
What is the troubleshooting process for the "Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005" errors in .Net? To clarify: I am getting this at runtime, on my XP machine, with client being .net code running under admin account. {XXXX} refers to one of our in-house COM components. From what I understand, 0x80080005 refers to "permission denied", but where do I go to check/change the permissions? Or am I completely wrong here, and the error is coming from the component itself, and not out of Windows COM subsystem? Seems to be a rather

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

时光毁灭记忆、已成空白 提交于 2019-12-01 02:46:54
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 xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; xlApp = new Excel.ApplicationClass();//error here //... and faced a compile-time error, saying There is no constructor defined for Microsoft.Office.Interop.Excel.ApplicationClass type. What am I missing? Try this: Excel._Application xlApp = new Excel.Application(); Use the following to open it: xlApp