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