Page 1 of 1
Copy from csv file to excel worksheet
Posted: Wed Jul 24, 2019 7:15 am
by Thet Thet
Hi,
How to copy from csv file worksheet into currently active excel worksheet.
How can I do that?
thanks
Re: Copy from csv file to excel worksheet
Posted: Wed Jul 24, 2019 7:48 am
by manish
HI,
You can try the below solution
Code: Select all
string inputFilepath = @"C:\Temp\output.csv";
string outputFilepath= @"C:\temp\testtable.xlsx";
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(inputFilepath);
wb.SaveAs(outputFilepath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault);
wb.Close(false);
app.Quit();
This code will take a .csv file as the input and generate a new .xlsx file copying the contents of the csv to it.
Re: Copy from csv file to excel worksheet
Posted: Wed Jul 24, 2019 8:33 am
by Thet Thet
Hi,
I am sorry,My explanation is missing. I don't want to create a new Excel file.
I want to copy from csv file data into already exit excel file.
thanks.