title: How to read an Excel file in PowerShell on Linux?
body: <p>As many of you are aware, PowerShell can now be <a href="https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.2" rel="nofollow noreferrer">installed and used on Linux</a> and it has worked surprisingly well for me so far. However, I wonder if the content of an Excel file can be read given that Excel cannot be installed on Linux. What I have found online is that the PS script to open an Excel file is:</p>
  <pre><code># Script copied and pasted from https://stackoverflow.com/questions/48443536/how-to-read-excel-files-in-powershell
  
  $excel = New-Object -com excel.application
  $wb = $excel.workbooks.open(&quot;c:\users\administrator\my_test.xls&quot;)
  </code></pre>
  <p>But I get the error:</p>
  <pre><code>New-Object: A parameter cannot be found that matches parameter name 'com'.
  </code></pre>
  <p>When I remove the parameter and run the script, this is the error I get:</p>
  <pre><code>New-Object: Cannot find type [excel.application]: verify that the assembly containing this type is loaded.
  </code></pre>
  <p>Since I'm on Linux (ubuntu 22.04), I can use <code>xls2csv</code> on bash to convert the Excel file to csv and then use <code>Get-Content</code> on PowerShell. But I would like to know if there is a way to do it on PowerShell since I am currently learning it.</p>
  <p>Thank you.</p>