New-SLDocument



Synopsis

Creates a new Excel Document or an instance of an excel document that can be piped to other commands in the module.

Syntax

Description

Creates a new Excel Document or an instance of an excel document that can be piped to other commands in the module.
2 parametersets included, the simplest is with no parameters which outputs a new instance of an excel
which can be piped to other cmdlets in the module.
The 2nd parameterset allows you to name the workbook and optionally the worksheet.
Note:Passthru parameter must be used if you want to pipe the instance to another cmdlet.

Parameters

-WhatIf

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Confirm

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-WorkbookName

Name of Excel Document to be created. There is no need to specify the .xlsx extension.

Required? True
Position? 0
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-WorksheetName

Name of the Worksheet to be created.
Only one worksheet can be created. If you want to create more, create a new instance of excel or use -passthru and then pipe that to Add-SLWorksheet

Required? False
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Path

Path where the excel document is to be created. You may specify a partial path without the filename or file extension.

Required? True
Position? 2
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Force

Use this to overwrite an existing file.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-PassThru

Use this parameter to pass the newly created document to the next cmdlet on the pipeline. By default no output is generated.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

String

Outputs

[SpreadsheetLight.SLDocument]

Notes

Examples

Example 1

Creates a new excel document with a blank worksheet named Testsheet1

Example 2

Overwrites the excel file created in example 1 above via the use of the &;39;Force&;39; parameter.
Note: User will be prompted to confirm the &;39;Overwrite&;39; action. The action will only succeed with an input of either &;39;Y&;39; or &;39;A&;39;

Example 3

Overwrites the existing file but does not prompt the user for confirmation because -confirm is set to &;39;False&;39;, default is true.

Example 4

creates a new document and stores an instance of that document in the variable $Doc which can be piped to other commands.

Example 5

Create a new document using positional parameters.

Example 6

Creates a new instance of an excel document which can be piped to other commands such as Add-SLWorksheet.
This is the simplest and most useful way to use the cmdlet.

Related links