# Export application records to Excel

Turn typed C# asset records into a filterable Excel table with the fluent API. Download the generated XLSX, rendered range, and complete source.

Excel · C# walkthrough

Export application data without writing every cell by hand. A typed asset array becomes an Excel table, with a frozen header and a formatted purchase-cost column.

[Build this report](#example-code)[Download XLSX](/downloads/showcase/workflows/excel-object-export/example.xlsx) [Try this file in your browser](/browser/excel-to-pdf/)

Opens the generated download in a local browser tool. The C# example below creates the document.

**Start with**

An array of typed asset records

**Generate**

XLSX

[!\[Generated Excel example: Export application records to Excel\](/downloads/showcase/workflows/excel-object-export/preview.webp)](/downloads/showcase/workflows/excel-object-export/preview.png)

Generated worksheet · Generated by the example below

## How it works

1. ### Define the record shape
  
  Use a small C# type for the fields that belong in the export. Keep unrelated application state out of the record.
2. ### Map records through RowsFrom
  
  Pass the array to the fluent sheet builder and add a named, styled table over the generated data.
3. ### Finish the worksheet
  
  Set practical widths, freeze the header, and format the cost column before rendering and saving.

## The C# source

The example below shows the document API and layout used for this report. Follow the Excel guide for package setup in your own project.

```csharp
using OfficeIMO.Drawing;
using OfficeIMO.Excel;

namespace OfficeIMO.Examples.Showcase.Workflows;
/// <summary>Exports typed application records as a filterable Excel table.</summary>
internal static class ObjectExport
{
    private sealed class Asset {
        public string AssetTag { get; init; } = "";
        public string Category { get; init; } = "";
        public string AssignedTeam { get; init; } = "";
        public DateTime PurchaseDate { get; init; }
        public decimal PurchaseCost { get; init; }
        public string Status { get; init; } = "";
    }

    internal static void Create(string folder)
    {
        Asset[] assets =
        {
            new()
            {
                AssetTag = "NW-1042",
                Category = "Laptop",
                AssignedTeam = "Delivery",
                PurchaseDate = new DateTime(2026, 1, 12),
                PurchaseCost = 1240,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1043",
                Category = "Monitor",
                AssignedTeam = "Support",
                PurchaseDate = new DateTime(2026, 1, 12),
                PurchaseCost = 320,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1044",
                Category = "Dock",
                AssignedTeam = "Engineering",
                PurchaseDate = new DateTime(2026, 2, 3),
                PurchaseCost = 185,
                Status = "In stock"
            },
            new()
            {
                AssetTag = "NW-1045",
                Category = "Laptop",
                AssignedTeam = "Operations",
                PurchaseDate = new DateTime(2026, 2, 17),
                PurchaseCost = 1390,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1046",
                Category = "Tablet",
                AssignedTeam = "Delivery",
                PurchaseDate = new DateTime(2026, 3, 2),
                PurchaseCost = 680,
                Status = "In repair"
            },
            new()
            {
                AssetTag = "NW-1047",
                Category = "Laptop",
                AssignedTeam = "Support",
                PurchaseDate = new DateTime(2026, 3, 9),
                PurchaseCost = 1240,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1048",
                Category = "Monitor",
                AssignedTeam = "Operations",
                PurchaseDate = new DateTime(2026, 3, 23),
                PurchaseCost = 320,
                Status = "In stock"
            },
            new()
            {
                AssetTag = "NW-1049",
                Category = "Phone",
                AssignedTeam = "Delivery",
                PurchaseDate = new DateTime(2026, 4, 6),
                PurchaseCost = 540,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1050",
                Category = "Dock",
                AssignedTeam = "Support",
                PurchaseDate = new DateTime(2026, 4, 6),
                PurchaseCost = 185,
                Status = "In use"
            },
            new()
            {
                AssetTag = "NW-1051",
                Category = "Laptop",
                AssignedTeam = "Engineering",
                PurchaseDate = new DateTime(2026, 4, 20),
                PurchaseCost = 1590,
                Status = "In stock"
            }
        };
        using ExcelDocument document = ExcelDocument.Create(Path.Combine(folder, "example.xlsx"));
        {
            var sheet1 = document.AddSheet("Assets");
            int nextRow2 = 1;
            var table3 = sheet1.AddTable(assets, new ExcelTableOptions { Name = "Assets", Style = ExcelTableStyle.TableStyleMedium2, IncludeAutoFilter = true, Projection = null }, row: nextRow2);
            nextRow2 = table3.AsRange().LastRow + 1;
            sheet1.AutoFitColumns();
        }

        ExcelSheet sheet = document.Sheets[0];
        sheet.View.Freeze(topRows: 1);
        for (int column = 1; column <= 6; column++)
            sheet.SetColumnWidth(column, ExcelColumnWidth.Characters(18));
        for (int row = 2; row <= assets.Length + 1; row++)
        {
            sheet.Cell(row, 4).SetNumberFormat("d mmm yyyy");
            sheet.Cell(row, 5).SetNumberFormat("#,##0.00");
        }

        sheet.Range("A1:F11").ToImage(OfficeImageExportFormat.Png).Save(Path.Combine(folder, "preview.png"), OfficeImageExportFileConflictPolicy.Replace);
        document.Save();
    }
}
```

[Open the C# source file](/downloads/showcase/workflows/excel-object-export/ObjectExport.cs.txt)

## API used in this example

- [`ExcelDocument`](/api/excel/officeimo-excel-exceldocument/)
- [`ExcelColumnWidth`](/api/excel/officeimo-excel-excelcolumnwidth/)
- [`ExcelSheet`](/api/excel/officeimo-excel-excelsheet/)
- [`ExcelTableOptions`](/api/excel/officeimo-excel-exceltableoptions/)
- [`ExcelTableStyle`](/api/excel/officeimo-excel-exceltablestyle/)
- [`OfficeImageExportFileConflictPolicy`](/api/core/officeimo-drawing-officeimageexportfileconflictpolicy/)
- [`OfficeImageExportFormat`](/api/core/officeimo-drawing-officeimageexportformat/)

## Use this in your project

Replace the asset type with the fields your recipient needs. RowsFrom also supports more explicit mapping options when your source has nested or optional properties.

The [Excel guide](/docs/excel/) explains package setup and related document APIs.

## Documents and scope

### What the preview shows

The linked C# example generates this file. The runner reopens and validates the XLSX. The image is a native rendering of the specified worksheet range.

### What to keep in mind

The sample uses ten flat records with dates, numbers and text. It is not a benchmark or a demonstration of streaming a large database result.

[Excel API reference](/api/excel/) · [Artifact hashes and provenance](/downloads/showcase/manifest.json)

## Continue with another example

- [Excel**Styled inventory tables**](/showcase/#excel-tables)
- [Excel**A structured expense register**](/showcase/excel-expense-register/)
- [Excel**Operational Excel report**](/showcase/#operational-excel-report)

<!-- PowerForge markdown artifact sha256:A8F4E99E8D898D8FA228E041E47863D9996C2604122CD5DA5271BF47784F6D5E -->
