Tag: visual studio 2010

无法杀死Excel进程

我正在使用下面的代码来做一些复制和粘贴excel文件: Imports Excel = Microsoft.Office.Interop.Excel Imports System.IO Imports System.Runtime.InteropServices Private Sub btnCombine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCombine.Click Dim xlAppSource As New Excel.Application Dim xlAppTarget As New Excel.Application Dim xlWbSource As Excel.Workbook Dim xlWbTarget As Excel.Workbook Dim xlsheetSource As Excel.Worksheet Dim xlsheetTarget As Excel.Worksheet Dim xlRangeSource As Excel.Range Dim xlRangeTarget As Excel.Range […]

C#&Excel:Value2没有定义

我需要一种通过c#读取Excel文件的方法。 我find一个例子https://coderwall.com/p/app3ya/read-excel-file-in-c 我创build了一个独立的程序来testing它,它按我的预期工作。 我将代码作为子程序添加到现有程序中并遇到错误。 第一个错误,“不能隐式转换types的对象”Microsoft.Office.Interop.Excel._Worksheet。存在明确的转换。 第二个错误“Object”不包含“Value2”的定义。 我解决了第一个错误,将(Excel._Worksheet)添加到xlWorkbook.Sheets [1]; 我找不到Value2的第二个,需要你的帮助:“错误98'对象'不包含'Value2'的定义,并且不能find接受types'object'的第一个参数的扩展方法'Value2' (你是否缺less使用指令或程序集引用?)“ 这是我的代码: using System; using System.Collections.Generic; using System.Collections;ArrayList, ListBox, ComboBox, etc. using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using XView.Properties; using System.Reflection; using ZedGraph; using System.IO; using System.Management; using System.Threading; using System.Diagnostics; using System.Runtime.InteropServices; using Excel = Microsoft.Office.Interop.Excel; private void readExcelFile(ArrayList […]

使用Activex控件查看Excel文件

我想查看我正在试图使用Visual Studio 2010构build的Windows应用程序中的Excel文件。 我怎样才能做到这一点 ? 有没有任何优秀的ActiveX控件。 build议热烈欢迎…. 请帮忙

颜色使用winforms excel细胞

您好我想出口的几个button的颜色到Excel中button代表一个网格,并dynamic创build。 代码我似乎给我的颜色的名称,而不是导出到Excel时的单元格的实际颜色。 for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { worksheet.Cells[i + 2, j + 1] = (buttons[i][j].BackColor); } }

使用excel和visual studio 2010时出现“Class not registered”错误

你好,我试图从Excel中导入数据到可视化的基本variables,但即时通讯一个奇怪的错误。 我没有添加对微软excel com库的引用。 Imports Microsoft.Office.Interop.Excel Module Module1 Sub Main() ExtraerCostos() End Sub Public Sub ExtraerCostos() Dim numero As String Dim aux As String Dim costos(20) As Double Dim cant As Integer Dim excelApp As New Microsoft.Office.Interop.Excel.Application Dim workbook As New Microsoft.Office.Interop.Excel.Workbook ' The error points to this line Dim sheet As New Microsoft.Office.Interop.Excel.Worksheet excelApp = […]

将dynamic标签文本导出到Excel

我有一个小程序,在flowLayoutPanel1中生成一些dynamic标签我试图将这些标签的文本导出到Excel,但我得到的是最后一个标签的值。 这是我的导出类: class Export { public Export(bool defaultBackgroundIsWhite) { this.defaultBackgroundIsWhite = defaultBackgroundIsWhite; app = new Application(); app.Visible = true; workbook = app.Workbooks.Add(1); worksheet = (Worksheet)workbook.Sheets[1]; } public void Do(string excelName, System.Windows.Forms.Label names) { for (int i = 0; i <= 5; i++) { AddNames(i,0,names); } } private void AddNames(int row, int col, System.Windows.Forms.Label lbls) { […]

使用VS13在C#中声明variables时出现奇怪的错误

所以我有导入的办公室库,我说using Microsoft.Office.Interop; 我正在尝试创build一个方法来检查是否打开Excel工作簿。 由于这个错误,还没有取得任何进展。 当我声明Excel.Application exApp; 它说types或命名空间名称'excel'找不到。 它说我需要声明它说Microsoft.Office.Interop.Excel.Application exApp; 我真的不认为我在这里做错了什么…我的import没有错误.. using Microsoft.Office.Interop; namespace Month_End_Closing { public partial class Step1Form : Form { public Step1Form() { InitializeComponent(); } static bool IsOpened(string wbook) { bool isOpened = true; Excel.Application exApp; return isOpened; } } }

对于Excel值,不能将types“double”转换为“string”

我正在加载一个Excel文件,正如在网上的许多地方所表明的那样。 OpenFileDialog chooseFile = new OpenFileDialog(); chooseFile.Filter = "Excel files (*.xls,*.xlsl)|*.xls;*.xlsx"; if (chooseFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { selectedFileName = chooseFile.FileName; textBox1.Text = selectedFileName; Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); Workbook wb = excel.Workbooks.Open(selectedFileName); Sheets excelSheets = wb.Worksheets; string currentSheet = "Sheet 1"; excelWorksheet = (Worksheet)excelSheets.get_Item(currentSheet); Range usedRange = excelWorksheet.UsedRange; Range lastCell = usedRange.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing); lastRow = lastCell.Row; […]

Webbrowser控件中的Excel从其他文件中lockingExcel

描述 我正在加载一个Excel文件到WinForm浏览器控件对象中。 加载后,我可能需要打开其他Excel文件。 但是,当浏览器控件被加载时,它会阻止在使用双击时加载另一个工作簿。 但是,如果我开始 – >运行Excel应用程序,然后文件 – >打开文档,它会加载,我可以在Web浏览器中的工作簿和刚才打开的工作簿之间进行交换。 我使用.NET参考Microsoft.Office.Internet.Excel 14.0.0.0。 有没有反正打开文件时双击浏览器控件加载? 在WebBrowser控件中加载Excel文件的代码 protected Microsoft.Office.Interop.Excel.Application _excelApp = null; protected Workbook _workbook = null; protected Worksheet _worksheet = null; //Load the Excel file in the WebBrowser control this.webBrowser.Navigate("MyFile.xls", false); //Get the ActiveXinstance from the WebBrowser Container SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)this.webBrowser.ActiveXInstance; //Make the web browser silent so […]

使用VS2010和Excel 2010访问FormatConditionexception

当我尝试访问FormatConditions集合中的FormatCondition项目时,出现以下exception。 无法将“System .__ ComObject”types的COM对象转换为接口types“Microsoft.Office.Interop.Excel.FormatCondition”。 此操作失败,因为IIC“{00024425-0000-0000-C000-000000000046}”接口的COM组件上的QueryInterface调用失败,原因是出现以下错误:没有此类接口支持(exception来自HRESULT:0x80004002(E_NOINTERFACE)) 。 我正在使用VS2010 SP1,C#,Excel 2010 32位 到目前为止,我创build了一个Excel电子表格,并将条件格式添加到单元格B3。 在代码I中: 打开电子表格。 获得细胞b3 validationFormatConditions.Count返回1。 我遇到以上exception,当我尝试以下: fmtCond = (Excel.FormatCondition) testCell.FormatConditions.Item(1); 我使用的代码似乎在另一台PC上构buildw / VS2005和Excel 2007时工作正常。