Click here to Skip to main content
15,904,817 members
Home / Discussions / C#
   

C#

 
GeneralRe: Subclassing The Desktop Pin
Rocky Moore1-Aug-03 21:21
Rocky Moore1-Aug-03 21:21 
GeneralRe: Subclassing The Desktop Pin
J. Dunlap1-Aug-03 21:26
J. Dunlap1-Aug-03 21:26 
GeneralRe: Subclassing The Desktop Pin
Rocky Moore1-Aug-03 21:55
Rocky Moore1-Aug-03 21:55 
GeneralRe: Subclassing The Desktop Pin
Nick Parker2-Aug-03 1:57
protectorNick Parker2-Aug-03 1:57 
GeneralRe: Subclassing The Desktop Pin
leppie2-Aug-03 4:42
leppie2-Aug-03 4:42 
GeneralRe: Subclassing The Desktop Pin
Nick Parker2-Aug-03 5:58
protectorNick Parker2-Aug-03 5:58 
QuestionHow to extract a table cell's textbox data? Pin
jmelgar1-Aug-03 7:20
jmelgar1-Aug-03 7:20 
AnswerRe: How to extract a table cell's textbox data? Pin
Ista1-Aug-03 9:10
Ista1-Aug-03 9:10 
QuestionApplication updater? Pin
Arun Bhalla1-Aug-03 7:01
Arun Bhalla1-Aug-03 7:01 
QuestionDrag and Drop Rows on DataGrid, Anyone? Pin
Khang Nguyen1-Aug-03 6:25
Khang Nguyen1-Aug-03 6:25 
AnswerRe: Drag and Drop Rows on DataGrid, Anyone? Pin
Ista1-Aug-03 9:11
Ista1-Aug-03 9:11 
GeneralRe: Drag and Drop Rows on DataGrid, Anyone? Pin
Khang Nguyen1-Aug-03 10:11
Khang Nguyen1-Aug-03 10:11 
Questionstring to int, double? Pin
alma1-Aug-03 5:09
alma1-Aug-03 5:09 
AnswerRe: string to int, double? Pin
mikemilano1-Aug-03 5:26
mikemilano1-Aug-03 5:26 
AnswerRe: string to int, double? Pin
Nick Parker1-Aug-03 5:40
protectorNick Parker1-Aug-03 5:40 
AnswerRe: string to int, double? Pin
Ista1-Aug-03 5:57
Ista1-Aug-03 5:57 
Generalpress enter anywhere in form to activate button Pin
mikemilano1-Aug-03 5:07
mikemilano1-Aug-03 5:07 
GeneralRe: press enter anywhere in form to activate button Pin
Valeria Bogdevich1-Aug-03 5:33
Valeria Bogdevich1-Aug-03 5:33 
GeneralConvincing web service migration Pin
Steve Severance1-Aug-03 4:36
Steve Severance1-Aug-03 4:36 
GeneralRe: Convincing web service migration Pin
Daniel Turini1-Aug-03 5:00
Daniel Turini1-Aug-03 5:00 
GeneralRe: Convincing web service migration Pin
Ista1-Aug-03 6:03
Ista1-Aug-03 6:03 
GeneralExcel in C# Pin
don7cry1-Aug-03 0:50
don7cry1-Aug-03 0:50 
GeneralRe: Excel in C# Pin
Philip Fitzsimons1-Aug-03 2:28
Philip Fitzsimons1-Aug-03 2:28 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07172003.asp[^]

is pretty good - tells you how to install the PIA.

however you can simplyfy the code to:

using Excel;
using Microsoft.Office.Core;
using System.Reflection;

namespace whaterever
{

class ExcelToWhatever
{
Excel.Application _excel = null;

		[STAThread]
		static void Main(string[] args)
		{
			ExcelToWhatever app = new ExcelToWhatever();

		}

		public ExcelToWhatever()
		{
			_excel = new Excel.ApplicationClass();
			_excel.Visible = true;

			try
			{
				Process();
			}
			finally
			{
				_excel.Quit();
			}
		}

		void Process()
		{
			Workbook workbook = _excel.Workbooks.Open(@"whatever.xls",
				Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
				Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
			ProcessSheet((Worksheet)workbook.Worksheets["sheet1"]);
		}		
		void ProcessSheet(Worksheet worksheet)
		{
				Range aCell = (Range)worksheet.Cells[1, 2];
				string cellText = aCell .Value2.ToString().Trim();
		}

}

}





"When the only tool you have is a hammer, a sore thumb you will have."

GeneralRe: Excel in C# Pin
Jesse Squire1-Aug-03 3:07
Jesse Squire1-Aug-03 3:07 
GeneralRe: Excel in C# Pin
Ista1-Aug-03 6:20
Ista1-Aug-03 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.