使用Powershell中的ComObject Excel.Application选择活动工作表中的所有单元格
Powershell非常新 情况: 我下面的脚本旨在执行以下操作:使用Powershell中的ComObject Excel.Application选择活动工作表中的所有单元格,excel,powershell,comobject,Excel,Powershell,Comobject,Powershell非常新 情况: 我下面的脚本旨在执行以下操作: 打开新工作簿 将“这是A1”放在单元格“A1”中 选择活动工作表中的所有单元格 将所选内容设置为文本数据格式 以下是我的Powershell脚本: 问题: 我不知道如何在命令中写入全选,因为当我运行脚本时,它只生成'A1&B1'文本单元格,其他所有内容都保留为常规格式。我想让这个范围充满活力 这是我在VBA中的脚本: 我试图遵循的脚本: 有谁能帮助我,让我的SELECT ALL语句更具动态性吗 非常感谢。试试这个,它对我有用。
'A1&B1'
文本单元格,其他所有内容都保留为常规格式。我想让这个范围充满活力
这是我在VBA中的脚本:
我试图遵循的脚本:
有谁能帮助我,让我的SELECT ALL语句更具动态性吗
非常感谢。试试这个,它对我有用。您可以通过选择所有行(或)所有列
$excel = New-Object -Com Excel.Application
$excel.visible = $true
$book = $excel.Workbooks.Add()
$worksheet = $book.ActiveSheet
$worksheet.Range("A1").Value2 = "This is A1" # Use the property 'Value2'
$worksheet.Rows.NumberFormat = "@"
# $worksheet.Columns.NumberFormat = "@" # this also sets number format of all cells to 'Text'
$worksheet.cells.numberformat=“@”
或$worksheet.usedrange.numberformat=“@”
不带$copyrange=
Sub TEXT_FORMAT()
ActiveCell.FormulaR1C1 = "This is A1"
Cells.Select
Selection.NumberFormat = "@"
End Sub
$excel = New-Object -Com Excel.Application
$excel.visible = $true
$book = $excel.Workbooks.Add()
$worksheet = $book.ActiveSheet
$worksheet.Range("A1").Value2 = "This is A1" # Use the property 'Value2'
$worksheet.Rows.NumberFormat = "@"
# $worksheet.Columns.NumberFormat = "@" # this also sets number format of all cells to 'Text'