# How to Create a New Excel Document with OfficeCLI: A Complete Guide

> Easily create a new Excel document using OfficeCLI. Learn how to generate an .xlsx workbook instantly without Microsoft Office. Get the complete guide here.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-07-09

---

**Run `officecli create filename.xlsx` to generate a blank .xlsx workbook with a default Sheet1 in seconds, no Microsoft Office installation required.**

OfficeCLI is an open-source command-line tool that manipulates Microsoft Office documents without requiring the desktop suite. Whether you are automating reports on Linux servers or generating templates on macOS, you can create new Excel documents programmatically using simple terminal commands. This guide walks through the exact command syntax and the underlying implementation in the iOfficeAI/OfficeCLI repository.

## Installation and Prerequisites

OfficeCLI distributes as a self-contained binary that works across Linux, macOS, and Windows. You do not need a local Microsoft Office installation to generate or edit files.

### Installing the OfficeCLI Binary

Fetch and execute the official install script to place the `officecli` command on your `$PATH`:

```bash
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash

```

After installation, verify the binary is accessible:

```bash
officecli --version

```

## Creating an Excel Workbook with the `create` Command

The `create` verb instantiates a new file with a minimal valid Office Open XML structure. You only need to specify the target filename with the correct extension.

### Basic Syntax and File Extension Detection

Execute the following pattern to generate your workbook:

```bash
officecli create report.xlsx

```

In [`CommandBuilder.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/CommandBuilder.cs), the parser inspects the file extension to route the request. When it detects `.xlsx`, it delegates execution to the **Excel handler** defined in [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs).

### What Happens Under the Hood

Inside [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs), the handler constructs a new package using **DocumentFormat.OpenXml**. It writes a bare-minimum workbook containing one worksheet named *Sheet1* and persists the stream to disk. This implementation relies purely on the Open XML SDK, ensuring the output file is fully compatible with Excel, Google Sheets, and LibreOffice Calc.

The entire operation completes without registry lookups or COM objects, making it suitable for CI/CD pipelines and containerized environments.

## Verifying and Populating Your New Workbook

Once created, you can inspect and modify the workbook through additional OfficeCLI commands.

### Inspecting Workbook Structure

Confirm the file was created with the default sheet using the `view` command:

```bash
officecli view report.xlsx outline

```

Expected output:

```text
→ Sheet1

```

This validates that the internal XML parts were written correctly by [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs).

### Adding Data to Cells

Populate the blank workbook using the `set` verb. The following sequence creates a basic header row:

```bash
officecli set report.xlsx /Sheet1/A1 --prop value="Month" --prop bold=true
officecli set report.xlsx /Sheet1/B1 --prop value="Revenue" --prop bold=true
officecli set report.xlsx /Sheet1/A2 --prop value="Jan"
officecli set report.xlsx /Sheet1/B2 --prop value=42000 --prop numFmt='$#,##0'

```

Each `set` invocation targets a specific cell address and accepts properties for value, styling, and number formatting.

## Cross-Platform Compatibility

Because OfficeCLI uses the .NET-based Open XML SDK rather than Office Interop, the `create` command runs identically on Ubuntu, macOS, and Windows. The resulting `.xlsx` file conforms to the ISO/IEC 29500 standard, ensuring interoperability across spreadsheet applications.

## Summary

- **Run `officecli create <filename.xlsx>`** to generate a blank workbook instantly via the terminal.
- The command routes through [`CommandBuilder.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/CommandBuilder.cs) and executes in [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs) using DocumentFormat.OpenXml.
- The default output contains a single worksheet named **Sheet1**.
- No Microsoft Office installation is required on Linux, macOS, or Windows.
- Use `officecli view` to inspect structure and `officecli set` to populate cells immediately after creation.

## Frequently Asked Questions

### Do I need Microsoft Office installed to use OfficeCLI?

No. OfficeCLI relies entirely on the open-source DocumentFormat.OpenXml library to construct Excel packages. The tool operates independently of the Microsoft Office desktop suite and functions in headless environments such as Docker containers and remote servers.

### What is the default sheet name when creating a new Excel file?

OfficeCLI creates a single worksheet named **Sheet1** by default. This behavior is hardcoded in [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs) to provide immediate usability while maintaining a minimal file footprint.

### Can I create Excel files with specific formatting during the create command?

The `create` command generates a blank, unformatted workbook. To apply formatting, run subsequent `officecli set` commands targeting specific cells with flags like `--prop bold=true` or `--prop numFmt='$#,##0'`. Advanced templates should be built by chaining set operations or modifying an existing template file.

### How does OfficeCLI handle file extension resolution?

In [`CommandBuilder.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/CommandBuilder.cs), the argument parser inspects the extension of the filename provided to the `create` verb. It maps `.xlsx` to [`ExcelHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ExcelHandler.cs), `.docx` to [`WordHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/WordHandler.cs), and `.pptx` to [`PowerPointHandler.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.cs). Providing an unsupported extension results in an error before any file write occurs.