Я хочу прочитать значение из .xls и записать его как .xml на основе ввода, предоставленного в .xls.
.xls
.xml
Get-ChildItem 'C:yourfile*.xml' -Recurse | ForEach { (Get-Content $_ | ForEach { $_ -replace '[MYID]', 'MyValue' }) | Set-Content $_ }
$sheetNumber = 1 $startRow = 2 $endRow = 3 $searchResouceId = 3 $searchResourceName = 1 $xls = "C:\Codes\book1.xlsx" $find = '<title></title>' $excel = New-Object -Com Excel.Application $wb = $excel.Workbooks.Open($xls) $sh = $wb.Sheets.Item($sheetNumber) $row = $startRow; for ($j = 1; $j -le $endRow; $j++) { $resourceId = $sh.Cells.Item($row, $searchResouceId).Value2 $resourceName = $sh.Cells.Item($row, $searchResourceName).Value2 Write-Output "Creating : $resourceId" Copy-Item "sample.html" -Destination "C:\Codes\$resourceName.html" $file = "C:\Codes\$resourceName.html" $row = $row + 1 $replace = "<title>$resourceId/title>" (Get-Content $file).replace($find, $replace) | Set-Content $file } $excel.Workbooks.Close()