在下面的代碼中,將多個附加clde添加到cconvert excel文件並將多個圖紙添加到Tsv文件中。如何將具有多個工作表的Excel文件轉換爲一組TSV文件?
注:下面的代碼轉換爲Excel用一張紙來Tsv.It文件不處理與多張Excel表
Public Sub Main()
Dim oExcel As Object
Dim oBook As Object
Dim sFileName As String
Dim sFileNameOnly As String
Dim sXlsPath As String
Dim sTsvPath As String
sFileName = CStr(Dts.Variables("User::Xls_File_Name").Value)
sXlsPath = "H:\Xls_Files\" + sFileName
sFileNameOnly = Path.GetFileNameWithoutExtension(sFileName)
sTsvPath = "H:\Xls_Files\" + sFileNameOnly + ".Txt"
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(sXlsPath)
oBook.SaveAs(sTsvPath, -4158)
oBook.Close(False)
enter code here
oExcel.Quit()
Dts.TaskResult = ScriptResults.Success
End Sub
一種可能性是創建臨時工作簿時,[各表複製到它](http://stackoverflow.com/questions/14734578/ c-sharp-excel-save-each-worksheet-to-a-new-workbook),把它保存到'tsv'中,然後一旦完成,丟棄它而不保存。 – stuartd