- 精华
- 阅读权限
- 80
- 贡献
- 人
- 好友
- 相册
- 分享
- 听众
- 收听
- 注册时间
- 2023-5-2
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
发表于 2026-4-24 09:05:52
|
显示全部楼层
这个一般在GEE里,也可以自己写,参考下这个
function ReadExcel(paths,stringkey)
path=程序目录.."//sysdata//"..paths..".data"
local key={}
for i=1,string.len(stringkey) do
table.insert(key,string.byte(string.sub(stringkey,i,i)))
end
-- if stringkey ~="小神授权" then
-- 引擎.关闭()
-- end
local file = assert(io.open(path, "rb"))
local DecryptData ={}
local number =0
while true do
local bytes = file:read(1)
if not bytes then break end
for b in string.gfind(bytes, ".") do
num=tonumber(string.byte(b))
-- io.write(num,",")
local a= number%#key
DecryptData[number+1]=bit.bxor(tostring(num),key[a+1])
number=number+1
end
end
file:close()
local indexes=0
local bufToInt32 = function (dataTable)
local num = 0;
num = num + math.floor(dataTable[indexes+4] * (2 ^ 24))
num = num + math.floor(dataTable[indexes+3] * (2 ^ 16))
num = num + math.floor(dataTable[indexes+2] * (2 ^ 8))
num = num + dataTable[indexes+1];
indexes=indexes+4
return num;
end
local bufToInt16=function(dataTable)
local num = 0;
num = num + math.floor(dataTable[indexes+2] * (2 ^ 8));
num = num + dataTable[indexes+1];
indexes=indexes+2
return num;
end
local Row= bufToInt32(DecryptData)
local Column=bufToInt32(DecryptData)
local ReadASCIIString =function(dataTable)
local len = bufToInt16(dataTable);
local a={}
for i=1,len do
table.insert(a,dataTable[indexes+1])
indexes=indexes+1
end
return string.char(unpack(a))
end
local FieldName={}
local GameData={}
local GameDataName
local funType={}
for i=1,Row do
for j=1,Column do
local str = ReadASCIIString(DecryptData);
if i==1 then
FieldName[j] = str;
elseif i==3 then
if str=="number" then
funType[j]=tonumber
elseif str=="string" then
funType[j]=tostring
elseif str=="array" then
funType[j]=toTablenumber
elseif str=="table" then
funType[j]=toTable
elseif str=="json" then
funType[j]=cjson.decode
end
--print(str)
elseif i>3 and str~="" then
if j==1 then
GameData[assert(funType[j](str))]={}
GameDataName=assert(funType[j](str))
else
--print(str)
GameData[GameDataName][FieldName[j]] = assert(funType[j](str))
end
end
end
end
print(string.format("加载%s成功-->", paths))
return GameData
end |
评分
-
查看全部评分
|