Cmdlet
New-OfficeExcel
Creates a new Excel workbook using the DSL.
Syntax
New-OfficeExcel
[-ApplicationName <String>]
[-Author <String>]
[-Category <String>]
[-ClearCachedFormulaResults]
[-Company <String>]
[[-Content] <ScriptBlock>]
[-DateSystem <1900| 1904| NineteenHundred| NineteenFour>]
[-Description <String>]
[-DisableFastPackageWriter]
[-DocumentTitle <String>]
[-EvaluateFormulas]
[-ForceFullCalculationOnOpen]
[-Keywords <String>]
[-LastModifiedBy <String>]
[-Manager <String>]
[-MarkFormulasDirty]
[-NoSave]
[-Open]
[-PassThru]
[-Password <String>]
[-Path] <String>
[-SafePreflight]
[-SafeRepairDefinedNames]
[-Subject <String>]
[-TemplatePath <String>]
[-ValidateOpenXml]
[<CommonParameters>]#Parameter set:
All Parameter SetsDescription
Runs the provided script block inside an ExcelSheet/ExcelCell DSL context and saves the file.
Examples
Create a workbook with a sheet and a few cells.
New-OfficeExcel -Path .\report.xlsx { ExcelSheet 'Data' { ExcelCell -Address 'A1' -Value 'Region' } }Creates report.xlsx and writes “Region” into cell A1 on the Data worksheet.
Keep a workbook for incremental composition.
$workbook = New-OfficeExcel -Path .\report.xlsx -NoSave
$sheet = $workbook | Add-OfficeExcelSheet -Name 'Data' -PassThru
$sheet | Set-OfficeExcelCell -Address A1 -Value 'Region'
$workbook | Save-OfficeExcel
$workbook | Close-OfficeExcelAssociates the output path with a live workbook, changes a worksheet, then saves and closes it once.
Parameters
- -ApplicationName String
- Workbook application-name metadata.
- Workbook author metadata.
- -Category String
- Workbook category metadata.
- -ClearCachedFormulaResults SwitchParameter
- Remove cached formula results before saving.
- -Company String
- Workbook company metadata.
- -Content ScriptBlock
- DSL scriptblock describing workbook content.
- -DateSystem String
- Workbook date system for Excel date serials.
- Possible values:
1900,1904,NineteenHundred,NineteenFour - -Description String
- Workbook description metadata.
- -DisableFastPackageWriter SwitchParameter
- Disable OfficeIMO fast package writers for this save.
- -DocumentTitle String
- Workbook document title metadata.
- -EvaluateFormulas SwitchParameter
- Evaluate supported formulas and write cached values before saving.
- -ForceFullCalculationOnOpen SwitchParameter
- Request a full workbook recalculation when opened in Excel-compatible applications.
- -Keywords String
- Workbook keyword metadata.
- -LastModifiedBy String
- Workbook last-modified-by metadata.
- -Manager String
- Workbook manager metadata.
- -MarkFormulasDirty SwitchParameter
- Mark formula cells dirty before saving.
- -NoSave SwitchParameter
- Skip saving the workbook after running the DSL.
- -Open SwitchParameter
- Open the workbook in Excel after saving.
- -PassThru SwitchParameter
- Emit a FileInfo for convenience.
- -Password String
- Password used to save the workbook as an encrypted package.
- -Path String
- Destination path for the workbook.
- -SafePreflight SwitchParameter
- Run OfficeIMO worksheet preflight cleanup before saving.
- -SafeRepairDefinedNames SwitchParameter
- Repair common defined-name issues before saving.
- -Subject String
- Workbook subject metadata.
- -TemplatePath String
- Optional workbook template package copied before running the DSL.
- -ValidateOpenXml SwitchParameter
- Validate the saved package with OpenXmlValidator and throw on errors.
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.