excel-interop

LinqToExcel: Distinct values in excel column

◇◆丶佛笑我妖孽 提交于 2019-12-08 20:49:35
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 I think I'm doing something wrong. Anyway, here's my program: Application XLApp = new Microsoft.Office

Add hyperlink to smartart node with interop-excel in c#

一笑奈何 提交于 2019-12-08 11:25:43
问题 I have an c# console application which create an excel worksheet containing a smartart object with the hiearchy layout(OrgChart). I would like to add hyperlinks to the nodes within the org chart, but somehow i can't. In the picture below, i would like to add a hyperlink to "Node 1"(1) which will take me to the "LinkedSheet" sheet(2): with the following code snippet, i tried to add a hyperlink to the sheet "orgChart" where the textFrame of "Node 1"(var name: ndTop) is the anchor and the sheet

How do I write this Excel Interop syntax in EPPLUS syntax

末鹿安然 提交于 2019-12-08 09:23:35
问题 Someone suggested to me a method to improve my code by making it more manageable through the use of objects: string[,] values = new string[15, 35]; //or objects values[7, 7] = "2016"; values[7, 28] = drag24; values[7, 33] = drag25; values[10, 8] = digit1; values[10, 11] = digit2; // etc. Range range = WS.Range[WS.Cells[1, 1], WS.Cells[15, 35]]; range.Value = values; His suggestion, but since I moved from interop to EPPLUS, the following syntax no longer works. Range range = WS.Range[WS.Cells

How do I remove an Excel Chart Legend Entry with C#?

六眼飞鱼酱① 提交于 2019-12-08 04:32:25
问题 I want to remove the legend entry for some, but not all, series in my Excel chart. From my experience it seems as if SeriesCollection.Item(index) and LegendEntries.Item(index) are not related. Given a series n how can I remove only the legend for that series? I'm using Office Interop 2010 with Visual Studio 2010. This is easily accomplished via the GUI by selecting the legend entry, then right clicking and choosing "delete". 回答1: To delete a legend entry you have to know the index of the

how to set values to a two-dimensional Excel range?

我的未来我决定 提交于 2019-12-08 04:19:42
问题 I need to build an excel sheet from a list of test-cases in a specific format in order to upload it it to the server. I've trubles to populate the two dimensional range of "expected" and "actual" in the file. I use the same methods in order to populate the headers, which is a one-dimensional array, and the steps (which is two-dims). The flow is: Defunding the TestCase range (some headers + steps). Let's say: A1 to E14 for the 1st iteration. Depunding a sub (local) range within the testCase

Programmatically export Excel files to XML using xmlMaps

廉价感情. 提交于 2019-12-08 04:10:26
With the Excel addin OfficeExcel2003XMLToolsAddin I've been able to define XML mapping for an Excel Worksheet (this addin converts a range to a XML list) and now I'm able to manually save the Excel file as a XML file, using Save as. Excel correctly produces something like <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Row> <brand>Brand1</brand> <Italian>Description1</Italian> <English>Description2</English> </Row> <Row> <brand>Brand2</brand> <Italian>Description3</Italian> <English>Description4</English> </Row> </Root> Now,

COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

杀马特。学长 韩版系。学妹 提交于 2019-12-07 14:22:33
问题 When I run the following code, I get the exception below: ''# NOTE: ExcelApp is a Private main form variable Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename) Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report") ''# Retreive data from sheet ReleaseCOM(ReportSheet) ReportBook.Close(True) ''# Error raised here ReleaseCOM(ReportBook) ReleaseCOM(ReportBooks) ERROR: COMException was unhandled The object invoked

Strange error on Excel Workbook input

六月ゝ 毕业季﹏ 提交于 2019-12-07 11:39:08
问题 For the current code: String currentPath = Directory.GetCurrentDirectory(); OpenFileDialog op = new OpenFileDialog(); op.InitialDirectory = currentPath; if (op.ShowDialog() == DialogResult.OK) currentPath = op.FileName; else { toolStripStatusLabel1.Text = "Failed to Load Workbook"; toolStripStatusLabel1.Visible = true; } Workbook wb = new Workbook(excel.Workbooks.Open(currentPath)); I recieve the error: System.Runtime.InteropServices.COMException was unhandled Message=Retrieving the COM class

Exporting Excel Charts as Images

依然范特西╮ 提交于 2019-12-07 11:03:55
问题 I've written the following simple C# console application to export all the charts from an Excel Workbook. It works just fine unless the chart has not been scrolled to since opening the document , in which case an empty image file is generated. using Excel = Microsoft.Office.Interop.Excel; using System; using System.Diagnostics; namespace ExcelExporter { class ChartExporter { const string EXPORT_TO_DIRECTORY = @"C:\Users\Sandy\Desktop\Excel\Charts"; static void Main(string[] args) { Excel

Can you paste a block of cells in one shot using Excel Interop w/o using the clipboard?

老子叫甜甜 提交于 2019-12-07 09:44:23
问题 I'm trying to transfer data from a DataSet into an Excel workbook. Unfortunately, I need more control than I can get by simply linking to Excel via ADO.NET and using standard SQL to select and insert the data, so I'm using excel interop. My original algorithm involved looping through all the tables/rows/items of the data set and individually setting the Formula of each cell in Excel. This worked, but it was taking nearly half a minute to transfer all the data. I decided to try a different