Powershell Excel Add Worksheet After

Worksheets.Add 方法 (Excel)Worksheets.Add method (Excel)

  • 05/18/2019
  • 作者
    • office 365 dev account
    • olprod
    • Office GSX

本文内容

创建新的工作表、图表或宏工作表。Creates a new worksheet, chart, or macro sheet. 新工作表成为活动工作表。The new worksheet becomes the active sheet.

语法Syntax

表达式(之前之后计数类型)expression.Add (Before, After, Count, Type)

_表达式_一个代表**工作表** 对象的变量。expression A variable that represents a Worksheets object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data type说明Description
BeforeBefore可选OptionalVariantVariant指定工作表的对象,新建的工作表将置于此工作表之前。An object that specifies the sheet before which the new sheet is added.
AfterAfter可选OptionalVariantVariant指定工作表的对象,新建的工作表将置于此工作表之后。An object that specifies the sheet after which the new sheet is added.
CountCount可选OptionalVariantVariant要添加的工作表数。The number of sheets to be added. 默认值为 1。The default value is one.
TypeType可选OptionalVariantVariant指定工作表类型。Specifies the sheet type. 可以是下列的**XlSheetType** 常量之一: xlWorksheetxlChartxlExcel4MacroSheetxlExcel4IntlMacroSheet。Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. 如果要基于现有模板插入工作表,请指定模板的路径。If you are inserting a sheet based on an existing template, specify the path to the template. 默认值为 xlWorksheet

 

按照上面的理论,Excel Add Worksheet 第一个参数为Before,第二个为After

在POWERHSELL中,Before的值也不能忽略,也不能为$Null,只可以为[System.Reflection.Missing]::Value

For Example:

$xl.Worksheets.add([System.Reflection.Missing]::Value,$xl.Worksheets.Item($xl.Worksheets.count))

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值