convert .txt , .xls files to .csv file.

Posted by Gayathri under C# on 9/11/2012 | Points: 10 | Views : 5074 | Status : [Member] | Replies : 1
hi,

i need the code for converting .txt file and .xls file to .csv
the headers are to be taken dynamically and no hardcoding.




Responses

Posted by: Eva2012 on: 9/11/2012 [Member] Starter | Points: 25

Up
0
Down
You can use below code to convert xls to CSV by a .net excel component(http://www.e-iceblue.com/Introduce/excel-for-net-introduce.html ), see below code:
               Workbook workbook = new Workbook();

workbook.LoadFromFile(@"..\employee.xls");
Worksheet sheet = workbook.Worksheets[0];
sheet.SaveToFile("sample.csv", ",", Encoding.UTF8);


see here to convert text to csv:http://office.microsoft.com/en-us/excel-help/import-or-export-text-txt-or-csv-files-HP010099725.aspx hope it can help.

Gayathri, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response