开发的软件导入和导出excel软件需要安装office吗?有如下代友码,这需要安装office才能运行吗?
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "Excel文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你选择的是:" & dlg.FileName, "提示") '提示用户选择的文件
Else
Return Nothing
End If
Dim stryu1 As String = dlg.FileName 'args(0) '导入的excel含路径的文件名
Dim zzwjm As String = stryu1.SubString(stryu1.LastIndexOf("\") + 1) ' 提取 不含路径的文件名称
Application.DoEvents
Dim App1 As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App1.WorkBooks.Open(stryu1)'参数2 stryu1
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Range("1:1") '引用单行
If ws.Cells(1, 1).value = "" Then
Rg.Delete
End If
app1.DisplayAlerts = False
wb.save
App1.Quit
gc.Collect
Dim mg As New Merger
mg.SourcePath = stryu1
mg.Format = "excel" '指定格式
mg.SourceTableName = "数据$" '指定要合并的表
mg.DataTableName = "数据" '指定接收数据的表
mg.Merge() '开始合并