<!-- Device Inventory Manager — https://wiki.cyberguard.srl/dim/query-explorer/export/ -->

# Exporting Results

After running a query, Query Explorer lets you export the full result set in two formats: **JSON** and **CSV**. Both export all matching rows — not just the current page — up to the 1000-row limit.

---

## How to Export

1. Run a query. Results appear in the table below the editor.
2. Use the **Export JSON** or **Export CSV** button in the toolbar above the results.
3. The file downloads immediately to your browser's default download location.

No server roundtrip is required — exports are generated client-side from the loaded result set.

---

## JSON Export

- **Format:** Pretty-printed JSON array, one object per row
- **File name:** `query-export-YYYY-MM-DD.json`
- **Encoding:** UTF-8
- **Content:** All columns returned by the query, including any `project` selection applied

**Example output:**

```json
[
  {
    "DeviceName": "ACME-LT-001",
    "ComplianceState": "NonCompliant",
    "PrimaryUserUPN": "john.doe@acme.com",
    "OSVersion": "10.0.22631.3447"
  },
  {
    "DeviceName": "ACME-LT-042",
    "ComplianceState": "NonCompliant",
    "PrimaryUserUPN": "jane.smith@acme.com",
    "OSVersion": "10.0.22621.3155"
  }
]
```

Useful for downstream processing, importing into other tools, or feeding into Power Automate / Logic Apps workflows.

---

## CSV Export

- **Format:** Semicolon-delimited (`;`) CSV with header row
- **File name:** `query-export-YYYY-MM-DD.csv`
- **Encoding:** UTF-8 with BOM (for correct rendering in Microsoft Excel)
- **Content:** All columns returned by the query

The semicolon delimiter is used by default to avoid conflicts with comma-formatted numbers in regional locales (common in European Excel configurations). Fields containing the delimiter or quotation marks are automatically escaped.

**Example output:**

```
DeviceName;ComplianceState;PrimaryUserUPN;OSVersion
ACME-LT-001;NonCompliant;john.doe@acme.com;10.0.22631.3447
ACME-LT-042;NonCompliant;jane.smith@acme.com;10.0.22621.3155
```

Opening in Excel will respect the UTF-8 BOM and display columns correctly without manual import configuration.

---

## Notes

- Exports include **all result rows** returned by the query, not only what is visible on screen. If your query returns 500 rows across multiple pages, all 500 are exported.
- The maximum result set is **1000 rows**. If your query returns more, refine it using `top`, `where`, or `sort by` before exporting.
- Column order in the export follows the order of your `project` clause, or the default column order of the table if no `project` is specified.
