您的位置:首页 > 其它

Silverlight 将DataGrid的数据导入到Excel中

2012-06-16 18:31 323 查看
1. 要求: OOB, 而且要提升信任.

dynamic excel = AutomationFactory.CreateObject("Excel.Application");
excel.Visible = true;
excel.workbooks.Add();
dynamic sheet = excel.ActiveSheet;
dynamic cell = null;
int i = 1;
foreach (AGC工程 c in dataGrid1.ItemsSource)
{
cell = sheet.Cells[i /*row*/, 1 /*col*/];
cell.Value = c.gcmc工程名称;
cell.ColumnWidth = 40;
cell = sheet.Cells[i /*row*/, 2 /*col*/];
cell.Value = c.tjsj添加时间;
cell.ColumnWidth = 30;
i++;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: