We have a product that reads .xls file to extract data. but one problem we have is before we process the files we had to manually convert each column to text type for existing data using text to column wizard. can we do this c# and office automati开发者_如何转开发on?
You have to create a macro in the workbook to run the Wizard.
The macro runs along the lines of:
Sub Macro1()
'
Worksheets("Sheet1").Range("A1:A10").TextToColumns Destination:=Range("A1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
End Sub
You may create the macro in Excel itself or using OA.
Then when you need to run the wizard, you can do that from OA too.
HTH!
精彩评论