[]
        
(Showing Draft Content)

Save and Export Excel XLSX Files

This tutorial shows how to programmatically export newly generated or modified XLSX workbooks from server-side .NET applications using C# and the Document Solutions for Excel .NET (DsExcel .NET) API. You’ll learn how to create a minimal workbook in memory and save it as a standard .xlsx file using the Workbook.save() method.

Prerequisites

Before you begin, make sure you have:

Install the package using the NuGet Package Manager or the .NET CLI:

dotnet add package DS.Documents.Excel

Add the required namespace as a using statement:

using GrapeCity.Documents.Excel;

1) Create a Minimal Excel Workbook in .NET

Start by creating a new Workbook object and getting the first worksheet:

Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "Sheet1";

2) Save the Workbook as an XLSX File

To export the workbook, call the save() method from your workbook object with a file name or full path.

Save to the current working directory

workbook.Save("output.xlsx");

You can also explicitly specify the XLSX file format:

workbook.Save("output.xlsx", SaveFileFormat.Xlsx);

Save to an absolute file path (Windows)

Be sure to replace temp with the file path where you want to save the file.

workbook.Save(@"C:\temp\output.xlsx", SaveFileFormat.Xlsx);

Save to an absolute file path (Linux/macOS)

workbook.Save("/tmp/output.xlsx", SaveFileFormat.Xlsx);

Notes for Server-Side Usage

DsExcel .NET is designed to run server-side and does not require Microsoft Excel or Office Interop.

Common server-side usage patterns include:

  • Generating Excel reports in a .NET Web API

  • Updating uploaded .xlsx templates and exporting a final workbook

  • Creating scheduled Excel exports in background services

  • Running Excel generation workflows in cross-platform .NET applications

Next Steps