excel-interop

Is there a “sister” function to “AutoFilter” in Excel Interop that works for columns instead of rows?

Deadly 提交于 2020-01-11 14:30:08
问题 The "AutoFilter" function in Excel Interop allows you to filter what data in the rows beneath a column display. I need a similar function to allow the user to select which columns to hide. For example and specifically, if there is a set of columns 3..15 (C..0) going from "Sep 15" to "Sep 16" with the obvious months in between them ("Oct 15", etc.) I want the user to be able to select any subset of those columns to view. Those deselected would "disappear" How can this be accomplished? I have

Interop Excel UsedRange Rows Count incorrect

断了今生、忘了曾经 提交于 2020-01-11 06:37:08
问题 I am trying to read an excel spreadsheet into memory but when I use worksheet.UsedRange.Rows.Count, the value return is incorrect. I have 1670 rows of data in my spreadsheet but the row count brings back 694 rows. var excelApp = new Microsoft.Office.Interop.Excel.Application {Visible = false}; var workbook = excelApp.Workbooks.Open(_mirrorFileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type

Excel Interop Workbooks.Open inconsistencies

偶尔善良 提交于 2020-01-07 03:50:22
问题 I have a process that is opening multiple workbooks var exApp = new Excel.Application(); Excel.Workbook ONE; Excel.Workbook TWO; Excel.Workbook THREE; ONE = exApp.Workbooks.Open(ONELocation); TWO = exApp.Workbooks.Open(TWOLocation); THREE = exApp.Workbooks.Open(THREELocation); Console.WriteLine("All Excel workbooks opened successfully\n"); Sometimes it runs with no issues. Sometimes though I get the following exception on crash System.Runtime.InteropServices.COMException: 'The remote

Strange behaviour of “Call was rejected by callee.” exception with Excel [duplicate]

浪尽此生 提交于 2020-01-06 11:49:43
问题 This question already has answers here : how to solve Exception:Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) in C#? (9 answers) Closed last year . I have an application that includes data exporting to Excel. And it works fine on most computers. However, there're two that throw Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) when I try to open Worksheet with get_item() . The funny thing is, when I set up

Unexpected behavior when refreshing internal data connections in Excel

心已入冬 提交于 2020-01-05 23:29:05
问题 I have faced a big and inconvenient problem with Excel spreadsheets that have internal data connections (queries that selects ranges of the own workbook) in them. I wiil start by showing the problem e exposing how to reproduce it. Problem: if I have some internal connetion and another instance (pay attention, instance, not other workbook) was already open, when refreshing that connection, the same workbook (which have the internal connection) is instantly opened in readonly mode in another

Closing Excel Workbook - System.Runtime.InteropServices.COMException : Exception from HRESULT: 0x800A03EC

百般思念 提交于 2020-01-05 05:30:14
问题 I've put in the following method that returns a value from an XLS file cell : public static string ReadFromExcel(string filePath, int sheetNum, int xCell, int yCell) { List<string> rowValue = new List<string> {}; var ExcelFilePath = @filePath; Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(ExcelFilePath); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[sheetNum]; Excel.Range xlRange = xlWorksheet.UsedRange; int rowCount = xlRange.Rows

starting excel application with addins from c# application

眉间皱痕 提交于 2020-01-03 16:12:26
问题 I have a c# app and it needs to create an excel application & then open a workbook. The issue is I need a Bloomberg addinn to be loaded when excel opens. The only way I have found is in this post working example. This indeed starts excel and able to use the Bloomberg functions. However I was wondering if there was a way to cast myXl to xlApp where xlApp is of type Microsoft.Office.Interop.Excel.Application? var myXl = Process.Start("excel.exe"); The reason being is I have a library which has

starting excel application with addins from c# application

岁酱吖の 提交于 2020-01-03 16:10:06
问题 I have a c# app and it needs to create an excel application & then open a workbook. The issue is I need a Bloomberg addinn to be loaded when excel opens. The only way I have found is in this post working example. This indeed starts excel and able to use the Bloomberg functions. However I was wondering if there was a way to cast myXl to xlApp where xlApp is of type Microsoft.Office.Interop.Excel.Application? var myXl = Process.Start("excel.exe"); The reason being is I have a library which has

How should I declare a Microsoft.Office.Interop.Excel.Worksheet so I can close it in C#?

天涯浪子 提交于 2020-01-02 20:18:08
问题 I am having a hard time making sure my COM objects are closing so I am not leaving an EXCEL.EXE process running in the background. I have learned that the double dot and chaining of declarations is bad as this could leave COM objects hanging around. Does anyone know how to fix this line of code so I can properly close and release the worksheet COM object? worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[strName]; EDIT: I have tried using app.Quit() when I am done

Excel Interop: Creating instance with Task.Run results in exception System.EntryPointNotFoundException

送分小仙女□ 提交于 2020-01-02 08:31:26
问题 Here is my minimal example producing the problem: using System.Runtime.InteropServices; using System.Threading.Tasks; using Excel = Microsoft.Office.Interop.Excel; class Program { static void Main(string[] args) { Task.Run(() => { Excel.Application app = new Excel.Application(); if (app != null) { app.Quit(); Marshal.FinalReleaseComObject(app); app = null; } }); } } This results in the following exception: The last part in Japanese says the "EventSetInformation" of DLL advapi32.dll entry