111,126
社区成员
发帖
与我相关
我的任务
分享
excel = AutomationFactory.CreateObject("Excel.Application");
if(excel==null)
throw new Exception("没有安装Excel。");
excel.Visible = true;
var workbook = excel.workbooks; workbook.Add();
sheet = excel.ActiveSheet;
var i = 1;
var data = new double[] { 1.0, 5.0, 9.5, 2.7, 3.2, 0.6 };
foreach (var d in data)
{
var cell = sheet.Cells[i, 1];
cell.Value = "第 " + i + "行";
cell.ColumnWidth = 10;
cell = sheet.Cells[i, 2];
cell.Value = d;
i++;
}
var button = new Button { Content = "click me!", Width = 80, Height = 20 };
this.Container.Children.Add(button);
button.Click += new RoutedEventHandler(button_Click);
CheckValues();
excel.DisplayAlerts = false;
excel.Quit();