엑셀 실행후 데이터 넣기
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$workbook = $excel.Workbooks.add()
$sheet = $workbook.worksheets.Add()
$sheet.Name = "First"
$sheet.Cells.Item(1,1) = '1,1'
$sheet.Cells.Item(1,2) = '1,2'
$sheet.Cells.Item(2,1) = '2,1'

Cell 색깔 바꾸기
$sheet.Cells.Item(1,1) = '1,1'
$sheet.Cells.Item(1,1).Interior.ColorIndex = 44

Color Index

사용예
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$workbook = $excel.Workbooks.add()
$sheet = $workbook.worksheets.Add()
$sheet.Name = "First"
1..5 | %{
$i = $_
1..4 | %{
$j = $_
$value = "({0},{1})" -f $i, $j
$sheet.Cells.Item($i,$j) = $value
if($i % 2 -eq 0){
$sheet.Cells.Item($i,$j).Interior.ColorIndex = 44
}
}
}

'파워쉘(Powershell) > 파일,폴더' 카테고리의 다른 글
파워쉘-엑셀파일 읽기 (0) | 2024.04.22 |
---|---|
파워쉘 - 파일 생성, 읽기, 쓰기 (0) | 2024.04.04 |
파워쉘 - 파일 이름 변경 및 지우기 (0) | 2024.04.02 |
파일, 폴더 목록 (0) | 2024.03.07 |