Skip to content

Microsoft.Office.Interop.Excel

reference
1 min readUpdated

Kind: Service

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

Part of: Pams

NuGet package dependency

Microsoft.Office.Interop.Excel is a NuGet package dependency referenced by Pams.API.csproj. It provides the .NET Excel interop types used by the Pams API when code needs to automate Excel or read and write legacy Excel-format files.

Diagram

mermaid
sequenceDiagram
    participant Client
    participant PamsAPI as Pams API
    participant Interop as Microsoft.Office.Interop.Excel
    participant Excel as Microsoft Excel

    Client->>PamsAPI: Request Excel processing
    PamsAPI->>Interop: Create Excel application and workbook
    Interop->>Excel: Open or create workbook
    Excel-->>Interop: Workbook data
    Interop-->>PamsAPI: Excel objects and results
    PamsAPI-->>Client: Return processed response

Usage

ts
import { execFile } from "node:child_process";

function exportWithPamsApi(inputPath: string, outputPath: string) {
  execFile(
    "dotnet",
    [
      "run",
      "--project",
      "Pams/API/Pams.API/Pams.API.csproj",
      "--",
      "export-excel",
      inputPath,
      outputPath,
    ],
    (error, stdout, stderr) => {
      if (error) {
        throw new Error(stderr || error.message);
      }

      console.log(stdout);
    },
  );
}

exportWithPamsApi("input.xlsx", "output.xlsx");

AI Coding Instructions

  • Keep Excel interop references in Pams/API/Pams.API/Pams.API.csproj; do not add duplicate package references in unrelated projects.
  • Release COM objects after workbook processing to prevent Excel processes from remaining open.
  • Handle Excel application, workbook, and worksheet cleanup in finally blocks.
  • Validate file paths and legacy Excel-format compatibility before passing files to interop code.

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.APIPams/API/Pams.API/Pams.API.csproj:1

Was this page helpful?

Download as PDF