居中对齐整个工作表

时间:2015-05-19 19:10:25

标签: excel powershell text-alignment

我当前的代码只对齐Excel工作表的前5行:

$xlCenter=-4108 
$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$excel.Rows.Item("1:5").HorizontalAlignment = $xlCenter

但是没有人知道我的程序将从数据库中读取多少行。如何居中对齐所有行?

1 个答案:

答案 0 :(得分:3)

不要将您应用格式的行限制为:

"Name","Address","FullPhone"
"Mike Wise","101 Abc Drive","4061234567" // Need to separate area code from the rest