VB.NET 控制EXCEL中的某几个sheet 到另外一个新的EXCEL文档中,并保存为单独文件。有EXCEL 类。求丰满
VB.NET控制EXCEL中的某几个sheet到另外一个新的EXCEL文档中,并保存为单独文件。有EXCEL类。求丰满代码。ActiveSheet{执行后获得选定的she...
VB.NET 控制EXCEL中的某几个sheet 到另外一个新的EXCEL文档中,并保存为单独文件。有EXCEL 类。求丰满代码。
ActiveSheet {执行后获得选定的sheet}
CopySheet { 执行后 执行 复制 sheet的工作}
AddSheet {执行后添加到新的excel文件里}
Public Class XlsIO
Private objXls As Application
Private objWbk As Workbook
Private objSht As Worksheet
Private objShts As Worksheets
Public Function Open(ByVal strFileName As String) As Boolean
objXls = New Application()
objXls.Visible = False
objWbk = objXls.Workbooks.Open(strFileName)
objShts = objWbk.Worksheets()
Return True
End Function
End Class 展开
ActiveSheet {执行后获得选定的sheet}
CopySheet { 执行后 执行 复制 sheet的工作}
AddSheet {执行后添加到新的excel文件里}
Public Class XlsIO
Private objXls As Application
Private objWbk As Workbook
Private objSht As Worksheet
Private objShts As Worksheets
Public Function Open(ByVal strFileName As String) As Boolean
objXls = New Application()
objXls.Visible = False
objWbk = objXls.Workbooks.Open(strFileName)
objShts = objWbk.Worksheets()
Return True
End Function
End Class 展开
1个回答
展开全部
提供一段VBA代码供参考
作用是,保存当前工作簿的sheet,在当前文件夹下,单独另存为xls文件
VB.NET与VBA有一些差别,自己调试一下改改。
Dim TPath As String, XSheet As Worksheet
TPath = ActiveWorkbook.Path
For Each XSheet In ActiveWorkbook.sheets
XSheet.Copy
ActiveWorkbook.SaveAs Filename:=TPath & "\" & ActiveSheet.Name & ".xls"
ActiveWindow.Close
Next
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询