Application对象是整个Excel结构的根对象,可用于获取常用属性如ActiveCell、ActiveWorkbook、ActiveSheet
Application.Workbooks.Item(file_name).Worksheets.Item("Sheet1").Activate()
myRange = Application.Range("A1:B5")
myRange.Value2 = "Hello World!"
// 设置行高,列宽
myRange.Rows.ColumnWidth = 12.28
myRange.Rows.RowHeight = 39
// 设置水平和垂直居中
myRange.Rows.HorizontalAlignment=xlHAlignCenter
myRange.Rows.VerticalAlignment=xlVAlignCenter
// 设置字体
myRange.Rows.Font.Size = 12
myRange.Rows.Font.Name = "宋体"
myRange.Font.Bold = true
// 取消边框
myRange.Borders.LineStyle = 0
// 输入框
let total = Application.InputBox("请输入数量", "输入提示", undefined, undefined, undefined, undefined, undefined,1)
//提示框 样式参见JSMsgBoxStyle枚举
confirm_flag = MsgBox("请确认信息无误",jsOKCancel+jsDefaultButton1,"确认")
myPage = Application.ActiveSheet.PageSetup
//设置页边距
myPage.TopMargin = Application.CentimetersToPoints(1.50)
myPage.BottomMargin = Application.CentimetersToPoints(1.50)
myPage.LeftMargin = Application.CentimetersToPoints(1.50)
myPage.RightMargin = Application.CentimetersToPoints(1.50)
myPage.HeaderMargin = Application.CentimetersToPoints(1.00)
myPage.FooterMargin = Application.CentimetersToPoints(1.00)
//设置页眉和页脚
myPage.RightHeader = "我是页眉"
myPage.CenterFooter = "第 &P 页,共 &N 页"