Quick Start

Quick Start

This page gets you from zero to a working XLSX file in C# using Aspose.Cells FOSS for .NET.


Prerequisites

RequirementDetail
Runtime.NET 6.0 or later
PackageAspose.Cells_FOSS (NuGet)
OSWindows, macOS, or Linux

Install the package if you haven’t already:

dotnet add package Aspose.Cells_FOSS

Step 1 — Create a Workbook and Write Cell Data

Instantiate a Workbook to get a blank workbook with one default worksheet. Access the worksheet through Workbook.Worksheets[0]. Use Cell.PutValue() to write strings, numbers, booleans, decimals, and dates. Assign a formula string to Cell.Formula to add a computed cell.

using Aspose.Cells_FOSS;

var workbook = new Workbook();
var sheet = workbook.Worksheets[0];

// Write different value types
sheet.Cells["A1"].PutValue("Product");
sheet.Cells["B1"].PutValue("Units");
sheet.Cells["C1"].PutValue("Price");

sheet.Cells["A2"].PutValue("Widget A");
sheet.Cells["B2"].PutValue(120);
sheet.Cells["C2"].PutValue(9.99m);

sheet.Cells["A3"].PutValue("Widget B");
sheet.Cells["B3"].PutValue(85);
sheet.Cells["C3"].PutValue(14.49m);

// Formula: total revenue for Widget A
sheet.Cells["D2"].Formula = "=B2*C2";
sheet.Cells["D3"].Formula = "=B3*C3";

Step 2 — Save the Workbook

Call Workbook.Save() with an output path. The file format is determined by the .xlsx extension.

workbook.Save("quickstart.xlsx");
Console.WriteLine("Saved: quickstart.xlsx");

Step 3 — Load and Read Back

Load an existing file by passing the file path to the Workbook constructor. Access cell values using Cell.StringValue for display strings or Cell.Value for the underlying object. Cell.Formula returns the formula string if one is set.

var loaded = new Workbook("quickstart.xlsx");
var ws = loaded.Worksheets[0];

Console.WriteLine(ws.Cells["A2"].StringValue);  // Widget A
Console.WriteLine(ws.Cells["B2"].StringValue);  // 120
Console.WriteLine(ws.Cells["D2"].Formula);       // =B2*C2
Console.WriteLine(ws.Cells["D2"].StringValue);   // 1198.8

Next Steps

  • Installation — Detailed setup instructions and .csproj package reference syntax
  • Features — Overview of all capabilities exposed by the library
  • Spreadsheet Management — Worksheets, page setup, row/column layout, and cell merging