For a developer, who is trying to update XLTM files via .NET application. Aspose.Total for .NET API can help to automate the updating process. It’s a full package of various .NET APIs dealing different formats including Microsoft Excel files. Aspose.Cells for .NET API that is part of Aspose.Total for .NET package makes this modifying process easy. Below is the process of updating the XLTM document.
How to Update XLTM File in .NET
- Create new Workbook class object having the source XLTM file as parameter
- Access of relevant Worksheet and relevant cell using Worksheets[0].Cells[column] method
- Insert new data in the accessed cell using PutValue(data) method
- Save the file as .xltm file using save() method by passing the file with path as the parameter
Modification Requirements
- For XLTM modification, Microsoft Windows or a compatible OS with .NET, .NET Core, Mono or Xamarin Platforms
- Development environment like Microsoft Visual Studio
- Install from command line as
nuget install Aspose.Cells
or via Package Manager Console of Visual Studio withInstall-Package Aspose.Cells
- Alternatively, get the offline MSI installer or all DLLs in a ZIP file from Downloads
Code - Update XLTM File in .NET
Workbook wkb = new Workbook("sourceFile.xlsx"); | |
Cell cellWithData = wkb.Worksheets[0].Cells["A1"]; | |
cellWithData.Value = 100; | |
Cell cellWithFormula = wkb.Worksheets[1].Cells["C1"]; | |
cellWithFormula.Formula = "=Sum(A1,A20)"; | |
wkb.CalculateFormula(); | |
Worksheet sheet = wkb.Worksheets[1]; | |
Cell cell = sheet.Cells["A1"]; | |
cell.PutValue("Hello World!"); | |
wkb.Save("modified-targetfile.xlsx"); |