Import-Xls

Import from Excel to Powershell.

 
 
 
 
 
3.8 Star
(5)
Add to favorites
Office
4/10/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Problem on Server 2016
    1 Posts | Last post May 29, 2019
    • I had a script that used Import-XLS to read some XLS and XLSX files.  However, it kept crashing Excel when I tried running the script on Server 2016.  The only way past this was using the Import-Excel module that I found.  Unfortunately, it doesn't seem as though the Import-XLS module supports Server 2016.
  • Passworded Excel file
    1 Posts | Last post December 30, 2018
    • Love your script for importing users to be added to Active Directory from an ADP feed. We now have a new twist in doing this. Is there a way to handle passworded Excel files?
  • Formatting
    1 Posts | Last post September 01, 2016
    • hi
      
      When using this, I get a semicolon separated array out. suppose excel looked like this
      name lastname number
      a b 1
      c d 2
      
      In Powershell I get an array like this
      name;lastname;number
      a;b;1
      c;d;2
      
      
      I changed this line
      Import-Csv $csvTemp;
      to this
      Import-Csv $csvTemp -Delimiter ";";
      
      And now it works like its supposed
      It is probably some regional settings or something in windows/excel
      I am using windows 7 and office 2010 with Scandinavian regional settings
  • Exception calling "Add" with "1" argument(s): "Old format or invalid type library.
    1 Posts | Last post February 12, 2016
    • Hi Guys,
      
      I have a problem with this script. Can't import a .xlsx. 
      
      Exception calling "Add" with "1" argument(s): "Old format or invalid type library. (Exception from HRESULT: 0x80028018
      (TYPE_E_INVDATAREAD))"
      At line:113 char:21
      +                     $wb = $xl.Workbooks.Add($_);
      +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ComMethodTargetInvocation
      
      krg Anel
  • import a file with path
    3 Posts | Last post October 08, 2015
    • hi there, 
      i was using your function the other day AND IT WORKS GREAT for me.
      thanks a lot.
      1 question those, i am looking to import the file from a different path then the one i put this function in, so the command obviously needs to change a bit. ".\employees.xlsx" | Import-Xls -Worksheet "Sheet2"
      so i tried play with it a bit and couldnt figure out how to do so, because it is failing on my tries (IE: "c:\temp\employees.xlsx" | Import-Xls -Worksheet "Sheet2"
      can you help ?
      thanks.
      tomer.
    • I actually need it to acquire the file from the network so it should be somthing like
      "\\netapp\share\employees.xlsx" | Import-Xls -Worksheet "Sheet2"
      
    • Quick fix, change the line
        $_ = (Resolve-Path $_).toString();
      
      to
        $_ = (Resolve-Path $_).ProviderPath
      
      Better fix, remove that line and change the follow line to:
        $wb = $xl.Workbooks.Add((Resolve-Path $_).ProviderPath); 
      
      I don't like changing the pipeline variable.  In fact this could be cleaned up since the $path variable is already the pipevariable and then piped again to a foreach within the process block.  But otherwise it is a nice function.
      
      
  • Character Encoding
    1 Posts | Last post February 03, 2015
    • I'm not entirely sure about this (character encoding is messy work), but might i suggest you change line 143 to read:
      
      Import-Csv $csvTemp -Encoding "Default";
      
      Because Excel files doesnt save its content using ASCII by default.
  • V2 Suggestion
    5 Posts | Last post September 30, 2014
    • This is a nice script.  Since your already using V2 stuff here,why not go all the way and add Help tags and cmdletbinding to make it a full blow advanced function?
    • Thanks. Maybe this weekend.
    • I'm trying out ideas on how Export-Xls should work when its input is piped. I don't want to Import-Xls to have inputs from the pipeline if Export-Xls can't do it. If you have any suggestions, I'd be glad to hear them.
    • Done, I think.
    • Hi imfrancisd,
      Can you take a look on my question please ?
      Thank you veri much.
      Tomer.
  • Ability to run on 2008 R2
    2 Posts | Last post August 21, 2014
    • I like your script, but am having issues executing it on a 2008 R2 server with Powershell installed - any hints or ideas?  It bombs out on this line
          [CmdletBinding(SupportsShouldProcess=$true)] 
    • Sorry for the late response.
      
      If you get an error message like:
      
          CmdletBinding : Unexpected attribute 'CmdletBinding'.
      
      then remove the empty line after [CmdletBinding(SupportsShouldProcess=$true)].
      
      In other words, there should be no empty line between "[CmdletBinding(SupportsShouldProcess=$true)]" and "Param(".
      
      This error occurs when pasting the script directly into the PowerShell (version 2) console.
      
      If you are getting a different error, please post the full error message along with a brief description of how you used the script.
      
      Thanks for the feedback.
      Francis