检索COM类工厂

时间:2013-11-21 14:46:11

标签: c# visual-studio-2010 office-interop

我收到错误 - 检索COM类工厂......'在

Excel.Workbook wb = new Excel.Workbook.

使用VS2010,Windows 7 64位,MS Office 2007.已经将目标平台设置为' X(86)'。

using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;

protected void btnOpen_Click(object sender, EventArgs e)
{
  OpenExcel();
}

private void OpenExcel()
{
  Excel.Application app = new Excel.Application();
  Excel.Workbook wb = new Excel.Workbook();
  Excel.Worksheet ws = new Excel.Worksheet();
  Excel.Range range = null;

  app.visible = true;
  wb = app.Workbooks.Add(1);
  ws = wb.WorkSheets[1];

  range = ws.get_Range("A1","A3");
   ws.Cells[0,0]="Date";
   ws.Cells[0,1]="Code";
   ws.Cells[0,2]="Name";
}

0 个答案:

没有答案