good-arrow’s blog

https://good-arrow.net/

Powershell で Excel から JSON をエクスポートする

Import-Excel モジュールをインストールしておく

Install-Module -Name ImportExcel -RequiredVersion 7.1.1



Excel から JSON ファイルを作成する

日付列は -AsText で指定しないと数値で出力される

$excel = "C:\sample\入力ファイル.xlsx"
$json = "C:\sample\出力ファイル.json"

$obj = Import-Excel -Path $excel -WorksheetName "シート名" -AsText "日付" | ConvertTo-Json | Out-File $json