Running LoadSheets
Command Line usage:
The following command is used to run the LoadSheets program.
loadsheets-configfilename.yaml [-highlight] [-paramsk=v,…]
Option Description -configSpecifies the YAML config file to use -highlightMarks cells with errors in the Excel output with yellow fill (Optional) -paramsComma-separated key=value pairs accessible in the config file (Optional)
Command (.bat) Files
Rather than typing loadsheet commands from a terminal window each time you want to process a job, you can use a .bat (command) file to automate the process.
For example:
@echo off
cls
pushd %~dp0
set /p EXPDATE="Cutoff Date (yyyy-mm-dd): "
loadsheets -config t1.yaml -highlight -params "cutoff=%EXPDATE%"
start /b notepad++.exe "%CD%\t1_template.log"
start /b excel.exe "%CD%\t1_template_%date:~10,4%-%date:~4,2%-%date:~7,2%.xlsx"
pause
popd
The first line (@echo off) just keeps each line from displaying when executing.
The set command is how you can pass user-supplied parameters into the loadsheets executable.
The pushd and popd commands are a workaround required if you have the command file on a network
drive and you do not have a drive letter mapped for it. This is because CMD does not support UNC paths
as current directories.
pushd creates a temporary mapped drive to the current working directory and popd removes that temporary mapping
(and so must be after the “pause” statement).
The %CD% variable allows substituting the current working directory (caused by the pushd command).
The Cuttoff Date prompt is just an example of how you would pass something into the process. In this case, the config
file would use the cutoff variable as a filter.
Powershell Version
If you use Powershell, here is a script with a few enhancements for controlling the running of LoadSheets.
# Clear screen and set working directory to script location
Clear-Host
Push-Location $PSScriptRoot
# Prompt for cutoff date
$expDate = Read-Host "Cutoff Date (yyyy-mm-dd)"
# Run loadsheets with parameters
& loadsheets -config "t1.yaml" -highlight -params "cutoff=$expDate"
# Launch Notepad++ with log file
Start-Process "notepad++.exe" -ArgumentList "$PWD\t1_template.log"
# Format today's date as yyyy-mm-dd
$today = Get-Date -Format "yyyy-MM-dd"
# Launch Excel with the generated file
Start-Process "excel.exe" -ArgumentList "$PWD\t1_template_$today.xlsx"
# Wait for user before closing
Pause
# Restore previous location
Pop-Location
Notes & Enhancements
- $PSScriptRoot ensures the script runs relative to its own location, like %~dp0.
- Read-Host replaces set /p for user input.
- Start-Process is the PowerShell equivalent of start /b, and avoids blocking.
- Get-Date -Format “yyyy-MM-dd” gives you the same date format as your batch file’s substring slicing.
- Pause works in PowerShell if you’re running interactively; otherwise, you can use Read-Host “Press Enter to continue…”.
- Defaulting to today avoids friction for frequent runs.
- Transcript logging gives you a persistent audit trail.
- Error checks prevent silent failures when files are missing or commands fail.