com-interop

Fastest way to drop a DataSet into a worksheet

两盒软妹~` 提交于 2019-12-08 08:56:48
问题 A rather higeisch dataset with 16000 x 12 entries needs to be dumped into a worksheet. I use the following function now: for (int r = 0; r < dt.Rows.Count; ++r) { for (int c = 0; c < dt.Columns.Count; ++c) { worksheet.Cells[c + 1][r + 1] = dt.Rows[r][c].ToString(); } } I rediced the example to the center piece Here is what i implemented after reading the suggestion from Dave Zych. This works great. private static void AppendWorkSheet(Excel.Workbook workbook, DataSet data, String tableName) {

import txt files using excel interop in C# (QueryTables.Add)

与世无争的帅哥 提交于 2019-12-08 07:04:32
问题 I am trying to insert text files into excel cell using Querytables.Add; no error, but the worksheet is empty. except for the single cell manipulation using Value2 property. I already using macro to record the object used. Can you help me on this(I am using vs2008, C# , excel 2003 and 2007; both shown empty cell). Below is my code; thanks for your help Application application = new ApplicationClass(); try { object misValue = Missing.Value; wbDoc = application.Workbooks.Open(flnmDoc, misValue,

Regasm and Com Interop false negatives

杀马特。学长 韩版系。学妹 提交于 2019-12-08 07:00:51
问题 I'm attempting to expose our library via COM but seem to be fighting the tools more than the actual problem. Regardless of how I write my COM exposed class I get the warning: "XXX.dll does not contain any types that can be registered for COM interop" (marked project as Register for COM interop in the project properties). Even the simple class below (as the only class in an assembly that is signed and marked with ComVisible(false)) still warning persists: [Guid("77699130-7D58-4d29-BE18

passing a complex object in c++ to c# through COM

匆匆过客 提交于 2019-12-08 06:09:02
问题 This question expands on the existing question here: Passing an object from C++ to C# though COM The previous question deals with a simple object, but I would like to do the same for a complex object. So instead of TestEntity1 having a single property, if it has another property of type TestEntity2, how can I assign the property of type TestEntity2 of the TestEntity1 object in c++ consumer? C#: using System; using System.Collections.Generic; using System.Text; using System.Runtime

How do I register a proxy/stub for a COM interface defined by a third party?

筅森魡賤 提交于 2019-12-08 04:53:19
There's Another Company that ships the product that consumes IAnotherCompanyInterface. We want to ship a COM object that implements IAnotherCompanyInterface. That interface is not Automation-compatible, so the next easiest option to enable marshalling is using a proxy/stub. Another Company doesn't ship the proxy/stub and doesn't want to. Compiling and registering the proxy/stub is not a problem by itself but consider the following situation. There's our company shipping a COM object implementing IAnotherCompanyInterface and the ThirdPartyCompany that does the same. So both components might end

Can Range.Value2 & Range.Formula have different values in C#, not VBA?

眉间皱痕 提交于 2019-12-08 04:30:21
问题 I want to create a UDF which is like GetPath(parameter) , where parameter can be a cell reference like "B1" , or a string what the GetPath does, based on input, it will call web service to get path for input e.g. formula of cell A1=GetPath(B1) , cell B1 has some string, the function should return path and put it in cell A1, i.e. "Value2" of A1 should be path of B1. Now in C#, when I did sth FormulaCell.Value2 = path , its formula changes, too but I want "Formula" & "Value2" to be different. I

Printer properties silverlight com-interop and out of browser

心已入冬 提交于 2019-12-08 01:32:26
问题 I need to access a printer to know if is active and have paper. I'm using silverlight 4 out of box with elevated trust. At this point I have: string cFileName = "temp.txt"; string cAction = "print"; using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject")) { dynamic file = fso.CreateTextFile(cFileName, true); file.WriteLine("First line text"); file.WriteLine("second line text"); file.Close(); } //Print dynamic shell = AutomationFactory.CreateObject("Shell.Application

Excel interop libraries incompatible with ASP.NET?

旧城冷巷雨未停 提交于 2019-12-07 22:25:39
问题 I have a simple web application which uses the Excel Interop libraries to read and insert into an Excel spreadsheet. I'm taking my due diligence to ensure that I don't use two dots and to ensure that all COM object references are released by using Marshal.ReleaseComObject() and GC.Collect() , but there is still an EXCEL.EXE process running on my server. I've created a Windows Forms application that uses the same object releasing process as in my ASP.NET app, and it ends the process

passing a complex object in c++ to c# through COM

好久不见. 提交于 2019-12-07 20:15:27
This question expands on the existing question here: Passing an object from C++ to C# though COM The previous question deals with a simple object, but I would like to do the same for a complex object. So instead of TestEntity1 having a single property, if it has another property of type TestEntity2, how can I assign the property of type TestEntity2 of the TestEntity1 object in c++ consumer? C#: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace ClassLibrary1 { [ComVisible(true)] public interface ITestEntity1 { string Name { get;

COM Object Cleanup

不羁的心 提交于 2019-12-07 18:14:40
问题 I am instantiating a COM object from a VBA script in excel as defined in a C# dll. The C# class I instantiate has a finalizer that performs garbage collection, notably other MS Office objects it references, which I should see appear and disappear in the task manager. In fact, the unit tests demonstrate that an Office process appears when the dll is called, and goes away when it is finished. When the dll is called from the VBA, I have noticed that the processes remain open after the VBA