Hi!
Problem: I need to import a text file into Excel using (preferrably) ASP.NET or VB.NET. The clincher is I need the datat to be imported based on an array of spacing.
I started the code out in Excel/VBA using the following method:
xls.Workbooks.OpenText(Filename:="P_022103.txt", Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(5, 2), Array(12, 2), Array(19, 2)))
This worked GREAT in VBA - but now I need to be able to use this in a Web App or WinApp instead of VBA.
I have added an Excel 9.0 library reference to my project and am using the following code:
Dim xls As New Excel.Application()
xls.Workbooks.Add()
xls.Workbooks.OpenText(Filename:="P_022103.txt", Origin:=Excel.XlPlatform.xlWindows, StartRow:=1, DataType:=Excel.XlTextParsingType.xlFixedWidth, FieldInfo:=Array(myArray(0, 2), myArray(5, 2), myArray(12, 2), myArray(19, 2)))
If I don't use the "Array" and just call the OpenText method ending with the DataType element - the text file opens fine in Excel, but I need it to open following the column definitions set up by the array.
Sooo...if anyone knows how to use Array to import or if there is another way to do this - I would greatly appreciate your help. Thanks in advance!
Problem: I need to import a text file into Excel using (preferrably) ASP.NET or VB.NET. The clincher is I need the datat to be imported based on an array of spacing.
I started the code out in Excel/VBA using the following method:
xls.Workbooks.OpenText(Filename:="P_022103.txt", Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(5, 2), Array(12, 2), Array(19, 2)))
This worked GREAT in VBA - but now I need to be able to use this in a Web App or WinApp instead of VBA.
I have added an Excel 9.0 library reference to my project and am using the following code:
Dim xls As New Excel.Application()
xls.Workbooks.Add()
xls.Workbooks.OpenText(Filename:="P_022103.txt", Origin:=Excel.XlPlatform.xlWindows, StartRow:=1, DataType:=Excel.XlTextParsingType.xlFixedWidth, FieldInfo:=Array(myArray(0, 2), myArray(5, 2), myArray(12, 2), myArray(19, 2)))
If I don't use the "Array" and just call the OpenText method ending with the DataType element - the text file opens fine in Excel, but I need it to open following the column definitions set up by the array.
Sooo...if anyone knows how to use Array to import or if there is another way to do this - I would greatly appreciate your help. Thanks in advance!