本帖最后由 newswan 于 2021-6-24 00:00 编辑
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $true
- $Workbook = $Excel.Workbooks.Add()
- $Sheet = $Workbook.Worksheets.Item(1)
- for ($i =1 ; $i -le $da.count ; $i++)
- {
- $Sheet.cells($i,1).value = $da[$i-1]
- }
- $colA=$sheet.range("A1").EntireColumn
- $colrange=$sheet.range("A1")
- $colA.texttocolumns($colrange,1,1,$true,$true,$false,$false,$false)
- $sheet.columns.autofit()
- $Workbook.SaveAs(($PSScriptRoot + "\" + $fileDest))
- $excel.Quit()
复制代码 生成 excel 文件 加到后面 |