# Export-OfficeCsv

Exports objects or a CSV document to a CSV file.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.CSV.CsvDocument` `System.Object`

**Outputs**

`System.IO.FileInfo`

**Source**

[ExportOfficeCsvCommand.cs:25](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Csv/ExportOfficeCsvCommand.cs#L25) 

Exports objects or a CSV document to a CSV file.

## Syntax

```
Export-OfficeCsv
[-Append]
[-CompressionLevel <Optimal|Fastest|NoCompression|SmallestSize>]
[-CompressionType <Auto|GZip|Deflate|Brotli|ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormat <String>]
[-Delimiter <String>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Force]
[-FormulaInjectionPolicy <Preserve|Escape>]
-InputObject <Object>
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-NewLine <String>]
[-NoClobber]
[-NoHeader]
[-NullValue <String>]
[-PassThru]
[-Path] <String>
[-QuoteCharacter <Char>]
[-QuoteFields <String[]>]
[-UseQuotes <AsNeeded|Always|Never>]
[-UseUtc]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#member-750a7a95d47036d4ef181031)

Parameter set: `InputObjectPath`

```
Export-OfficeCsv
[-Append]
[-CompressionLevel <Optimal|Fastest|NoCompression|SmallestSize>]
[-CompressionType <Auto|GZip|Deflate|Brotli|ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormat <String>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Force]
[-FormulaInjectionPolicy <Preserve|Escape>]
-InputObject <Object>
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-NewLine <String>]
[-NoClobber]
[-NoHeader]
[-NullValue <String>]
[-PassThru]
[-Path] <String>
[-QuoteCharacter <Char>]
[-QuoteFields <String[]>]
-UseCulture
[-UseQuotes <AsNeeded|Always|Never>]
[-UseUtc]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#member-aa89d3dc4ded39b52be50878)

Parameter set: `InputObjectPathCulture`

```
Export-OfficeCsv
[-Append]
[-CompressionLevel <Optimal|Fastest|NoCompression|SmallestSize>]
[-CompressionType <Auto|GZip|Deflate|Brotli|ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormat <String>]
[-Delimiter <String>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Force]
[-FormulaInjectionPolicy <Preserve|Escape>]
-InputObject <Object>
-LiteralPath <String>
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-NewLine <String>]
[-NoClobber]
[-NoHeader]
[-NullValue <String>]
[-PassThru]
[-QuoteCharacter <Char>]
[-QuoteFields <String[]>]
[-UseQuotes <AsNeeded|Always|Never>]
[-UseUtc]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#member-6ff2e206ff942f088ddbb8bd)

Parameter set: `InputObjectLiteralPath`

```
Export-OfficeCsv
[-Append]
[-CompressionLevel <Optimal|Fastest|NoCompression|SmallestSize>]
[-CompressionType <Auto|GZip|Deflate|Brotli|ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormat <String>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Force]
[-FormulaInjectionPolicy <Preserve|Escape>]
-InputObject <Object>
-LiteralPath <String>
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-NewLine <String>]
[-NoClobber]
[-NoHeader]
[-NullValue <String>]
[-PassThru]
[-QuoteCharacter <Char>]
[-QuoteFields <String[]>]
-UseCulture
[-UseQuotes <AsNeeded|Always|Never>]
[-UseUtc]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#member-ec2c856fe4560ab1d0493dc4)

Parameter set: `InputObjectLiteralPathCulture`

## Description

Use ConvertTo-OfficeCsv when the destination should be CSV text in the pipeline.

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Configuration Files and Data Conversion](/docs/pswriteoffice/config-data-formats/) Guide
  
  Edit YAML and TOML without losing comments, read and write them as objects, and convert JSON, YAML, TOML, XML, CSV and Excel data from PowerShell.
- [Database Reporting with DbaClientX](/docs/workflows/database-reporting/) Guide
  
  Move SQL data into Excel or CSV, verify the artifact, and optionally load it back with DbaClientX and PSWriteOffice. Includes examples and API links.
- [PowerShell Document Recipes](/docs/workflows/powershell-recipes/) Guide
  
  Practical PSWriteOffice patterns for reports, presentations, PDF, CSV, Markdown, RTF, and document extraction. Includes examples and API links.
- [CSV Dialects and Encodings](/docs/csv/dialects-encodings/) Guide
  
  Read and write semicolon, tab and pipe-delimited CSV, detect delimiters, and choose encodings, cultures and policy profiles with OfficeIMO.CSV.
- [Convert CSV to Excel](/docs/csv/convert-to-excel/) Guide
  
  Import CSV files into Excel worksheets as typed tables and export worksheets back to CSV with OfficeIMO.Excel.Csv, PSWriteOffice, and the officeimo CLI.
- [Write CSV from Objects and Data Readers](/docs/csv/write-data/) Guide
  
  Write CSV from objects and IDataReader results, with formula-injection protection and compression, using OfficeIMO.CSV and PSWriteOffice.

## Examples

### Export objects to a CSV file.

```powershell
$data | Export-OfficeCsv -Path .\export.csv
```

Streams PowerShell objects into a CSV file.

### Export with culture list separator.

```powershell
$data | Export-OfficeCsv -Path .\export.csv -UseCulture -Culture pl-PL
```

Uses the selected culture list separator as the delimiter.

## Parameters

**-Append SwitchParameter optional**

Append rows to an existing CSV file. Existing headers are reused when present.

**-CompressionLevel CompressionLevel optional**

Compression level used when CompressionType is enabled.

Possible values: `Optimal`, `Fastest`, `NoCompression`, `SmallestSize`

**-CompressionType CsvCompressionType optional**

Compression used when writing the CSV file.

Possible values: `Auto`, `GZip`, `Deflate`, `Brotli`, `ZLib`

**-Culture CultureInfo optional**

Culture used for value formatting.

**-DateTimeFormat String optional**

Date/time format used for DateTime and DateTimeOffset values.

**-Delimiter String optionalsets: InputObjectPath, InputObjectLiteralPath**

Field delimiter text, including multi-character separators.

**-Encoding Encoding optional**

Encoding used when writing files.

**-EscapeCharacter Char optional**

Character written before the quote character, and before itself, inside quoted fields, such as a backslash. Leave unset to double the quote character.

**-Force SwitchParameter optional**

Allow overwriting read-only files and appending rows with missing existing columns.

**-FormulaInjectionPolicy CsvFormulaInjectionPolicy optional**

Controls how formula-like values are written.

Possible values: `Preserve`, `Escape`

**-InputObject Object requiredpipeline: True (ByValue)aliases: Document**

Objects to export into CSV rows, or a CsvDocument to export (alias Document).

**-MaxCollectionItems Int32 optional**

Maximum number of items allowed in one nested collection or dictionary field. Defaults to 1,048,575; increase explicitly for trusted larger values.

**-MaxNestingDepth Int32 optional**

Maximum nesting depth allowed while normalizing one field value. Defaults to 64; increase explicitly for trusted deeper values.

**-NewLine String optional**

Override the newline sequence.

**-NoClobber SwitchParameter optionalaliases: NoOverwrite**

Do not overwrite an existing CSV file.

**-NoHeader SwitchParameter optional**

Omit the header row from the output.

**-NullValue String optional**

Token written for null values.

**-PassThru SwitchParameter optional**

Emit a FileInfo for the exported file.

**-Path String requiredposition: 0aliases: FilePath, OutPath, OutputPathsets: InputObjectPath, InputObjectPathCulture**

Destination CSV path.

**-QuoteCharacter Char optional**

Character that encloses quoted fields. Defaults to the double quote; fields that contain it are quoted.

**-QuoteFields String[] optional**

Field names that should always be quoted when UseQuotes is AsNeeded.

**-UseQuotes CsvQuoteMode optional**

Controls when CSV fields are quoted. Defaults to quoting only fields that need it.

Possible values: `AsNeeded`, `Always`, `Never`

**-UseUtc SwitchParameter optional**

Convert date/time values to UTC before formatting.

**-WhatIf SwitchParameter optional**

Shows what would happen if the command runs.

**-Confirm SwitchParameter optional**

Prompts for confirmation before running the command.

**-UseCulture SwitchParameter requiredsets: InputObjectPathCulture, InputObjectLiteralPathCulture**

Use the list separator from the selected or current culture as the delimiter.

**-LiteralPath String requiredaliases: LP, PSPathsets: InputObjectLiteralPath, InputObjectLiteralPathCulture**

Literal destination CSV path. Wildcards are not expanded.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:E9CD8361A309DFBF4F9B1A99BDF0ABBB430E3FF4AD9B6A5A21164E910B708ED0 -->
