国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

lua操作excel方法分享

2024-07-21 23:04:23
字體:
來源:轉載
供稿:網友

通過luacom操作excel。網上提供的資料很少,我模仿vba找出了一些基本操作方法。

 

復制代碼 代碼如下:

require 'luacom'
local excel = luacom.CreateObject('Excel.Application')
excel.Visible = true
local book = excel.Workbooks:Add()
local sheet = book.Worksheets(1)
sheet.Name = 'gty'
local range = sheet:Range('A1:A10')
local cell = sheet.Cells(1,1)
sheet:Range('D3:D6'):Merge()--合并單元格
range.Value2 = 1
range.Font.Size = 20
sheet.Cells(1,2).FormulaR1C1 = '=R3C1+R4C1' --公式
cell.Value2 = 'gty'
cell.Font.Name = 'Arial'
--cell.Font.FontStyle = 'bold'
cell.Font.Bold = true
sheet.Cells(4,5).EntireRow.Interior.Color = 0x334455    --整行操作
sheet.Cells(4,5).EntireColumn.Interior.Color = 0x998877 --整列操作
cell.Font.Size = 20
cell.Font.Color = 0x0000ff
cell.Font.Underline = true
cell.Font.Strikethrough = true  --刪除線
cell.font.OutlineFont = true    --下劃線
range.Interior.Color = 0x778899 --區域上色
range.Borders.LineStyle = 1     --邊框樣式 --每個小的內邊框
sheet:Range('C2:G7').BorderAround(1)--外邊框
--range.Borders.Weight = 4      --邊框寬度
--range.Interior.Pattern = 8    --區域花紋
--cell.Font.Shadow = true
--cell.Font.SuperScript = true
--cell.Font.SubScript = true
print(range.Cells.Count)    --統計單元格數
print(range.Rows.Count)
print(range.Columns.Count)
range.NumberFormat = '$#,##0.00'    --格式化數字
sheet:Range('A2'):Cut()     --剪切
sheet:Range('A3'):Copy()    --復制
sheet:Paste(sheet:Range('B3')) --粘貼
book.Worksheets('sheet3'):Delete()
book:SaveAs(filePath,51)--51xlsx -4143xls
excel:Quit()

 

以上就是代碼的全部內容了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 察隅县| 同德县| 都兰县| 阿合奇县| 灵宝市| 蚌埠市| 西青区| 吐鲁番市| 合山市| 克拉玛依市| 仲巴县| 德惠市| 余干县| 丽江市| 棋牌| 张家口市| 清流县| 大城县| 陈巴尔虎旗| 南澳县| 滨海县| 广饶县| 太湖县| 丰镇市| 历史| 原阳县| 聊城市| 闵行区| 尉犁县| 邹城市| 永新县| 乌什县| 体育| 宁国市| 南雄市| 定陶县| 古交市| 凤翔县| 汉寿县| 聊城市| 焉耆|