How to edit and update data in Microsoft Excel without Office installed.
C#.NET Excel document file editing library control, XsExcel SDK for .NET, is a robust & thread-safe .NET solution which provides a reliable and quick approach for C# developers to create and save a highly-secure and industry-standard Excel spreedsheet file.
This guide page provides users with detailed explanations for adding and changing XLSX and XLS cell value in C# code.
// Load excel workbook from local file Workbook workBook = new Workbook("sample.xlsx"); // Get worksheet by name Sheet sheet = workBook.GetSheet("Sheet1"); // Get row by row index Row row = sheet.GetRow(0); if (row != null) { // If the cell is the same as the original cell type, // you can update the cell value directly. // For example, the original cell value is Int value "123", // now you want to change the cell value to Int "456" Cell cellUpdate = row.GetCell(0); if (cellUpdate != null) { cellUpdate.SetValue(456); } // If the cell is different from the original cell type, // you need to create a new cell to replace the original one. // For example, the original cell value is Int value "123", // now you wan to change the cell value to String "XsExcel" Cell cellNew = row.CreateCell(1); cellNew.SetValue("XsExcel"); } // Save and show the spreedsheet if (File.Exists("sample.xlsx")) File.Delete("sample.xlsx"); workBook.Save("sample.xlsx"); Process.Start("sample.xlsx");
More Excel tutorial
- .NET online guide for setting MS Excel formula
- Spreedsheets converting from SQL database in .NET is quite easy and quick using XsExcel DLL for .NET
- Spreedsheets extracting from datatable in .NET is quite easy and quick using XsExcel Component for .NET
- How to create Spreedsheets in ASP.NET MVC using .NET
- How to set Spreedsheets date time data display formatted in ASP.NET web application using C#.NET