How to merge multiple xlsm files
Sheetize XLSM Merger for .NET provides a simple yet powerful API for combining several XLSM workbooks into a single file while preserving all worksheets, macros, charts, and formatting. This is useful when you need to consolidate reports, aggregate data, or create a master workbook from multiple sources.
Main Features
Merge Multiple XLSM Files
Combine an arbitrary number of XLSM workbooks into one consolidated workbook. All macros (VBA) are retained and remain functional in the resulting file.
Preserve Formatting & Objects
All cell styles, formulas, tables, charts, images, and embedded objects are kept intact during the merge process.
Streaming Support
Process large workbooks in a streaming fashion to keep memory usage low, ideal for batch merging of many files.
Detailed Instructions
XLSM Merging Workflow
To merge multiple XLSM files with Sheetize, follow these steps:
- Initialize the Merger: Create an instance of
SpreadsheetMerger. - Configure Options: Set
SaveOptionsif you need to control sheet naming, conflict resolution, or macro handling. - Define File Paths: Provide the list of source XLSM files and the destination merged XLSM location.
- Execute Merge: Call
Processwith the prepared options.
Example – Merge three XLSM files into a single workbook
using Sheetize;
var loadOptions = new LoadOptions();
var saveOptions = new SaveOptions
{
OutputFile = \"E:\\\\MergedReport.xlsm\"
};
SpreadsheetMerger.Process(loadOptions, saveOptions, new string[]
{
\"Quarter1_Report.xlsm\",
\"Quarter2_Report.xlsm\",
\"Quarter3_Report.xlsm\"
});Tips for Successful Merges
- Consistent Macro References: Ensure that macros in the source files do not use duplicate module names; Sheetize will automatically rename conflicting modules.
- Sheet Naming Conflicts: By default, duplicate sheet names are suffixed with “_1”, “_2”, etc. You can override this behavior via
MergerOptions. - Large Workbooks: Use the streaming API (
SpreadsheetMerger.StreamProcess) to keep memory consumption low when merging dozens of large XLSM files.
Expanded Format Support
- The same merger can handle XLSX, CSV, and TSV files; however, only XLSM inputs retain macro functionality.
- After merging, you may optionally apply password protection (see the XLSX password guide) to secure the combined workbook.
With these capabilities, Sheetize makes merging multiple XLSM files effortless, whether you need a quick script for ad‑hoc reporting or a production‑grade service that consolidates thousands of macro‑enabled workbooks daily.