我在silverlight 4應用程序上有一個datagrid,我試圖通過調用silverlight中的COM組件將其導出爲excel。它保持錯誤,並告訴我該功能不受支持。我無法弄清楚什麼是錯誤的,並相信我的代碼是穩定的,顯然不是。使用COM對象將Silverlight Datagrid導出到Excel
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Dim excel As Object = AutomationFactory.CreateObject("Excel.Application")
excel.visible = True
Dim workbook As Object = excel.workbooks
workbook.add()
Dim sheet As Object = excel.activesheet
Dim cell As Object = Nothing
Dim i As Integer = 1
'populate the excel sheet
For Each item In ActivityTypeCountDataGrid.ItemsSource
cell = sheet.cells(i, 1)
cell.Value = item.Activity_Type
cell.ColumnWidth = 50
cell = sheet.cells(i, 2)
cell.Value = item.Activity_Type_Count
cell.ColumnWidth = 50
i += 1
Next item
End Sub
下面是數據網格
以下是錯誤
這是一個Out Of Browser應用程序嗎? – cadrell0
不,它在瀏覽器內運行 – Jared
您需要提升信任才能使其工作。 – Leo