• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1177
  • Last Modified:

excel.interop reference

Ok, I lost a reference.
500 points to the one who can find it.

my code lines are:
xlApp.Cells[rowIndex, i + 1].Interior.Color = ColorTranslator.ToOle(Color.Aqua);
xlApp.Cells[rowIndex, i + 1].NumberFormat = "@";

both Interior and NumberFormat were working yesterday, but now they are giving me the error:
Error      1      'object' does not contain a definition for 'Interior' and no extension method 'Interior' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)      C:\Users\Evan\documents\visual studio 2012\Projects\DAT2MSSQL2XLS\DAT2MSSQL2XLS\Classes\DAT2XLS.cs      64      46      DAT2MSSQL2XLS

I am using .NET 3.5

Here's my page references:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Drawing;

Here's my project references:
I think I lost a reference somewhere, and I don't know which one.
The Microsoft.office.Interop.Excel is Version 12.

Evan Cutler
Evan Cutler
1 Solution
Michael FowlerSolutions ConsultantCommented:
First thing to try would be removing Microsoft.Office.Interop.Excel from the project references and then add it again.

Arno KosterCommented:
it could also have something to do with the object 'rowIndex'. does it have a value and if so, does it lead to a cell ?

i would expect something like xlApp.xlWorkbook.xlWorksheet.Cells[...] instead of xlApp.Cells[...]
Evan CutlerAuthor Commented:
That did it.
Thanks.  I don't know what happened.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now