mercredi 25 novembre 2020

Checking a cell in a spreadsheet for blank values

Folks,

Im trying to have powershell see if there is data in a certain cell, as no action is needed if it is blank.

Here's what I have so far:

$Excel = New-Object -ComObject Excel.Application

$Workbook = $Excel.Workbooks.Open('MySheet.xlsx')

$workSheet = $Workbook.Sheets.Item(1)
$WorkSheet.Name

$column = 1
$row = 2
$info = $workSheet.cells.Item($row, $column).text
#$excel.Quit()

echo $info 

$info of course has nothing in it.

Basically, if cell A2 is blank, Im going to exit, otherwise Ill send an email, etc. I guess Im asking do I convert $info to string?

Ive tried If($info = "") and If($info -eq null) but I guess Im stuck on where to go now. How do I tell the computer "Hey, if there is anything in cell A2, do this"

Thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire