I’m currently attempting to update an very large excel spreedsheet using OLEDB provider. I have to update blank field within one column. The Excel file is 55K+ lines, and probably more than half of them are blank. I’m able to Select * from file and get all the listed Items in the column including the blank. I want to update the blank cells, so I’m using the Update SQL command. The issue is the <> operand is not selecting the blank cells. If I set the operand to = it will replace the cells that are equaled. It doesn’t take ‘’ or ’ ’ as the same as the blank cell. The below code return 0 rows effected, even though there are 20+ rows that don’t equal Operations in the same data. Any Help would be great.
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0" $strDataSource = "Data Source=`"$ExcelFile`"" $strExtend = "Extended Properties=`"Excel 12.0 Xml;HDR=YES`";" $strQuery = "Update [$strSheetName] set [Collection Name] = 'N\A' WHERE [Collection Name] <> 'Operations' " $objConn = New-Object System.Data.OleDb.OleDbConnection $objConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`"$strFileName`";Extended Properties=`"Excel 12.0 Xml;HDR=YES`";" $sqlCommand = New-Object System.Data.OleDb.OleDbCommand($strQuery) $sqlCommand.Connection = $objConn $objConn.open() $sqlCommand.ExecuteNonQuery() $objConn.Close()