![]() ![]() Text = "Hello World" //Defining the ContentType for excel file. ![]() ![]() Open ( sampleFile ) //Access first worksheet from the workbook. WebRootPath FileStream sampleFile = new FileStream ( basePath, FileMode. Excel2013 //A existing workbook is opened. Excel //Assigns default application version application. workbook.SaveAs("E:\TimesTable.//New instance of ExcelEngine is created //Equivalent to launching Microsoft Excel with no workbooks open //Instantiate the spreadsheet creation engine ExcelEngine excelEngine = new ExcelEngine () //Instantiate the Excel application object IApplication application = excelEngine. = row * column įinally, we save the workbook and close the Excel application. We are going to create a 10×10 times table: worksheet.Name = "TimesTable" įor(int column = 1 column < 10 column ) Now, we can write some data into the worksheet. Worksheet worksheet = workbook.Worksheets The created workbook contains per default one worksheet that has the index 1 in the Worksheets array: .Workbook workbook = () Having the instance of the Excel application, we can create a new workbook and access the worksheet. A new instance of the Excel application can be created as follows: .Application app = new .Application() To create a new Excel file, we first need to execute a new instance of the Excel application (alternatively, you can also search for an existing one, yet we do not consider thís option here). Select the library by placing a tick in the checkbox left of the library name and click OK. For this tutorial, I used the version (15.0.0.0). Likely, you find multiple versions of the library. ![]() In the Reference Manager use the search field to search for the mentioned library. You can do it by clicking with the right mouse button on the Reference folder in your project in the Solution Explorer and selecting the option Add Reference. In this short tutorial, I am going to explain how to create a new Excel file and write some data in a C# application.įirst of all, you need to add a reference to the library to your project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |