有没有办法在不使用 excel 库的情况下将现有宏插入现有的 excel 文件?我需要这个来设置excel来打印整个工作簿。我不能使用excel库,因为它将在无法安装excel的服务器上在线完成。但是,我可以使用 c#.net 编码。我正在使用 NPOI 来生成 excel。
宏在下面给出
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If printed = False Then
Cancel = True
printed = True
ActiveWorkbook.PrintOut
End If
End Sub