How to write data to an excel file with C# using Microsoft.Office.Interop.Excel

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello awesome viewers how are you all welcome back to another video guys in this video we are going to discuss how to write the data from SL dot application we have seen in my previous video how to read the data from excel.application I'll add that video right top corner of this video you can go and watch that here we'll do the same mechanism but the thing is we'll we'll create an Excel file then we'll add a data so that we can write the data to the Excel file using Excel dot application without any further Ado let us start the video foreign [Music] Excel Dot application I'll write Excel lab equal to new Excel dot application the same thing we which we added in the which we added in the read Excel through Excel load application okay the same thing first Reliance will be exactly same we'll write we'll take a workbook now so I'll write Excel Excel dot workbook Excel workbook I'll write here Excel application Dot workbooks select workbooks dot here I previously added open and I added the link but here I will not add that link but instead I'll add add and I'll give open or close bracket URL I'll give as blank and semicolon at the end also I will add semicolon here also open right close bracket semicolon there so here I'll write Excel dot underscore worksheet okay so Excel dot worksheet I'll write Excel worksheet equal to Excel workbook active worksheet so these three will be our main lines now here so here we'll add the data suppose I'm just adding the full name first name and second name that's it apart from the dial not add anything so I'll let Excel worksheet dot here I'll write cells of 1 comma 1. so this will be my first cell I am now not adding the data dynamically just I'm simply adding the data 1 comma 1 equal to first name okay I'll copy the same data so I'll write a second name also the same thing paste the data paste it and then paste it okay so here I'll write second name or maybe I can write last name here I'll write my first name is azer my last name I'll write Jama okay so this should be added in my created Excel okay so now what we'll do after adding the data I'll save the Excel file how I can save the Excel file I'll write Excel workbook dot Abu dot you will get save as okay or maybe we can write save copy as here we have to write the file name so what will be our file name so let me copy this file name so here I'll write copy as path okay click on this go to a program here you have if you if you want to copy as path you have to add the rate and copy as per okay so here already double quotes is there so just remove the one double quotes so here I'll write a semicolon at the end you have to keep at the rate at the beginning okay so now it should be proper here I'll write convert txt file textile Financial right so write data 5 okay so if you open that there won't be any right data file www so even if you sort let's say size or type okay you go by the type Excel are there any Excel with the right data fan okay these are all the CSV or xrsx file there is no right data file okay so let me open the program I'm saving with write data file dot Excel SX so once we say we have to close the workbook and we have to quit the Excel okay two things we have to do here so here I'll do excel workbook Dot close okay I think C is capital yes see semicolon then we have to go Excel app Dot quit so closing the workbook quitting that cell and releasing the memory of memory of okay so here it will if the file is not there it will create the file by itself okay so now let me execute this so we have to make sure right data file dot XLS is created with this so data should be 1 comma 2 this should be the headers this should be later it is 2 comma 1 and 2 comma 2. okay so now you see let's just execute the program so now the execution has started now the execution has ended you can see the file is created data file.xlsx if you double click that you should be able to see the headers first name last name and the assets azer and Jamal are the first name and last name Excel file has now opened you can see the first name is as a last name means German is written to the file and the right data file is now created hope it up like the video guys if you like the video please click on like if you're a new viewer please click on subscribe till then guys take care have a great day bye
Info
Channel: Azhar Techno Coder
Views: 7,314
Rating: undefined out of 5
Keywords: write into excel c#, write data into excel using c#, csharp write to file, csharp excel, excel write data using c#, csharp excel data, c# write to excel file, c# write into excel, c# write data to excel, csharp write data into excel, csharp, csharp tutorial, c sharp, c# write data in excel file, How to write data in to excel file using C#, How to write into excel file using C#, How to write data to an excel file with C# using Microsoft.Office.Interop.Excel
Id: 0BzoeTxUG3U
Channel Id: undefined
Length: 6min 23sec (383 seconds)
Published: Thu Jan 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.