0

I get this error when I want to change from AxMicrosoft.Office.Interop.Owc11 to Microsoft.Office.Interop.Excel , from AxSpreadsheet currentSpreadSheet = GetTestSheet to SpreadsheetGear IWorkbook = GetWorkbook

'Microsoft.Office.Interop.Excel.SpreadsheetGear' does not contain a definition for 'ActiveCell' and no extension method 'ActiveCell' accepting a first argument of type 'Microsoft.Office.Interop.Excel.SpreadsheetGear' could be found (are you missing a using directive or an assembly reference?)

There is an error at ActiveCell

Object searchRange = IWorkbook.ActiveCell.Cells[1, 1];
emma
  • 11
  • 3
  • do you want use SpreadsheetGear.dll or Microsoft.Office.Interop.Excel dll? – Technovation May 20 '15 at 08:36
  • SpreadsheetGear.dll, I thought SpreadsheetGear.dll use together with Microsoft.Office.Interop.Excel. I am first time doing this. May you guide me what to do for the following? – emma May 20 '15 at 12:32
  • what is the reference for SpreadsheetGear.dll instead of using Excel = Microsoft.Office.Interop.Excel;? – emma May 20 '15 at 12:51

1 Answers1

0

It seems you wanna use SpreadsheetGear not Microsoft.Office.Interop.Excel, they are different assemblies. SpreadsheetGear is a third party library and Microsoft.Office.Interop.Excel comes with .net. the error tells you where is the problem:

Microsoft.Office.Interop.Excel.SpreadsheetGear' does not contain a definition for 'ActiveCell

ActiveCell is property of IWorksheetWindowInfo Interface in SpreadsheetGear Namespace. ActiveCell is single active cell within the current selection. i'm thinking you wanna read first cell of used range in your sheet. first of all you should reference this:

using SpreadsheetGear;

and code like this:

  //this line will create  a new workbook
  IWorkbook workbook = Factory.GetWorkbook();
  IWorksheet worksheet = workbook.ActiveWorksheet;
  //this line represent first cell in used range cells
  SpreadsheetGear.IRange firstCell = worksheet.UsedRange.Cells["A1"];
Technovation
  • 387
  • 2
  • 12