将Excel工作簿保存为HTML在Windows 10中不起作用

将Excel工作簿保存为HTML在Windows 10中无法正常工作。在Windows 7中工作正常。

码:

Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application() Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim misValue As Object = System.Reflection.Missing.Value xlWorkBook = xlApp.Workbooks.Add(misValue) xlWorkSheet = xlWorkBook.Sheets("sheet1") xlWorkSheet.Cells(1, 1) = "Sheet 1 content" xlWorkBook.SaveAs(Filename:="C:\Test\csharp-Excel.htm", FileFormat:=Excel.XlFileFormat.xlHtml, Password:="", _ WriteResPassword:="", ReadOnlyRecommended:=True, CreateBackup:=False) xlApp.Quit() releaseObject(xlWorkSheet) releaseObject(xlWorkBook) releaseObject(xlApp) MessageBox.Show("Excel file created successfully") End Sub Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub End Class