大家好,欢迎来到IT知识分享网。
1. 获取指定Sheet并激活
Application对象是整个Excel结构的根对象,可用于获取常用属性如ActiveCell、ActiveWorkbook、ActiveSheet
Application.Workbooks.Item(file_name).Worksheets.Item("Sheet1").Activate()
2. 获取Sheet上某一区域
myRange = Application.Range("A1:B5")
3.对选定区域进行设置,修改边框,行高,列宽,字体等操作
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
4. 输入框和提示框
// 输入框
let total = Application.InputBox("请输入数量", "输入提示", undefined, undefined, undefined, undefined, undefined,1)
//提示框 样式参见JSMsgBoxStyle枚举
confirm_flag = MsgBox("请确认信息无误",jsOKCancel+jsDefaultButton1,"确认")
5. 打印设置
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 页"
6. 参考
https://open.wps.cn/docs/client/wpsLoad wps开发文档
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/25441.html