Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Excel could not be found - missing assembly reference?

Hi, I did get this error in my error list while compiling the project. Previously the project are done with MS Office Excel 2003, and currenlty i am using Excel 2007. In my system i don't have MS office 2003. In my project, my references i did add Excel and Microsoft.Office.Core.

The error is ->
The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)      

private int findColumnDept(Excel.Worksheet Ws)

Error was underline in "Excel"

private int findColumnDept(Excel.Worksheet Ws)
		{
		
			int no=1;
			string CellValue="";
			int retryCount=0;
			bool EmptyCellAllowed=true;
			do 
			{
				//listBox1.Items.Add(worksheet.getCells[i,1].ToString());
					
				Excel.Range range1 = Ws.get_Range( "A"+no, "A" + no);
				no++;	
					
					
				
				if (range1.Cells.Value2!=null)
				{
					CellValue=range1.Cells.Value2.ToString().Trim();
					EmptyCellAllowed=false;

				}
				else
				{
					retryCount++;
					CellValue="";
					if (retryCount>15)
					{
						EmptyCellAllowed=false;
						no=0;		
					}
					
				
				}
			}while ((CellValue.Length>0)||(EmptyCellAllowed)) ;
			

			return no-1;

		}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rama Tito

ASKER

Hi, i did manage to solve after

using Excel = Microsoft.Office.Interop.Excel;

Thank you.
glad to help you