我收到错误 - 检索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";
}