参考:
try
{
// which ever version of Excel was referenced to build the interop file
// should be installed on client machines
excelApp = new Excel.Application(); // create the task list on the first worksheet in the workbook
workBook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
ws = (Worksheet) workBook.Worksheets[1];
}
catch
{
// remove the excel references: Excel, Microsoft.Office.Core, and VBIDE and re-add
// the COM reference Microsoft Excel 10.0 Type Library.
MessageBox.Show("An incompatible version of Microsoft Excel is intalled on your system.");
return;
}