Interpretation requested!

Discussion in 'other software & services' started by BoaterDave, May 21, 2011.

Thread Status:
Not open for further replies.
  1. BoaterDave

    BoaterDave Registered Member

    Joined:
    Oct 25, 2006
    Posts:
    62
    Location:
    Devon, England
    #Requires -Version 2.0
    [CmdletBinding()]
    Param
    ([Parameter(Mandatory=$true,
    Position=1,
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$false)]
    [String]$CSVname,
    [Parameter(Mandatory=$false,
    Position=2,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$false)]
    [String]$XLSname,
    [Int]$xlExcel8 = 56,
    [Switch]$Open
    )#End Param

    Begin
    {
    Write-Host "`nConverting from CSV to XLS . . .`n"
    $path = gci $CSVName -EA 0
    if ($XLSname -eq "")
    {
    $path.fullname
    [String]$XLSname = (($path.fullname -split "\.")[0] + ".xls").tostring()
    #[String]$XLSname
    }
    }#Begin
    Process
    {
    if (Test-path -Path $path -EA 0)
    {
    write-host "Creating Excel Report . . .`n"
    $Excel = New-Object -ComObject excel.application
    $Excel.visible = $False
    $Excel.displayalerts=$False
    $WorkBook = $Excel.Workbooks.Open($path)
    $WorkSheet = $Workbook.worksheets.Item(1)
    $Resize = $WorkSheet.UsedRange
    $Resize.EntireColumn.AutoFit() | Out-Null
    $WorkBook.SaveAs($XLSname, $xlExcel:cool:
    $Excel.quit()
    write-host "File saved to Output to:" $XLSname
    }
    else
    {
    "No input file specified, please provide correct path to CSV."
    }

    }#Process
    End
    {
    if ($open)
    {
    ii $XLSname -EA 0
    }
    $XLSname = $Null
    }#End
     
  2. Cudni

    Cudni Global Moderator

    Joined:
    May 24, 2009
    Posts:
    6,956
    Location:
    Somethingshire
    and you see this where? looks like some export/convert routine to Excel
     
  3. BoaterDave

    BoaterDave Registered Member

    Joined:
    Oct 25, 2006
    Posts:
    62
    Location:
    Devon, England
    I'm sorry to have wasted your time. :oops:

    I simply cannot remember - I set off boating on my narrowboat two plus weeks ago .......... and clean forgot I'd asked the question! My bad! :thumbd:

    Dave
     
Loading...
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.