问题描述
亲爱的所有人,
我正在尝试为表格添加标题并相应地格式化,但我m被提示错误"你不能在空值表达式上调用方法"你能帮忙吗? IM使用powershell和excel 2016版本。
I'm trying to add a title to a sheet and format it accordingly, but I'm being prompted with an error "you cannot call a method on a null-valued expression" Could you please assist. IM using powershell and excel 2016 version.
$ ASheet = $ Workbook.Cells.Item(1,1)="每日报告 - $(Get-date -f'dd MMMM yyyy')"
$ASheet = $Workbook.Cells.Item(1,1) = "Daily Report - $(Get-date -f 'dd MMMM yyyy')"
$ ASheet.Cells.Item(1,1).Font.Size = 14
$ ASheet.Cells.Item(1,1).Font.Bold = $ True
$ ASheet.Cells.Item(1,1).Font.Name =" Cambria" b
$ ASheet.Cells.Item(1,1).Font.ThemeFont = 1
$ ASheet.Cells.Item(1,1).Font.ThemeColor = 4
$ ASheet.Cells.Item(1,1).Font.ColorIndex = 55
$ ASheet.Cells.Item(1,1).Font.Color = 8210719
$ range = $ ASheet.range(" A1:E1")。Merge()| Out-Null
$ASheet.Cells.Item(1,1).Font.Size = 14
$ASheet.Cells.Item(1,1).Font.Bold = $True
$ASheet.Cells.Item(1,1).Font.Name = "Cambria"
$ASheet.Cells.Item(1,1).Font.ThemeFont = 1
$ASheet.Cells.Item(1,1).Font.ThemeColor = 4
$ASheet.Cells.Item(1,1).Font.ColorIndex = 55
$ASheet.Cells.Item(1,1).Font.Color = 8210719
$range = $ASheet.range("A1:E1").Merge() | Out-Null
谢谢
推荐答案
这篇关于使用PowerShell向excel 2016添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!