国产探花免费观看_亚洲丰满少妇自慰呻吟_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()

 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西藏| 美姑县| 溧阳市| 上饶县| 辽中县| 沈阳市| 郯城县| 大厂| 茂名市| 沛县| 凌源市| 平邑县| 黎川县| 建瓯市| 兴义市| 东方市| 同仁县| 共和县| 红安县| 德兴市| 时尚| 怀化市| 长垣县| 黄山市| 怀来县| 平邑县| 长治县| 合作市| 云和县| 犍为县| 信丰县| 太仆寺旗| 堆龙德庆县| 德州市| 阳信县| 城市| 株洲县| 繁峙县| 定安县| 阳曲县| 闽清县|