07.02.03.tiptop集成篇(4gl扩展功能 集成java:封装java的poi包设配4gl 案例 导入excle) 本页目录1、案例2、测试闲鱼DKLi1717 引用POI包Excel批量处理s_poi_excel.4gl下载excle的模板到桌面anmt200.xlsx案例p_test.4fd?xmlversion1.0encodingUTF-8?ManagedFormgstVersion22800nameManagedFormuid{2b41e64b-b5a8-42eb-a856-c2e80d7d16b3}AGSettings/RecordadditionalTablesjoinLeftjoinOperatorjoinRightnames_emailorderuid{d7e34c48-750d-4f0b-a17b-f04e0949bb58}where/RecordadditionalTablesjoinLeftjoinOperatorjoinRightnames_pmdorderuid{63a46eb9-f9b8-4526-a2cd-4faf9f248688}where/FormgridHeight6gridWidth40nameFormtextFormVBoxgridHeight6gridWidth38nameVBox1posX1posY0GridgridHeight4gridWidth38nameGrid1posX0posY1//VBox/FormDiagramLayout![CDATA[AAAAAgAAAEwAewBkADcAZQAzADQAYwA0ADgALQA3ADUAMABkAC0ANABmADAAYgAtAGEAMQA3AGIALQBmADAANABlADAAOQA0ADkAYgBiADUAOAB9QFwAAAAAAABAaqAAAAAAADWhysCDEmAQAAAEwAewA2ADMAYQA0ADYAZQBiADkALQBmADkAYgA4AC0ANAA1ADIANgAtAGEAMgBjAGQALQA0AGYAYQBmADkAZgAyADQAOAA2ADgAOAB9QCQAAAAAAABAJAAAAAAAADRaHKwIMSeAQ]]/DiagramLayout/ManagedFormp_test.4glIMPORT os IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFWorkbook IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFSheet IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFRow IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFCell DATABASE ds GLOBALS../../config/top.globalGLOBALS DEFINE g_curs_index LIKE type_file.num10 DEFINE g_row_count LIKE type_file.num10 DEFINE filename STRING DEFINE workbook XSSFWorkbook DEFINE sheet XSSFSheet DEFINE row XSSFRow DEFINE cell XSSFCell END GLOBALS MAIN DEFINE p_row,p_col LIKE type_file.num5 LET p_rowARG_VAL(1)LET p_colARG_VAL(2)LETg_curs_indexARG_VAL(3)LETg_row_countARG_VAL(3)OPTIONS FORM LINE FIRST 2, MESSAGE LINE LAST, PROMPT LINE LAST, INPUT NO WRAP DEFER INTERRUPT IF(NOT cl_user())THEN EXIT PROGRAM END IF WHENEVER ERROR CALL cl_err_msg_log IF(NOT cl_setup(CZZ))THEN EXIT PROGRAM END IF CALL cl_used(g_prog,g_time,1)RETURNING g_time LET p_row5LET p_col10OPEN WINDOW test_w AT p_row,p_col WITH FORMczz/42f/p_testATTRIBUTE(STYLEg_win_style CLIPPED)CALL cl_ui_init()CALL test_menu()CLOSE WINDOW test_w CALL cl_used(g_prog,g_time,2)RETURNING g_time END MAIN# mathodName: test_menu# author:DKLi1717 2665252078qq.com# date:Created in 2025-03-14# description: 菜单栏位置FUNCTION test_menu()MENUBEFORE MENU CALL cl_navigator_setting(g_curs_index, g_row_count)ON ACTION import_excel CALL uploadEXCLE()CALL readEXCLE()ON IDLE g_idle_seconds CALL cl_on_idle()CONTINUE MENU ON ACTION locale CALL cl_dynamic_locale()CALL cl_show_fld_cont()ON ACTION qbe_select CALL cl_qbe_select()ON ACTIONhelpCALL cl_show_help()ON ACTION about CALL cl_about()ON ACTION controlg CALL cl_cmdask()ON ACTIONexitLET INT_FLAGFALSE EXIT MENU ON ACTION close LETINT_FLAGFALSE EXIT MENU END MENU END FUNCTION# mathodName: uploadEXCLE# author:DKLi1717 2665252078qq.com# date:Created in 2025-03-14# description: 上传文件到服务器FUNCTION uploadEXCLE()DEFINE l_location STRING, ls_str STRING WHILE TRUE PROMPT ls_str CLIPPED FOR l_location ATTRIBUTE(WITHOUT DEFAULTS)ON ACTION accept EXIT WHILE ON ACTION cancel EXIT WHILE ON ACTION browse_document LET l_locationcl_browse_file()ON IDLE g_idle_seconds CALL cl_on_idle()RETURN END PROMPT END WHILE# 获取上传附件的名称LETfilenamel_location WHILE filename.getindexof(os.path.separator(),1)0LETfilenamefilename.substring(filename.getindexof(/,1)1,filename.getlength())END WHILE LETstatuscl_upload_file(l_location,/u1/out/||filename)IF status THEN CALL cl_err(,abm-019,0)ELSE CALL cl_err(,abm-020,0)END IF END FUNCTION# mathodName: readEXCLE# author:DKLi1717 2665252078qq.com# date:Created in 2025-03-14# description: 读readEXCLE信息FUNCTION readEXCLE()CALL workbook_open(/u1/out/||filename)RETURNING workbookDISPLAYsheets数||workbook.getNumberOfSheets()LETsheetworkbook.getSheetAt(0)#获取第1个sheetDISPLAY行数||sheet.getPhysicalNumberOfRows()LET rowsheet.getRow(1)#获取第2行DISPLAY列数||row.getPhysicalNumberOfCells()LET cellrow.getCell(1)#获取第2列DISPLAY列类型||cell.getCellType()DISPLAY列字符值||cell.getStringCellValue()LET cellrow.getCell(4)#获取第5列DISPLAY列类型||cell.getCellType()DISPLAY列数字值||cell.getNumericCellValue()DISPLAYSFMT(Evaluated value in cell B12 %1, workbook.getCreationHelper().createFormulaEvaluator().evaluate(cell).getNumberValue())END FUNCTION测试# 上传代码cd/u1/toptest/topcust/csub/4gl put s_poi_excel.4glcd/u1/toptest/topcust/czz/4gl put p_test.4gl# 编译代码cd/u1/toptest/topcust/csub/4gl r.c2 s_poi_excelcd/u1/toptest/topcust/czz/4gl r.c2 p_test r.l2 p_test exe2 p_test

相关新闻

最新新闻

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现 【免费下载链接】serenity The Serenity Operating System 🐞 项目地址: https://gitcode.com/GitHub_Trending/se/serenity 导读 本文以 getopt(3) 手册 为核心&a…

2026/10/1 19:32:24
轻量服务器还是ECS?大促云服务器选购与避坑实战指南

轻量服务器还是ECS?大促云服务器选购与避坑实战指南

每年大促节点,群里永远有人在问同一个问题:“38元的轻量服务器到底怎么抢?为什么我每次点进去都是已售罄?68元直购和99元的ECS我到底选哪个?”作为一个常年帮团队和自己采购云服务器的老用户,我太清楚这种纠…

2026/9/30 21:32:07
为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南 【免费下载链接】agents Multi-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity 项目地址:…

2026/10/2 15:29:32
PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署 【免费下载链接】PaddleOCR Turn any PDF or image document into structured data for your AI. A powerful, lightweight OCR toolkit that bridges the gap between i…

2026/10/1 19:32:23
Spring源码解析:构造器注入的类型转换与候选匹配机制

Spring源码解析:构造器注入的类型转换与候选匹配机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/1 19:32:35
openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由 【免费下载链接】openai-agents-python A lightweight, powerful framework for multi-agent workflows 项目地址: https://gitcode.com/GitHub_Trending/op/openai-agents-pyth…

2026/9/30 21:32:11

日新闻

周新闻

月新闻