excel-interop

microsoft.office.interop.excel stays in Process list

◇◆丶佛笑我妖孽 提交于 2019-12-24 07:37:10
问题 When I use the microsoft.office.interop.excel to create Excel file, I always call the quit command at the end. However, more than ever, if I look into the process list of Windows Task manager, I can clearly see that the process is still there and I end up with a bunch of those after a while. I guess this isn't that much of a problem on normal case, but I would still like to prevent that from happening every time. Is there any way to do this ? I can't go on and kill all Excel process because

How to copy contents of Excel UsedRange into an array for faster reading?

百般思念 提交于 2019-12-24 06:31:04
问题 I'm trying to improve the performance of an application that is reading cells from an Excel worksheet row by row. I found this solution https://stackoverflow.com/a/25842904/1462656 You want to do it in one operation: object[,] objectArray = cSheet.get_Range("A1:C4").Value2; dataRange.Value2 = objectArray; Is it assuming all the cells are of type Value2?. In general I would like to know how to get the contents of the UsedRange into a local array for faster access (instead of keep going back

How to copy contents of Excel UsedRange into an array for faster reading?

笑着哭i 提交于 2019-12-24 06:29:48
问题 I'm trying to improve the performance of an application that is reading cells from an Excel worksheet row by row. I found this solution https://stackoverflow.com/a/25842904/1462656 You want to do it in one operation: object[,] objectArray = cSheet.get_Range("A1:C4").Value2; dataRange.Value2 = objectArray; Is it assuming all the cells are of type Value2?. In general I would like to know how to get the contents of the UsedRange into a local array for faster access (instead of keep going back

Remove Ribbon from Excel

纵然是瞬间 提交于 2019-12-24 01:04:35
问题 I'm trying to remove the ribbon bar from the Excel window. Currently I'm using the following code which removes the ribbon. excelApp.ExecuteExcel4Macro("SHOW.TOOLBAR(""Ribbon"",False)") But it also removes everything above the cells including the title bar. I need the title bar so users can move, minimize, maximize and close the window. Ideally I would like to remove the entire ribbon but I would be satisfied if I could minimize the Icons on the Ribbon. I can minimize the ribbon icons by

How can I prevent the green warning triangle from displaying in a formula-bound cell (C# Excel Interop)?

痞子三分冷 提交于 2019-12-24 00:56:40
问题 I've got this formula that generates the correct data: var avgWeeklyDeliveriesCell = (Range)_xlSheetDelPerf.Cells[curDelPerfRow, AVG_WEEKLY_DELIVERIES_COLUMN]; avgWeeklyDeliveriesCell.Value2 = string.Format("=ROUND(AVERAGE(C{0}:I{0}), 2)", curDelPerfRow); The problem is that it overthinks/micro-manages matters, and wonders if an adjacent cell (the one to the left, I presume, "Total Orders") should be included in the formula. Specifically, if I click on the green triangle, a "!" glyph pops out

Microsoft.Office.Interop.Excel Reference in Build Server [duplicate]

混江龙づ霸主 提交于 2019-12-23 13:08:44
问题 This question already has answers here : Is it necessary for the build machine to have Microsoft Office 2007 installed? (3 answers) Closed 4 years ago . I'm using Microsoft.Office.Interop.Excel reference in the windows service application to create excel reports. The application builds fine in DEV machine but in the build machine it fails saying "The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)". It's working in DEV

Interop Excel is slow

房东的猫 提交于 2019-12-23 09:47:30
问题 I am writing an application to open an Excel sheet and read it MyApp = new Excel.Application(); MyBook = MyApp.Workbooks.Open(filename); MySheet = (Excel.Worksheet)MyBook.Sheets[1]; // Explict cast is not required here lastRow = MySheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; MyApp.Visible = false; It takes about 6-7 seconds for this to take place, is this normal with interop Excel? Also is there a quicker way to Read an Excel than this? string[] xx = new string[lastRow];

Importing Excel Charts from Excel to PowerPoint causes `RPC_E_SERVERFAULT` on some machines

本小妞迷上赌 提交于 2019-12-23 04:57:08
问题 This is an irritating one. I have created a method to copy all Excel charts in a workbook to PowerPoint slides. public int ImportExcelChartsFromWorkbookToSlides(int startingSlideIndex, string workbookPath, string[] slideTitles, int chartPosTop, int chartPosLeft = 10, int titleWidth = 680, int titleHeight = 20, int titlePosTop = 90, int titlePosLeft = 20, int titleFontSize = 18) { int slideIndex = startingSlideIndex; int titleIndex = 0; EXCL.Application objExclApp = new EXCL.Application();

LinqToExcel: Distinct values in excel column

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:13:06
问题 This might be a very simple thing for you gurus, but I'm not familiar with C#4 and INTEROP. Therefore, I'm stumped. Here's my problem. I have a excel column that has duplicate data and I want to trim it down to only unique values. Here's what the data looks like: ColA ColB 10 Adam 12 Jane 14 Adam 18 Adam 20 Eve So, in the end I just want unique names from ColB: Adam Jane Eve I know that I can do this by getting all those values into a List and then adding the Distinct functionality to it. But

Get running instances of Excel with VB.NET

戏子无情 提交于 2019-12-23 02:07:22
问题 I have the following working code taken from this answer: Option Compare Binary Option Explicit On Option Infer On Option Strict Off Imports Microsoft.Office.Interop Imports System.Collections.Generic Imports System.Runtime.InteropServices Friend Module Module1 Private Declare Function GetDesktopWindow Lib "user32" () As IntPtr Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowsProc, ByVal lParam As IntPtr) As Boolean Private