Update XLSM File via .NET

Modify XLSM spreadsheet via your .NET based applications without installing Microsoft Office®.

XLSM Update via Java XLSM Update via C++

 

For a developer, who is trying to update XLSM 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 XLSM document.

How to Update XLSM File in .NET

  • Create new Workbook class object having the source XLSM 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 .xlsm file using save() method by passing the file with path as the parameter

Modification Requirements

  • For XLSM 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 with Install-Package Aspose.Cells
  • Alternatively, get the offline MSI installer or all DLLs in a ZIP file from Downloads
 

Code - Update XLSM 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");
 

Explore File Editor Options with .NET

Edit CSV (Comma Seperated Values)
Edit TSV (Tab-separated Values)
Edit XLS (Microsoft Excel Binary Format)
Edit XLSB (Excel Binary Workbook)
Edit XLSM (Macro-enabled Spreadsheet)
Edit XLSX (Open XML Workbook)
Edit XLT (Excel 97 - 2003 Template)
Edit XLTM (Excel Macro-Enabled Template)
Edit XLTX (Excel Template)

What is XLSM File Format?

The XLSM file format is another file format used by Microsoft Excel, and it stands for Excel Macro-Enabled Workbook. Similar to XLSB, XLSM files offer additional functionality and capabilities compared to the standard XLSX format.

XLSM files are designed to store spreadsheet data that includes macros. Macros are small programs or scripts that automate tasks within Excel. With the XLSM format, users can create, edit, and execute macros directly within the workbook. This makes XLSM files particularly useful for automating repetitive tasks, performing complex calculations, or creating customized functions.

By enabling macros, XLSM files allow users to enhance the functionality of their spreadsheets. Macros can be written using the Visual Basic for Applications (VBA) programming language, providing a powerful tool for customization and automation within Excel.

One of the main advantages of the XLSM format is its ability to store and execute macros seamlessly. When an XLSM file is opened, Excel enables the macros contained within the file, allowing users to utilize the automation and customization features provided by the macros.

However, it’s important to note that due to potential security risks, some Excel versions may prompt users to enable or disable macros when opening an XLSM file. This is done to protect against potentially malicious macros that could harm the system or compromise data.