interop

Opening .dat (tab delimited file) in Excel, save as .xls

匆匆过客 提交于 2020-02-14 19:28:13
问题 I am trying to open a .dat file in Excel, which is tab delimited, and then have it save out as a .xls file. So far, I can read in the file and save it as the .xls file but for some reason, all the values are in the first column and it does not tab delimit them. (If I open up the file in Excel without my program, it tab-delimits perfectly) These are the two lines of code that I am using to open and resave the file. xlWorkBook = xlApp.Workbooks.Open(f, 0, true, 5, "", "", true, Microsoft.Office

C# property exposed to VBA (COM) : Run-time error '424': Object required

爷,独闯天下 提交于 2020-02-14 18:37:57
问题 This C# code is in a .NET 4.5 ComVisible assembly: C# Code [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("22341123-9264-12AB-C1A4-B4F112014C31")] public interface IComExposed { double[] DoubleArray { get; set; } object[] ObjectArray { get; set; } object PlainObject { get; set; } double ScalarDouble { get; set; } } [ClassInterface(ClassInterfaceType.None)] [Guid("E4F27EA4-1932-2186-1234-111CF2722C42")] [ProgId("ComExposed")] public class ComExposed : IComExposed { public double[]

C# property exposed to VBA (COM) : Run-time error '424': Object required

扶醉桌前 提交于 2020-02-14 18:36:33
问题 This C# code is in a .NET 4.5 ComVisible assembly: C# Code [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("22341123-9264-12AB-C1A4-B4F112014C31")] public interface IComExposed { double[] DoubleArray { get; set; } object[] ObjectArray { get; set; } object PlainObject { get; set; } double ScalarDouble { get; set; } } [ClassInterface(ClassInterfaceType.None)] [Guid("E4F27EA4-1932-2186-1234-111CF2722C42")] [ProgId("ComExposed")] public class ComExposed : IComExposed { public double[]

Deleting all QueryTables in Excel 2007 Workbook

北战南征 提交于 2020-02-05 06:43:49
问题 Using Excel Interop, I'm attempting to loop through all QueryTables in all Worksheets and delete them. I've got this code, which works: > // loop through each Worksheet > for (int i = 1; i <= workbook.Sheets.Count; i++) > { > sheet = (Worksheet)workbook.Sheets.get_Item(i); > > // loop through each queryTable on each Worksheet > int queryTableCount = sheet.QueryTables.Count; > for (int j = 1; j <= queryTableCount; j++) { > sheet.QueryTables.Item(1).Delete(); > } > } This works just fine for

How to get CustomDocumentProperties using Excel Interop?

自闭症网瘾萝莉.ら 提交于 2020-02-02 06:48:29
问题 The below code is used to get the custom document properties for Excel workbook. var xlApp = Globals.ThisAddIn.Application; // This works in VSTO Excel Add-in var xlApp = new global::Microsoft.Office.Interop.Excel.Application(); // This doesn't work anywhere xlApp.Visible = true; global::Microsoft.Office.Interop.Excel.Workbook workbook = xlApp.Workbooks.Open(file, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type

How to get CustomDocumentProperties using Excel Interop?

烂漫一生 提交于 2020-02-02 06:48:10
问题 The below code is used to get the custom document properties for Excel workbook. var xlApp = Globals.ThisAddIn.Application; // This works in VSTO Excel Add-in var xlApp = new global::Microsoft.Office.Interop.Excel.Application(); // This doesn't work anywhere xlApp.Visible = true; global::Microsoft.Office.Interop.Excel.Workbook workbook = xlApp.Workbooks.Open(file, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type

Attach to existing Excel Instance

安稳与你 提交于 2020-02-02 05:47:29
问题 I'm trying to determine whether or not an instance of Excel of running with a particular file open, and if so attach to it so I can control that instance. I've searched around and the majority of what I've got have come from this question. It has a reference to another site, but unfortunately it's dead for me so I cannot read up on it. My code so far is; //Is Excel open? if (Process.GetProcessesByName("EXCEL").Length != 0) { Process[] processes = Process.GetProcesses(); foreach (Process

Changing an Excel cell's backcolor using hex results in Excel displaying completely different color in the spreadsheet

巧了我就是萌 提交于 2020-01-31 04:31:08
问题 So I am setting an Excel cell's Interior Color to a certain value, like below: worksheet.Cells[1, 1].Interior.Color = 0xF1DCDB; However, when I then open up the spreadsheet in Excel, I see that the color that came out is completely different (in the above case, the color in the resulting spreadsheet is 0xDCDCEF). I tried a few different colors and it always changes it, and I don't see a pattern. Is there any reason for this? I even tried setting the color by writing Color.FromArgb(241, 220,

receiving strings through interop

随声附和 提交于 2020-01-30 08:12:29
问题 I'm having trouble getting a string back from some c code I wrote. First some generally unrealated background info: I'd like to receive the user readable string for a TAPI TSP from the TAPI API. I've implemented a semi workable TAPI solution relying on matching driver names to stored strings, but would like to change this to work on permanant line id's instead, as one of our customers has an (Alcatel) PBX that refuses to work any other way. In C, I define the function in my header file as: _

System.Data.SQLite from NuGet, interop dll not copied to output directory

北城以北 提交于 2020-01-29 10:21:52
问题 I installed System.Data.SQLite Core (x86/x64) from NuGet. It built without warnings but threw System.DllNotFoundException regarding SQLite.Interop.dll . I rigged my projects to copy the SQLite.Interop.dll from under the NuGet package's directory to the output directory, and now it runs without the exception. Why didn't the NuGet package configure my projects to put the appropriate interop dll in the output directory? It seems like it should be able to do that. I'm new to interop and I