function export_excel(help,helpColumns)
    local line = CVector();
    local lineName = CVector();
    helpColumns:orderBy('序号');
    for i=0,helpColumns:size()-1 do
        if helpColumns:vs(i,'是否显示') == '1' then
            line:push_back(helpColumns:vs(i,'编码'));
            lineName:push_back(helpColumns:vs(i,'显示名称'));
        end
    end 
    local xlsx = CLuaXlsxUtil();
    local helpFormat = CSelectHelp();
    for i=0,lineName:size()-1 do
        xlsx:writeString(1,i+1,lineName:get(i),helpFormat);
    end
    for i=0,help:size()-1 do
        for j=0,line:size()-1 do
            xlsx:writeString(i+2,j+1,help:vs(i,line:get(j)),helpFormat);
        end
    end
    local sName = ui:getSaveFileName('保存文件',cutil:getBusiUniqueID('',''),'(*.xlsx)');
    xlsx:saveAs(sName);
    if ui:msgConfirm('是否打开文件', sName) then
        sName = string.gsub(sName, '/', '\\');
        os.execute(string.format([[explorer "%s"]], sName));
    end
end
local m_pGrid = CLuaGridUtil();
m_pGrid:SetGrid(ui:getDialogName(),'id_grid');
local m_help = CSelectHelp();--需要SQL查询获取数据
m_pGrid:setHelp(m_help);
local helpColumns = CSelectHelp();
m_pGrid:getColumnsInfo(helpColumns);--获取表格列属性信息
local help = CSelectHelp();
m_pGrid:getHelp(help);--获取表格数据
--调用export_excel方法导出Excel
export_excel(help,helpColumns);
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""