lua對於excel的操作


require("luacom");
require("lc");

--創建excel對象
local excel = luacom.CreateObject("Excel.Application"); --創建新的實例

excel.Visible = false;

local book =excel.Workbooks:Add();

--讀第一個工作表
local sheet = book.Sheets(1); 

sheet.Cells(1, 1).Value2 = "hello";
sheet.Cells(1, 2).Value2 = lc.a2u("你好");

sheet.Cells(2, 1).Value2 = "hello";
sheet.Cells(2, 2).Value2 = "java";

local name = 'E://' ..  lc.a2u("fjhx") .. '.xls';

-- 保存
book:SaveAs(name);

book:Close();

--[[ 關閉excel -------------]]
excel:Quit();

--釋放資源
excel = nil;

collectgarbage();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM