In This Article I Will Show You How To Convert CSV File Into XLS File
So Firstly You Need To Install The Package: Microsoft.Office.Interop.Excel From Nugget Package Manager
Just use the function I provided here to convert CSV in XLSX.
using System; using System.Collections.Generic; using Excel = Microsoft.Office.Interop.Excel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSV_TO_XLS { class Program { static void Main(string[] args) { string csv = @"D:\Files\csvfile.csv"; string xls = @"D:\Files\xlsfile.xlsx"; Excel.Application xl = new Excel.Application(); //Open Excel Workbook for conversion. Excel.Workbook wb = xl.Workbooks.Open(csv); Excel.Worksheet ws = (Excel.Worksheet)wb.Worksheets.get_Item(1); //Select The UsedRange Excel.Range used = ws.UsedRange; //Autofit The Columns used.EntireColumn.AutoFit(); //Save file as csv file wb.SaveAs(xls, 51); //Close the Workbook. wb.Close(); //Quit Excel Application. xl.Quit(); } } }
Now Run The Project And Its Genrate XLS FILE FROM CSV FILE
The Below Screenshot Is Represents The CSV File Will Converted Into Excel(XLS) File By The Above Code.
The Below Screenshot Represents The CSV File To Converted Excel .
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
View Comments
Congrats ! I could do what I wanted thanks to your post. Bless you :-)
Great yet simple solution for this issue! I'd been trying a more complex solution I found that I couldn't get to work. Yours worked like a charm. Great job!