Export-SLData


Synopsis

Stores data in a datatable which is the input type that excel accepts.

Syntax

Description

Stores data in a datatable which is the input type that excel accepts.
Since there may be a possibility of overwriting existing data the workbook is backed up prior to processing the command.
Location of backup –> $Env:temp\SLPSLib

Parameters

-inputobject

Data in the form of rows and columns. eg. output from the cmdlet &;39;Get-service&;39;

Required? True
Position? 1
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? False

-WorkBookInstance

Instance of an excel document that can be used for editing.Please note you cannot pipe a workbookinstance to this cmdlet. Instead use named parameter.

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

-WorksheetName

Name of the Worksheet where data will be exported. Make sure this is blank if not existing data will be overwritten.

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

-StartRowIndex

Row number which marks the start of the data table.Default value is 5

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

-StartColumnIndex

Column number which marks the start of the data table.Default value is 2

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

-AutofitColumns

Autofit all columns that contain data in the selected worksheet.

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

-ParseStringData

For the most part powershell handles dataconversion to its proper datatype but it cannot help
when data is explicitly cast as a string which gives rise to mismatch between data and datatype.
Eg: $a = “12” stored as a string even though the value is an integer.

Mismatched datatypes may also result due to poorly built functions that cast everything as a string.
parsestringdata tries to coerce these string values into their respective datatypes(Integer,Double, or datetime)
eg: $a = “25-07-2014″ is a string so excel will store this as a string but when parsestring data is used the value of $a is stored as a datetime instead of a string.

Note: In Excel Numbers are always right aligned and strings leftaligned.

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

Object,SpreadsheetLight.SLDocument

Outputs

SpreadsheetLight.SLDocument

Notes

Examples

Example 1

Get-Service is piped to an instance of &;39;MyFirstDoc&;39;. The output is saved to a worksheet named &;39;MyComp_Services&;39;.
Note: A new worksheet will be created in case the specified worksheet dosen&;39;t exist.

Example 2

An instance of MyFirstDoc is stored in a variable named doc.
Service,process and diskdata from the localcomputer is then exported to worksheets &;39;service&;39;,&;39;process&;39; & &;39;Disk&;39; respectively.

Example 3

A one-liner to get the newest 5 entries from the system eventlog to a new workbook named &;39;Eventlog&;39;.

Example 4

3 new documents are created.One each for service,process and disk respectively.
Export-sldata is then used to export the relevant data to each fo the workbooks.
Note: &;39;Passthru&;39; parameter with New-SLDocument is required when you want to store the document instance in a variable as shown above.

Example 5

Group-Object is used to group by the status property .
Export-sldata is then used to export the running services starting from column number 2 to 5.
Stopped services are then exported to columns 6-8 in the same worksheet.

Related links

Stay in touch

Linkedin // RSS Feed