# NetOffice

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

NetOffice is a NuGet package dependency declared by `Pams.API.csproj`. It provides the .NET-side integration layer for Office automation, allowing Pams API code to interact with installed Office applications through managed wrappers.

## Diagram

```mermaid
sequenceDiagram
    participant Client as JavaScript Client
    participant API as Pams API
    participant NetOffice as NetOffice Package
    participant Office as Office Application

    Client->>API: Send document operation request
    API->>NetOffice: Create or open Office document
    NetOffice->>Office: Call COM automation API
    Office-->>NetOffice: Return document result
    NetOffice-->>API: Return operation result
    API-->>Client: Return API response
```

## Usage

```ts
type DocumentOperation = {
  documentPath: string;
  action: "export" | "print";
};

export async function runDocumentOperation(
  operation: DocumentOperation,
): Promise<Response> {
  return fetch("/api/documents/office-operation", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(operation),
  });
}

await runDocumentOperation({
  documentPath: "C:\\Pams\\Reports\\report.xlsx",
  action: "export",
});
```

## AI Coding Instructions

- Keep NetOffice references in the .NET API project; browser JavaScript should call an API endpoint rather than load the NuGet package.
- Preserve the package reference format already used in `Pams.API.csproj`, since this dependency is tagged as legacy-format.
- Release Office COM objects and close documents after each operation to avoid leaving Office processes running.
- Handle environments where the required Office application is not installed or cannot be started.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.API` — `Pams/API/Pams.API/Pams.API.csproj`:1
