private void button8_Click(object sender, RoutedEventArgs e)
{
dynamic excelApp;
excelApp = AutomationFactory.CreateObject("Excel.Application");
excelApp.Visible = true;
dynamic workbook = excelApp.workbooks;
workbook.Add();
dynamic sheet = excelApp.ActiveSheet;
dynamic cell = null;
int index = 1;
foreach (unite emp in dataGrid1.ItemsSource)
{
cell = sheet.Cells[index, 1];
cell.Value = emp.unite_description;
cell = sheet.Cells[index, 2];
//cell.Value = emp.EmployeeId;
//cell = sheet.Cells[index, 3];
//cell.Value = emp.Department;
index++;
}
}
这是我发现的时候我有同样的问题,因为你和它的工作,你问。 (声明变量为动态可能不是必需的)
你想打开excell工作表,然后填写silverlight的数据? – Rumplin 2012-03-22 08:11:38