I get asked many times to write a script to parse Excel files
First , we need to tell Powershell what file we're interested in, and let it see its content.
$FilePath = "C:\Users\me\Documents\myexcelfile.xls"
We then need to create a new excel object ,so that PS know what kind of format the file will be in
$objExcel = New-Object -ComObject Excel.Application
After having created the objext, we can use a variable to store the content of the workbook in a variable:
$WorkBook = $objExcel.Workbooks.Open($FilePath)
We assign the sheets name to a variable like so:
$Overview = "Overview"
$Overview_sheet = $WorkBook.sheets.item($Overview)
$PositionSheet = $WorkBook.sheets.item($positions)
#--- INVOICE NUMBER
$INVOICE_NUM = $Overview_sheet.Range("B6").Text
$INVOICE_DATE = $Overview_sheet.Range("B7").Text
Subscribe to our newsletter to get notification about new updates, information, discount, etc..