使用PowerShell向excel 2016添加标题 [英] Adding a title to excel 2016 with powershell

查看:107
本文介绍了使用PowerShell向excel 2016添加标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在尝试为表格添加标题并相应地格式化,但我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

谢谢

推荐答案

没有更完整和准确的信息无法知道是什么导致了这一点。
Without more complete and accurate information there is no way to know what is causing this.


这篇关于使用PowerShell向excel 2016添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆