I would like help with a script component in Visual Studio 2005 to take a text file as a source and convert it to Excel file (output). The text file uses a ~ (tilde) as the column delimiter. Any help would be greatly appreciated!
Also, can this be done without installing Excel on the server? Any and all suggestions are welcome.
Below is sample I am having a problem with in the script component:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objExcel As Excel.Application
Const xlDelimited = 1
Const xlWorkbookNormal = -4143
objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.OpenText("D:\PROCESSPO~TP-4186", _
, , xlDelimit开发者_运维知识库ed, , , , , , , True, "~")
objExcel.Workbooks("PROCESSPO~TP-4186").SaveAs( _
"D:\ProcessPO.xls", xlWorkbookNormal)
objExcel.Workbooks("ProcessPO.xls").Close()
objExcel.Quit()
End Sub End Class
I keep getting an error stating that Excel.Application is not defined and I also get Option Strict On requires all vairable declarations to have an 'AS' clause. Can someone point me into the right direction?
Look here:Different Options for Importing Data into SQL Server
精彩评论