excel-interop

How to create dropdownlist on Excel 2003

瘦欲@ 提交于 2019-12-24 23:01:19
问题 I'm creating Excel files using AutomationFactory.CreateObject("Excel.Application") . I'm using these lines of codes to create a dropdown list: mySheet.Range("A1").Validation.Add(Type:=Interop.Excel.XlDVType.xlValidateList, _ AlertStyle:=Interop.Excel.XlDVAlertStyle.xlValidAlertStop, _ [Operator]:=Interop.Excel.XlFormatConditionOperator.xlBetween, Formula1:="=List!$C$3:$C$903") The formula (Formula1:="=List!$C$3:$C$903") returns 900 rows In Excel 2010 it works perfectly, however, in Excel 2003

Creating excel file in C#

一曲冷凌霜 提交于 2019-12-24 19:33:20
问题 Its my first experience with excel file using C#. As a demo, I wrote a single line in excel file and it worked but now I am trying to insert all the rows of DataTable but it gives the following error: "HRESULT: 0x800A03EC" Here is the code: for (int i = 0; i < table.Rows.Count; i++) { xlWorkSheet.Cells[i, 1] = table.Rows[i]["Ref"].ToString(); xlWorkSheet.Cells[i, 2] = table.Rows[i]["Name"].ToString(); } Please tell me how can I fix it? 回答1: Use Range.Value instead. Worksheet.Cells property is

How to insert specific excel row into datagridview using excel rowindex

佐手、 提交于 2019-12-24 19:17:14
问题 I am performing search within excel workbook using small c# application using below method public void SearchExcelFiles(string FilePath) { string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";"; Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook oWB; Microsoft.Office.Interop.Excel.Range currentFind = null; Microsoft.Office.Interop

Cells.Formula=“=CONCATENATE(…)” Exception 0x800A03EC

こ雲淡風輕ζ 提交于 2019-12-24 16:18:13
问题 I'm writing a VB.NET application that generates an Excel file. My intention here is to write a particular formula that uses CONCATENATE in a cell. Now, the following line of code fires the above exception: 0) tSheet.Cells(tIncRow + ItemIndex * PixelIndex + PixelIndex, 2).Formula = "=CONCATENATE(" & Pixels(PixelIndex) & ";Batches!J3)" The following row does NOT raise the exception. (It's simply the row above without the = at the beginning. The fact that it doesn't raise the exception means

Excel.Range Copy() works very slowly

你说的曾经没有我的故事 提交于 2019-12-24 14:29:45
问题 I'm building a report in which try to copy the previous row cell styles in the following for (int i = 0; i < DataSource.Length; i++) { int rowNumber = i + s; Excel.Range RngToCopy = ObjWorkSheet.get_Range("A" + rowNumber.ToString(), "K" + rowNumber.ToString()); Excel.Range r = ObjWorkSheet.get_Range("A" + (rowNumber + 1).ToString(), "K" + (rowNumber + 1).ToString()); RngToCopy.Copy(Type.Missing); r.Insert(Excel.XlInsertShiftDirection.xlShiftDown); r.PasteSpecial(Excel.XlPasteType

Accessing a table in an excel spreadsheet using C#

∥☆過路亽.° 提交于 2019-12-24 12:44:34
问题 I'm writing a program (in C#, using Microsoft.Office.Interop.Excel) that reads in an Excel spreadsheet and applies filters, etc. to the data within. However, I'm struggling with a few issues, namely how to "get" a table object representing the table of data I am working with. I'd like to be able to access columns by their headers as well, so I assumed that I would require the DataTable namespace. I can't seem to figure out what to do, however. Here is the rough framework of my code: private

Workbooks.Open method throwing HRESULT: 0x800A03EC

亡梦爱人 提交于 2019-12-24 12:34:39
问题 I am opening an excel file using object missing = Type.Missing; xlWorkBook = xlApp.Workbooks.Open(strFilePath, missing, false, missing, missing, missing, true, missing, missing, missing, missing, true, missing, missing, missing); and it throws HRESULT: 0x800A03EC It was working fine with office 2010 but after updating office libraries to version 15 and when deployed to server which had office 2013. I started getting this message. I have also tried giving permission to Excel Object in

Find last cell with values using indexes

断了今生、忘了曾经 提交于 2019-12-24 11:08:38
问题 I try to find the last cell in a column that contains values. I know I can use something like: Dim findme As Range = excel.Range("A1:A" & lastrow.row) but I am looking for a way not to use this column-character format. Something like this VBA format Dim rng as range with myWorksheet LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row rng = .Range(.Cells(1,1), .Cells(LastRow, 1)) end with 回答1: I created an helper class to solve this problem: Imports Excel = Microsoft.Office.Interop.Excel Public

Range.find in C# with multiple 'what'

99封情书 提交于 2019-12-24 10:14:00
问题 Stuck in writing this thing... I am writing a C# Winform app in which I am looking up certain values in an Excel file in a certain column. I am using Excel.Range.Find but I could be wrong in this choice of course. I want to find the Excel adress of the cell with either €,EUR,USD,CAD,GBP, or NOR. But Range.Find only seems to handle one at a time? What would be the best way to proceed? Here's a snippet of my code: Excel.Application xlApp = (Excel.Application)System.Runtime.InteropServices

How can I change the text of the automatically added labels on these Excel Interop PivotTables' row and column fields?

坚强是说给别人听的谎言 提交于 2019-12-24 08:58:46
问题 I've got a row field that allows the user to filter rows: pvt.PivotFields("Description").Orientation = XlPivotFieldOrientation.xlRowField; ...and a column field that allows the user to filter columns: var monthField = pvt.PivotFields("MonthYr"); monthField.Orientation = XlPivotFieldOrientation.xlColumnField; ...but when the PivotTable is generated, it displays "Row Labels" where I want it to say "Description" and "Column Labels" where I want it to say "Month": How can I change this default