locked
Powershell with excel cmdlet trying to create a graph . RRS feed

  • Question

  • Hello,

    I have a question that hopefully someone can help me.

    I have a xlsx file called tempxlsserverhdrive1.xlsx.

    It holds the following data

    Date

    Free Megabytes

    7/11/2017 0:00

    46816.56

    8/11/2017 0:00

    46265.18

    9/11/2017 0:00

    45085.95

    10/11/2017 0:00

    46919.88

    11/11/2017 0:00

    47574.48

    Now I am trying to use the powershell cmdlet      ImportExcel

    But I can not work out how to create a line graphs from this data .

    Here is a copy of my code

    #import-module sqlps -DisableNameChecking

    #Install-Module ImportExcel -Force

    #Install-Module -Name SqlServer

    # Initialize Hash Table Array

    $tempEntry =@()

    $sqlquery = @()

    #remove any exisiting temp xlsx TO BE MOVE LATER ON TO THE BOTTOM OF THE POWERSHELL !!!

    #if file exists then remove...

    Remove-Item -Path C:\scripts\tempxlsserverhdrive1.xlsx

    #The SQL query will obtain the free MB from D volume.the server in the last 100 days

    $sqlquery = Invoke-Sqlcmd -ServerInstance SQLSERVER.FQDN -inputFile "C:\scripts\Disk-Free-report-100days.sql"

    #I only need the date and the amount of free space

    $tmpentry = $sqlquery | select date,'free megabytes'

    #producing the Xlsx file

    $tmpentry | Export-Excel -Path C:\scripts\tempxlsserverhdrive1.xlsx

     

    I am suck. Can someone help me out ?

    Wednesday, February 14, 2018 2:11 AM

Answers

  • Its all good.  I have managed to get it all working.

    • Marked as answer by Goce_D Wednesday, February 14, 2018 9:09 PM
    Wednesday, February 14, 2018 9:09 PM

All replies

  • You will have to create an Excel file that defines a graph and a data area for the graph. 

    We cannot write that for you.


    \_(ツ)_/

    Wednesday, February 14, 2018 2:23 AM
  • So I can not use the powershell excel cmdlet to produce a chart from an already established excel document ?


    Wednesday, February 14, 2018 2:54 AM
  • That is right.  Import-Excel does not create charts.

    Read all of the following to learn how to create charts with PowerShell (plot.ps1).


    \_(ツ)_/

    Wednesday, February 14, 2018 3:22 AM
  • Its all good.  I have managed to get it all working.

    • Marked as answer by Goce_D Wednesday, February 14, 2018 9:09 PM
    Wednesday, February 14, 2018 9:09 PM