0

How can I convert below from Xlsx to JSON? I want to the JSON file to pick up data like this:

{"POV":["DC01","DC05",...,"Input"],
"Years": ["FY19", "FY19",..., "FY19"],
"Columns":[["Jan", "Feb",...,"Apr"]],
"Rows":[{"Account":["Meals"],"Data":["5000","6000","5000","7000"]}

Really struggling with PowerShell (Example):

$Excel = New-Object -Com Excel.Application
$wb = $Excel.Workbooks.Open("C:\Users\Blam\OneDrive - Huron Consulting Group\Desktop\Projects\Bio_Rad\EPBCS - Copy\EPBCS - Copy\Test.xlsx")

$WorkBook = $objExcel.Workbooks.Open($strPath)
$Worksheet = $Worksheet.sheet.item("Test")
$intRowMax = ($worksheet.UsedRange.Rows).count

1 Answer 1

1
Import-Csv .\Test.csv | ConvertTo-Json | Add-Content -Path "result.json"

My Excel:

enter image description here

Here's the JSON Result

[
    {
        "Jan":  "6000",
        "Feb":  "2342",
        "Mar":  "5424"
    },
    {
        "Jan":  "6001",
        "Feb":  "2343",
        "Mar":  "5425"
    },
    {
        "Jan":  "6002",
        "Feb":  "2344",
        "Mar":  "5426"
    },
    {
        "Jan":  "6003",
        "Feb":  "2345",
        "Mar":  "5427"
    },
    {
        "Jan":  "6004",
        "Feb":  "2346",
        "Mar":  "5428"
    },
    {
        "Jan":  "6005",
        "Feb":  "2347",
        "Mar":  "5429"
    },
    {
        "Jan":  "6006",
        "Feb":  "2348",
        "Mar":  "5430"
    },
    {
        "Jan":  "6007",
        "Feb":  "2349",
        "Mar":  "5431"
    }
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.