C#에서 Microsoft.Office.Interop.Excel
네임 스페이스를 사용하여 Excel 워크 시트에 액세스하고 있습니다.C에서 Excel 워크 시트 셀에 액세스하는 방법 #
워크 시트의 특정 셀에 액세스하는 데 문제가 있습니다.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input.Manipulations;
using Application = Microsoft.Office.Interop.Excel.Application;
namespace excelProgram
{
class Program
{
[STAThreadAttribute]
public static void Main(string[] args)
{
Program p = new Program();
p.openWorkSheet();
Console.ReadKey(true);
}
private void openWorkSheet()
{
var xl= new Application();
xl.Visible = true;
xl.Workbooks.Open(@"C:\Documents and Settings\user\Desktop\Book1.xls");
}
}
}
가 내 PC에 Excel 통합 문서를 여는
Application()
객체를 생성 :
이것은 내가 지금까지있는 것입니다. 이 잘 작동하지만 통합 문서 내의 워크 시트에서 특정 셀에 액세스하는 방법을 모른다. 셀 B1.
아무도 도와 줄 수 있습니까?
xl.Workbooks.Open (...) 명령은 통합 문서를 반환합니까? – Gwny
@Gwny 예, 실제 Excel 통합 문서를 엽니 다. – user3574492
예를 들어 범위를 통해 액세스하려고 할 수 있습니다. Range aRange = Workbook.get_Range ("C1", "C7"); – Gwny