我有一個項目,我創建示例文檔。代碼在這裏:PDF和Silverlight,它們可以一起工作嗎?
private void btnExcel_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (AutomationFactory.IsAvailable)
{
dynamic excel = AutomationFactory.CreateObject("Excel.Application");
excel.Visible = true;
dynamic workbook = excel.workbooks;
workbook.Add();
dynamic sheet = excel.ActiveSheet;
dynamic cell = null;
int i;
int z = 20;
for (i = 1; i <= 20; i++)
{
cell = sheet.Cells[i, 1];
cell.Value = i.ToString();
cell = sheet.Cells[i, 2];
cell.Value = z.ToString();
z--;
}
}
}
正如你所看到的,這是Excel文件。有什麼辦法可以做到這一點,並導出到PDF文件?感謝您的見解。