interop

Excel Interop Print

雨燕双飞 提交于 2019-12-04 12:28:48
问题 I need to print a selected area of an excel sheet (which I selected with Range.Select()) using the following print settings: Printer: Microsoft XPS Document Writer Print Selection Landscape Orientation A4 Normal Margins Fit Sheet on One Page How can I achieve this using _Worksheet.PrintOut or _Worksheet.PrintOutEx? Thanks in advance! 回答1: Try this ( TRIED AND TESTED ) I am assuming that you have set reference to Excel and have already declared your objects like Microsoft.Office.Interop.Excel

Need suggestions on how to extract data from .docx/.doc file then into SQL Server

☆樱花仙子☆ 提交于 2019-12-04 12:16:56
I'm suppose to develop an application for my project, it will load past-year examination / exercises paper (word file), detect the sections accordingly, extract the questions and images in that section, and then store the questions and images into the database. (Preview of the question paper is at the bottom of this post) So I need some suggestions on how to extract data from a word file, then inserting them into a database. Currently I have a few methods to do so, however I have no idea how I could implement them when the file contains textboxes with background image. The question has to link

Using ActiveX PropertyBags from C#

给你一囗甜甜゛ 提交于 2019-12-04 12:14:59
I have created a .NET user control with an ActiveX interface. It works well. Now, I want to be able to read and write from the property bag for the ActiveX interface. How would I do this? teebot The easiest is to use client script to pass the parameters values to the ActiveX <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <script language="javascript"> function Rundata(file) { var winCtrl = document.getElementById("YourActiveX"); winCtrl.Option1 = file; winCtrl.WriteToFile(); } </script> </head> <body> <form id="form1" runat="server"> <div> <object id=

Does COM interop respect .NET AppDomain boundaries for assembly loading?

怎甘沉沦 提交于 2019-12-04 12:10:55
问题 Here's the core problem: I have a .NET application that is using COM interop in a separate AppDomain. The COM stuff seems to be loading assemblies back into the default domain, rather than the AppDomain from which the COM stuff is being called. What I want to know is: is this expected behaviour, or am I doing something wrong to cause these COM related assemblies to be loaded in the wrong AppDomain? Please see a more detailed description of the situation below... The application consists of 3

Struct marshal in C#

故事扮演 提交于 2019-12-04 12:07:25
问题 I have the following struct in C# unsafe public struct control { public int bSetComPort; public int iComPortIndex; public int iBaudRate; public int iManufactoryID; public byte btAddressOfCamera; public int iCameraParam; public byte PresetNum; public byte PresetWaitTime; public byte Group; public byte AutoCruiseStatus; public byte Channel; public fixed byte Data[64]; } And the function i use to convert it to byte array[] is static byte[] structtobyte(object obj) { int len = Marshal.SizeOf(obj)

How to get the list of all content controls in the document?

好久不见. 提交于 2019-12-04 12:01:47
I am using interop and I want to get the list of all content controls contained in word document (in the body, shapes, header, footer..). Is this the correct and the best way to do this : public static List<ContentControl> GetAllContentControls(Document wordDocument) { if (null == wordDocument) throw new ArgumentNullException("wordDocument"); List<ContentControl> ccList = new List<ContentControl>(); ; // Body cc var inBodyCc = (from r in wordDocument.ContentControls.Cast<ContentControl>() select r); ccList.AddRange(inBodyCc); // cc within shapes foreach (Shape shape in wordDocument.Shapes) {

How to return a JavaScript 'native' array from a C# method?

…衆ロ難τιáo~ 提交于 2019-12-04 11:52:50
问题 I'm trying to call a C# method from JavaScript by using ActiveXObject : var myobj = new ActiveXObject('myobject'); var arr = myobj.GetArray(); Eventually, arr will contain a SAFEARRAY object, but not JScript array. Is there any way to return native JavaScript object from a C# method? 回答1: You can return a JSON string and then parse into a JavaScript object. There are a number of .NET libraries available to serialize .NET objects into JSON and vice-versa- JSON.NET Microsoft ASP.NET AJAX

How can I add a VC++ DLL as a reference in my C# Visual Studio project?

▼魔方 西西 提交于 2019-12-04 11:35:47
I want to add a VC++ DLL reference into my C# Visual Studio project. But when I try to add it I see, "It is not a valid assembly or COM component". Please suggest how I can use the VC++ DLL as a reference in a C# project. There are two options for using a C++ DLL from C#: either COM interop, or P/Invoke. COM Interop involves creating a COM object in your C++ DLL, and then adding it as a reference. You can use the COM object like a C# object (for the most part) at this point. P/Invoke allows you to call exported functions from C# (think calling standard Win32 API functions from C#). This is

How can I create a jar from some Scala source code?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 11:29:41
How can I create a jar from some Scala source code? I want to use some of that code in a Clojure project of mine. Is there a simpler way than doing batch files as in this SO question ? Thanks, Alex Scala is in no way special when it comes to what you do with the .class files produced by its compiler. Just use the jar command with the c action flag. However, you will need to have the scala-library.jar file in the class-path when you run the program that uses the Scala-compiled .class files. And be careful to use the scala-library.jar for / from the same Scala Development Kit that you used to

How to call C# delegate to pass array of strings from native C simplest way?

会有一股神秘感。 提交于 2019-12-04 11:19:52
I know this can be done by mallocing in C, passing malloced pointer to delegate with parameter type IntPtr, marshalling to string[] and then freeing malloced memory with separate, exported C-function from managed code. My question is: Can this be done simpler way? E.g. : C# delegate parameter is of type string[]? no separate free function to call from managed code EDIT: I tried with delegate signature: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] MyManagedDelegate(string[] values, int valueCount) and fucntion in C: void NativeCallDelegate(char *pStringValues[], int nValues) { if