안녕하세요!

Excel개체라이브러리에는버전번호가포함되어있는데,Excel2000의버전은9.0이고Excel2002의버전은10.0입니다.

참조추가대화상자에서확인을눌러선택내용을수락합니다.선택한라이브러리에대해래퍼를만들것인지묻는메시지가나타나면예를누릅니다.
그리고다음과같은소스를넣으시고사용하시면될것입니다.

Excel.ApplicationobjApp;
Excel._WorkbookobjBook;
Excel.WorkbooksobjBooks;
Excel.SheetsobjSheets;
Excel._WorksheetobjSheet;
Excel.Rangerange;

try
{
objApp=newExcel.Application();
objBooks=objApp.Workbooks;
objBook=objBooks.Add(Missing.Value);
objSheets=objBook.Worksheets;
objSheet=(Excel._Worksheet)objSheets.get_Item(1);

range=objSheet.get_Range("A1",Missing.Value);

//Settherangevalue.
//EXCEL9Use:
range.Value="Hello,World!";
//EXCEL10Use:
//range.set_Value(Missing.Value,"Hello,World!");

//ReturncontrolofExceltotheuser.
objApp.Visible=true;
objApp.UserControl=true;
}
catch(ExceptiontheException)
{
StringerrorMessage;
errorMessage="Error:";
errorMessage=String.Concat(errorMessage,theException.Message);
errorMessage=String.Concat(errorMessage,"Line:");
errorMessage=String.Concat(errorMessage,theException.Source);

MessageBox.Show(errorMessage,"Error");
}


그리고참고로.NET에서는OLEAutomation은지원을하지않습니다.

도움이되셨는지모르겠습니다.

MicrosoftCommunitySpecialist

강성재

.NETisMySoul...NothingBut.NET

Posted by 퓨전마법사
,