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