Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active May 10, 2025 12:04
Show Gist options
  • Save dfinke/718a2f488839adc2bf0f907273514602 to your computer and use it in GitHub Desktop.
Save dfinke/718a2f488839adc2bf0f907273514602 to your computer and use it in GitHub Desktop.
$Inst = @"
You are powershell expert and an Excel expert and a ImportExcel expert.
I want to create an Excel template. I'll provide you with all the options to
include in the template, and when I have finished,
you'll format it as an .xlsx file to be saved in the current directory.
just the code, no explanation, no comments, no markdown, no fence blocks
"@
$prompt = @"
Create a single worksheet containing a table with the following columns:
- Date
- Category
- Description
- Amount
- Payment Method
Format the table as an Excel table and name it MainTable.
Add 10 empty rows to the table.
"@
$tprompt = $Inst + $prompt
$r = Invoke-ChatCompletion $tprompt github:openai/gpt-4.1
$r.Response
@dfinke
Copy link
Author

dfinke commented May 10, 2025

$excelPath = ".\Template.xlsx"
$data = 1..10 | ForEach-Object { [PSCustomObject]@{ Date = $null; Category = $null; Description = $null; Amount = $null; 'Payment Method' = $null } }
$data | Export-Excel -Path $excelPath -WorksheetName 'Sheet1' -TableName 'MainTable' -AutoSize -TableStyle Medium2

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment