Import-CSVToSLDocument


Synopsis

Import one or more CSV files into an excel document.

Syntax

Description

Import one or more CSV files into an excel document.Worksheet names are automatically generated based on the csv filenames.

Parameters

-WorkBookInstance

Instance of an excel document that can be used for editing.

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

-CSVFile

The complete path to the CSV file along with extension.Multiple paths can be specified in a comma seperated list.

Required? True
Position? 0
Default value  
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? False

-ImportStartCell

Marks the start of the cell within excel for the csvfile data.

Required? False
Position? named
Default value  
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? False

-Force

Use force to overwrite an existing worksheet.

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

-AutofitColumns

Autofit Columns.

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

-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

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,SpreadsheetLight.SLDocument

Outputs

SpreadsheetLight.SLDocument

Notes

Examples

Example 1

An instance of MyFirstDoc is stored in a variable named doc.
CSVfile named &;39;disk&;39; is then imported into the existing document.

Example 2

Same as the first example except that in this case we create a new document named disk and then import the contents of the csv file.
Note the use of the &;39;Passthru&;39; parameter with New-SLDcoument. Required if you want to process the new document further.

Example 3

An instance of MyFirstDoc is stored in a variable named doc.
2 csv files named disk & service in different locations are passed in a comma seperated list
Since we are importing the csv files to one single document we cannot call save-sldocument in the same pipeline.
Instead we perform all the operations on the doucment and then finally call save to save all changes.

Example 4

We make use of the pipeline to pipe the CSVfile paths using &;39;DIR&;39; along with the filter parameter.
We are getting all csv files from the location d:\workdocuments with the exclusion of &;39;process.csv” and then pipe them Import-CSVToSLDocument.

Example 5

We build on the last example by importing the csvfiles and additionally setting a tablestyle of &;39;Dark10&;39; on each imported file.

Example 6

A oneliner to import all csv files with the exception of process.csv to new excel workbooks and also set a tablestyle of &;39;Dark10&;39; on each imported csvfile.
Since we are exporting the csvfiles to different workbooks we can use &;39;Save-SLDocument&;39; as the last command on the pipeline.

Related links