Excel and C#

Apr 14 2005 5:52 AM
Hello I al working on a project with Excel and .NET. I have a Excel file with in column A some text like 123,lala,456 I want to split this text as follows : in column B the value 123 in column C the value lala and in column D the value 456. This can be done with the TextToColumns but I cannot get it working. This is what I tried Excel.Application excelApp; excelApp = new Excel.Application(); excelApp.Visible = true; Excel.Workbook wb; wb = excelApp.Workbooks.Open(file,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing); Excel.Range xls = (Excel.Range)((Excel.Worksheet)excelApp.ActiveWorkbook.Sheets[1]).get_Range("B1","D1"); Excel.Range csv = (Excel.Range)((Excel.Worksheet)excelApp.ActiveWorkbook.Sheets[1]).get_Range("A1","A40"); csv.TextToColumns(xls,Excel.XlTextParsingType.xlDelimited,Excel.XlTextQualifier.xlTextQualifierDoubleQuote,false,false,false,true,false,false,false,false,false,Type.Missing,Type.Missing); What am I doing wrong??? please help me !! Thanks a lot !!!!! Bye bye ;)

Answers (1)