Barak Rosenfeld
Barak Rosenfeld

Reputation: 337

opening a text file with excel opentext file using C#

I want to open a txt file with excel

which is like a "csv" file but instead of a comma, I want to use another character like start (*) after opening I would like to save it as an xlsx file how can I do that with the function Workbooks.opentext()?

can you please give me a code example

this is the code I am using however I am getting an error since I am not sure how to use the openText method character

  xlApp = new Microsoft.Office.Interop.Excel.Application()
  var _wbs = xlApp.Workbooks;
 _wbs.OpenText(pathTemp,Microsoft.Office.Interop.Excel.oy //0, 26, 0, 0, 0, 0, 0, 0, 0, true, '^');
 _wbs[0].SaveAs(pathTemp + "Barak.xlsx");

Upvotes: 0

Views: 4930

Answers (1)

cronos2546
cronos2546

Reputation: 1106

Per http://msdn.microsoft.com/en-us/library/office/ff837097%28v=office.15%29.aspx

_wbs.OpenText(Path:=pathTemp,Datatype:=xlDelimited,Other:=True,Otherchar:="*");

Upvotes: 0

Related Questions