[]
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.
Before you begin, make sure you have:
.NET SDK
Document Solutions for Excel .NET (DsExcel .NET)
The DS.Documents.Excel NuGet package installed in your project
Install the package using the NuGet Package Manager or the .NET CLI:
dotnet add package DS.Documents.ExcelAdd the required namespace as a using statement:
using GrapeCity.Documents.Excel;Start by creating a new Workbook object and getting the first worksheet:
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "Sheet1";To export the workbook, call the save() method from your workbook object with a file name or full path.
workbook.Save("output.xlsx");You can also explicitly specify the XLSX file format:
workbook.Save("output.xlsx", SaveFileFormat.Xlsx);Be sure to replace temp with the file path where you want to save the file.
workbook.Save(@"C:\temp\output.xlsx", SaveFileFormat.Xlsx);workbook.Save("/tmp/output.xlsx", SaveFileFormat.Xlsx);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