vb.net 只读模式预览Excel文件

只读模式打开"c:\a.xlsx"目录下的文件。

 

Dim ex AS New Microsoft.Office.Interop.Excel.Application

Dim wb AS Microsoft.Office.Interop.Excel.WorkBook = ex.WorkBooks.Open("c:\a.xlsx",  , True)

Dim sh AS Microsoft.Office.Interop.Excel.Worksheet = wb.ActiveSheet

sh.EnableSelection = Microsoft.Office.Interop.Excel.XLEnableSelection.xlNoRestrictions

sh.Protect(, True, True, True)

ex.Visible = True

你可能感兴趣的:(excel,vb.net)