首页 > 其他分享 >ERP导出表格自定义格式R报表开发

ERP导出表格自定义格式R报表开发

时间:2023-07-06 11:37:17浏览次数:50  
标签:ERP LIKE 表格 XSSFCellStyle CALL LET docno DEFINE 自定义

按照正常流程新建程序,画面修改上传,程序下载修改

导入JAVA包,在global.import下

 

IMPORT com
IMPORT JAVA java.net.URL
IMPORT JAVA org.apache.poi.ss.util.CellRangeAddress
IMPORT JAVA org.apache.poi.ss.util.RegionUtil
IMPORT JAVA java.io.InputStream
IMPORT JAVA java.io.FileInputStream
IMPORT JAVA java.io.FileOutputStream
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFWorkbook
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFSheet
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFRow
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFCell
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFCellStyle
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFFont
IMPORT JAVA org.apache.poi.ss.usermodel.IndexedColors
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFDataFormat
IMPORT JAVA com.fourjs.fgl.lang.FglDecimal
IMPORT JAVA com.fourjs.fgl.lang.FglDate
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFWorkbook
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFSheet
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFRow
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFCell
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFCellStyle
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFFont
IMPORT JAVA org.apache.poi.ss.usermodel.IndexedColors
IMPORT JAVA org.apache.poi.hssf.usermodel.HSSFDataFormat
IMPORT JAVA org.apache.poi.xssf.streaming.SXSSFWorkbook
IMPORT JAVA org.apache.poi.ss.usermodel.CellStyle
IMPORT JAVA org.apache.poi.ss.usermodel.Sheet
IMPORT JAVA org.apache.poi.ss.usermodel.Row
IMPORT JAVA org.apache.poi.ss.usermodel.Cell
IMPORT JAVA org.apache.poi.ss.usermodel.Font
IMPORT JAVA org.apache.poi.ss.usermodel.DataFormat   
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
IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFCellStyle
IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFFont
IMPORT JAVA org.apache.poi.xssf.usermodel.XSSFDataFormat

 

在global.variable下添加全局变量

 

DEFINE g_showmsg                       STRING
DEFINE l_xlsfile                       STRING
DEFINE l_xlsname                       STRING
DEFINE l_target                        STRING
DEFINE fo                              FileOutputStream
DEFINE import_file                     InputStream
DEFINE workbook                        XSSFWorkbook
DEFINE sheet                           XSSFSheet
DEFINE row                             XSSFRow
DEFINE cell                            XSSFCell
DEFINE cell_xls                        HSSFCell
DEFINE font1                           XSSFFont
DEFINE font2                           XSSFFont
DEFINE font3                           XSSFFont
DEFINE font4                           XSSFFont
DEFINE format1         DataFormat
DEFINE g_num           FLOAT

 

在DIALOG ATTRIBUTES下添加查询栏位逻辑

 

         ON ACTION controlp INFIELD xcag004
            #add-point:ON ACTION controlp INFIELD xcag004 name="construct.c.xcag004"
            #應用 a08 樣板自動產生(Version:3)
            #開窗c段
            INITIALIZE g_qryparam.* TO NULL
            LET g_qryparam.state = 'c' 
            LET g_qryparam.reqry = FALSE
            CALL q_xcag004()                           #呼叫開窗
            DISPLAY g_qryparam.return1 TO xcag004  #顯示到畫面上
            NEXT FIELD xcag004                     #返回原欄位
    



            #END add-point
 
 
         #應用 a01 樣板自動產生(Version:2)
         BEFORE FIELD xcag004
            #add-point:BEFORE FIELD xcag004 name="construct.b.xcag004"

            #END add-point
 
 
         #應用 a02 樣板自動產生(Version:2)
         AFTER FIELD xcag004
            
            #add-point:AFTER FIELD xcag004 name="construct.a.xcag004"

            #END add-point

 

在process下的process.count_progress下添加调用方法逻辑

 

      CALL cxcr600_create_tmp()
      CALL cxcr600_export_excel()

 

写自己的方法,供上面调用

 

PRIVATE FUNCTION cxcr600_create_tmp()
     DROP TABLE cxcr600_tmp; 
     CREATE TEMP TABLE cxcr600_tmp(
       t_xcah020            LIKE   xcah_t.xcah020,    #bom阶层
       t_xcah004            LIKE   xcah_t.xcah040,    #主件料号
       t_xcah004_desc       LIKE   type_t.chr200,     #主件品名
       t_xcah004_1_desc     LIKE   type_t.chr200,     #主件规格
       t_xcaeud015_sum      LIKE   xcae_t.xcaeud015,  #合计工时
       t_xcah031_a_sum      LIKE   type_t.num20_6,    #合计材料费
       t_price_ws           LIKE   type_t.num20_6,    #未税单价
       t_xcah031_b_sum      LIKE   type_t.num20_6,    #合计人工费
       t_xcah031_b_szb      LIKE   type_t.num20_6,    #人工费用占比
       t_xcah031_a_szb      LIKE   type_t.num20_6,    #材料费用占比
       t_xcah022            LIKE   xcah_t.xcah022,    #元件料号
       t_xcah022_desc       LIKE   type_t.chr200,     #元件品名
       t_xcah022_1_desc     LIKE   type_t.chr200,     #元件规格
       t_xcaeud015          LIKE   xcae_t.xcaeud015,  #各阶段标准工时
       t_xcaeud016          LIKE   xcae_t.xcaeud016,  #各阶段标准机时
       t_xcah031_b          LIKE   type_t.num20_6,    #各阶段人力费
       t_xcah031_a          LIKE   type_t.num20_6,    #各阶段材料费
       t_xcah026            LIKE   xcah_t.xcah026,    #工时占比(各阶段/总)
       t_xcah025            LIKE   xcah_t.xcah025     #材料占比(各阶段/总)
     );

END FUNCTION

PRIVATE FUNCTION cxcr600_ins_tmp(p_imaa001_a)
    DEFINE p_imaa001_a     LIKE imaa_t.imaa001
    DEFINE l_sql           STRING
    DEFINE l_dex           LIKE type_t.num5
    DEFINE l_docno         DYNAMIC ARRAY OF RECORD 
       l_xcah020            LIKE   xcah_t.xcah020,    #bom阶层    
       l_xcah004            LIKE   xcah_t.xcah040,    #主件料号
       l_xcah004_desc       LIKE   type_t.chr200,     #主件品名
       l_xcah004_1_desc     LIKE   type_t.chr200,     #主件规格
       l_xcaeud015_sum      LIKE   xcae_t.xcaeud015,  #合计工时
       l_xcah031_a_sum      LIKE   type_t.num20_6,    #合计材料费
       l_price_ws           LIKE   type_t.num20_6,    #未税单价
       l_xcah031_b_sum      LIKE   type_t.num20_6,    #合计人工费       
       l_xcah031_b_szb      LIKE   type_t.num20_6,    #人工费用占比
       l_xcah031_a_szb      LIKE   type_t.num20_6,    #材料费用占比
       l_xcah022            LIKE   xcah_t.xcah022,    #元件料号
       l_xcah022_desc       LIKE   type_t.chr200,     #元件品名
       l_xcah022_1_desc     LIKE   type_t.chr200,     #元件规格
       l_xcaeud015          LIKE   xcae_t.xcaeud015,  #各阶段标准工时
       l_xcaeud016          LIKE   xcae_t.xcaeud016,  #各阶段标准机时
       l_xcah031_b          LIKE   type_t.num20_6,    #各阶段人力费
       l_xcah031_a          LIKE   type_t.num20_6,    #各阶段材料费
       l_xcah026            LIKE   xcah_t.xcah026,    #工时占比(各阶段/总)
       l_xcah025            LIKE   xcah_t.xcah025     #材料占比(各阶段/总)
    END RECORD
    DEFINE l_num           LIKE type_t.num5

    
    LET l_sql = "DELETE FROM cxcr600_tmp "
    EXECUTE IMMEDIATE l_sql
    
    #插入数据
    LET l_sql = "INSERT INTO cxcr600_tmp
                 SELECT xcah020,xcag004,a.imaal003,a.imaal004,0,0,0,0,0,0,xcah022,b.imaal003,b.imaal004,0,0,0,0,0,0 FROM xcag_t
                 LEFT JOIN xcah_t ON xcagent = xcahent AND xcagsite = xcahsite AND xcag001 = xcah001 AND xcag004 = xcah004
                 LEFT JOIN imaal_t a ON a.imaalent = xcagent AND a.imaal001 = xcag004 AND a.imaal002 = '",g_dlang,"'
                 LEFT JOIN imaal_t b ON b.imaalent = xcahent AND b.imaal001 = xcah022 AND b.imaal002 = '",g_dlang,"'
                 WHERE xcagent = ",g_enterprise," AND xcagsite = '",g_site,"' AND xcah004 = '",p_imaa001_a,"' 
                 AND xcag001 = '101' AND xcah023 = 'A'
                 ORDER BY xcah020 ASC "
    DISPLAY l_sql
    EXECUTE IMMEDIATE l_sql
    
    LET l_sql = " SELECT * FROM cxcr600_tmp "
    PREPARE l_upd_code FROM l_sql
    DECLARE l_upd_curs CURSOR FOR l_upd_code 
 
    CALL l_docno.clear()     #在进入循环之前把二维数组清空
    LET l_dex = 1            #初始化   
 
    FOREACH l_upd_curs INTO l_docno[l_dex].*
      
      #判断如果不属于A或者B料号,就删除,因为存在C,D料号属于A类型
       SELECT COUNT(*) INTO l_num 
       FROM cxcr600_tmp
       WHERE t_xcah022=l_docno[l_dex].l_xcah022 
       AND (t_xcah022 LIKE 'A%' OR t_xcah022 LIKE 'B%')
     IF cl_null(l_num) OR (l_num = 0) THEN
       #删除此料号
       DELETE FROM cxcr600_tmp 
       WHERE t_xcah004 = l_docno[l_dex].l_xcah004 
       AND t_xcah022 = l_docno[l_dex].l_xcah022  
     END IF
      LET l_num = 0
      LET l_dex = l_dex + 1
    
    END FOREACH
    
    
END FUNCTION

PRIVATE FUNCTION cxcr600_get_data(p_imaa001_a)
    DEFINE p_imaa001_a     LIKE imaa_t.imaa001
    DEFINE l_sql           STRING
    DEFINE l_dex           LIKE type_t.num5           #数组循环变量
    DEFINE l_num           LIKE type_t.num5           #判断是否夹治具
    DEFINE l_num1          LIKE xcah_t.xcah025        #上阶主件底数
    DEFINE l_num2          LIKE xcah_t.xcah026        #上阶组成用量
    DEFINE l_money_sh      LIKE type_t.num20_6        #主件损耗
    
    DEFINE l_docno         DYNAMIC ARRAY OF RECORD  
       l_xcah004            LIKE   xcah_t.xcah040,    #主件料号
       l_xcah004_desc       LIKE   type_t.chr200,     #主件品名
       l_xcah004_1_desc     LIKE   type_t.chr200,     #主件规格
       l_xcaeud015_sum      LIKE   xcae_t.xcaeud015,  #合计工时
       l_xcah031_a_sum      LIKE   type_t.num20_6,    #合计材料费
       l_price_ws           LIKE   type_t.num20_6,    #未税单价
       l_xcah031_b_sum      LIKE   type_t.num20_6,    #合计人工费
       l_xcah031_b_szb      LIKE   type_t.num20_6,    #人工费用占比
       l_xcah031_a_szb      LIKE   type_t.num20_6,    #材料费用占比
       l_xcah022            LIKE   xcah_t.xcah022,    #元件料号
       l_xcah022_desc       LIKE   type_t.chr200,     #元件品名
       l_xcah022_1_desc     LIKE   type_t.chr200,     #元件规格
       l_xcaeud015          LIKE   xcae_t.xcaeud015,  #各阶段标准工时
       l_xcaeud016          LIKE   xcae_t.xcaeud016,  #各阶段标准机时
       l_xcah031_b          LIKE   type_t.num20_6,    #各阶段人力费
       l_xcah031_a          LIKE   type_t.num20_6,    #各阶段材料费
       l_xcah026            LIKE   xcah_t.xcah026,    #工时占比(各阶段/总)
       l_xcah025            LIKE   xcah_t.xcah025     #材料占比(各阶段/总)
    END RECORD
    
   
    #======================================页签==============================================================
    CALL cxcr600_ins_tmp(p_imaa001_a)
    
    LET l_sql = " SELECT t_xcah004,t_xcah004_desc,t_xcah004_1_desc,t_xcaeud015_sum,t_xcah031_a_sum,
                  t_price_ws,t_xcah031_b_sum,t_xcah031_b_szb,t_xcah031_a_szb,t_xcah022,t_xcah022_desc,
                  t_xcah022_1_desc,t_xcaeud015,t_xcaeud016,t_xcah031_b,t_xcah031_a,t_xcah026,t_xcah025 
                  FROM cxcr600_tmp ORDER BY t_xcah020 ASC "
     
    PREPARE l_get_code FROM l_sql
    DECLARE l_get_curs CURSOR FOR l_get_code 
   
    CALL l_docno.clear()     #在进入循环之前把二维数组清空
    LET l_dex = 1            #初始化   
    LET l_money_sh = 0       #初始化损耗
    FOREACH l_get_curs INTO l_docno[l_dex].*
      
      #1、标准工时 取阶段料号对应的工时和
      SELECT SUM(xcaeud015) INTO l_docno[l_dex].l_xcaeud015 FROM xcae_t 
      WHERE xcaeent = g_enterprise AND xcaesite = g_site 
      AND xcaestus = 'Y' AND xcae002 = l_docno[l_dex].l_xcah004
      AND xcaeud001 = l_docno[l_dex].l_xcah022
      
      IF cl_null(l_docno[l_dex].l_xcaeud015) THEN 
            LET l_docno[l_dex].l_xcaeud015 = 0
      END IF
      
      #2、标准机时 取阶段料号对应的机时和
      SELECT SUM(xcaeud016) INTO l_docno[l_dex].l_xcaeud016 FROM xcae_t 
      WHERE xcaeent = g_enterprise AND xcaesite = g_site 
      AND xcaestus = 'Y' AND xcae002 = l_docno[l_dex].l_xcah004
      AND xcaeud001 = l_docno[l_dex].l_xcah022
      
      IF cl_null(l_docno[l_dex].l_xcaeud016) THEN 
            LET l_docno[l_dex].l_xcaeud016 = 0
      END IF
      
      #3、人力成本 取阶段料号对应的成本直接人工+间接一、二
      SELECT (xcah031b+xcah031d+xcah031e) INTO l_docno[l_dex].l_xcah031_b FROM xcah_t
      WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
      AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah022 = l_docno[l_dex].l_xcah022
      
      #4、材料成本 如果是夹治具,直接去成本材料费;不是的话,取它对应的下阶材料费加上它自身的损耗
      #取数判断是否夹治具
      SELECT imaaud011 INTO l_num FROM imaa_t
      WHERE imaaent = g_enterprise AND imaastus = 'Y'
      AND imaa001 = l_docno[l_dex].l_xcah022
      
      SELECT xcah025 INTO l_num1 FROM xcah_t
      WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
      AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah022 = l_docno[l_dex].l_xcah022
      
      SELECT xcah026 INTO l_num2 FROM xcah_t
      WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
      AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah022 = l_docno[l_dex].l_xcah022
      
      #损耗=单位材料*组成用量/主件底数/(1-损耗)-单位材料*组成用量/主件底数 更新到主件中去
      SELECT (xcah030a*xcah026/xcah025/(1-xcah027/100)-xcah030a*xcah026/xcah025) INTO l_money_sh FROM xcah_t
      WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
      AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah040 = l_docno[l_dex].l_xcah022
      AND xcah023 = 'A' AND xcah022 IN (
                                           SELECT imaa001 FROM imaa_t
                                           WHERE imaaent = g_enterprise AND imaastus = 'Y'
                                           AND (imaaud011 = 0 OR imaaud011 IS NULL)
                                           )
      IF cl_null(l_money_sh) THEN
         LET l_money_sh = 0
      END IF
      #判断是否夹治具料号,如果是直接取夹治具材料成本,否则的话取下阶材料和
      IF l_num <> 0 THEN
         SELECT xcah031a INTO l_docno[l_dex].l_xcah031_a FROM xcah_t
         WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
         AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah022 = l_docno[l_dex].l_xcah022
      ELSE
         SELECT SUM(xcah031a/l_num1*l_num2) INTO l_docno[l_dex].l_xcah031_a FROM xcah_t
         WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
         AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah023 = 'M' AND xcah040 = l_docno[l_dex].l_xcah022
         AND xcah020 IN (
                        SELECT xcah020+1 FROM xcah_t
                        WHERE xcahent = g_enterprise AND xcahsite = g_site AND xcah001 = '101'
                        AND xcah004 = l_docno[l_dex].l_xcah004 AND xcah022 = l_docno[l_dex].l_xcah022
                        )
         #如果下阶无材料,费用为空,另它等于零
         IF cl_null(l_docno[l_dex].l_xcah031_a) THEN 
            LET l_docno[l_dex].l_xcah031_a = 0
         END IF
         #费用加上它的损耗
         LET l_docno[l_dex].l_xcah031_a = l_docno[l_dex].l_xcah031_a+l_money_sh
         LET l_money_sh = 0
      END IF
      
      IF cl_null(l_docno[l_dex].l_xcah031_a) THEN 
         LET l_docno[l_dex].l_xcah031_a = 0
      END IF
      
      #5、合计人工 取axci006里面主件直接+间接
      SELECT (xcag102b+xcag102d+xcag102e) INTO l_docno[l_dex].l_xcah031_b_sum FROM xcag_t
      WHERE xcagent = g_enterprise AND xcagsite = g_site 
      AND xcag001 = '101' AND xcag004 = l_docno[l_dex].l_xcah004
      
      
      #6、合计材料 直接取axci006主件材料费
      SELECT xcag102a INTO l_docno[l_dex].l_xcah031_a_sum FROM xcag_t
      WHERE xcagent = g_enterprise AND xcagsite = g_site 
      AND xcag001 = '101' AND xcag004 = l_docno[l_dex].l_xcah004
      
      #7、合计工时 取axci005里面所有工时和
      SELECT SUM(xcaeud015) INTO l_docno[l_dex].l_xcaeud015_sum FROM xcae_t
      WHERE xcaeent = g_enterprise AND xcaesite = g_site 
      AND xcaestus = 'Y' AND xcae002 = l_docno[l_dex].l_xcah004
      
      #8、未税单价
      LET l_docno[l_dex].l_price_ws = cxcr600_get_price(l_docno[l_dex].l_xcah004)
      
      #9、主件人工占比
      LET l_docno[l_dex].l_xcah031_b_szb = l_docno[l_dex].l_xcah031_b_sum/l_docno[l_dex].l_price_ws
      
      
      #10、主件材料占比
      LET l_docno[l_dex].l_xcah031_a_szb = l_docno[l_dex].l_xcah031_a_sum/l_docno[l_dex].l_price_ws
      
      #11、工时占比
      LET l_docno[l_dex].l_xcah026= l_docno[l_dex].l_xcaeud015/l_docno[l_dex].l_xcaeud015_sum
      
      #12、材料占比
      LET l_docno[l_dex].l_xcah025 = l_docno[l_dex].l_xcah031_a/l_docno[l_dex].l_xcah031_a_sum

      LET l_dex = l_dex + 1
    END FOREACH

    CALL l_docno.deleteElement(l_docno.getLength())
    
    
    RETURN l_docno
    
    
    
END FUNCTION

PRIVATE FUNCTION cxcr600_export_excel()
 DEFINE style2                    XSSFCellStyle
 DEFINE style3                    XSSFCellStyle
 DEFINE style3_5                  XSSFCellStyle
 DEFINE style4                    XSSFCellStyle
 DEFINE style4_1                  XSSFCellStyle
 DEFINE style4_3                  XSSFCellStyle
 DEFINE style4_3_1                XSSFCellStyle
 DEFINE style5                    XSSFCellStyle
 DEFINE style6                    XSSFCellStyle
 DEFINE style7                    XSSFCellStyle
 DEFINE style8                    XSSFCellStyle
 DEFINE style9                    XSSFCellStyle
 DEFINE workbook                  XSSFWorkbook
 DEFINE l_str                     STRING
 DEFINE l_cnt                     LIKE type_t.num10
 DEFINE l_i                       LIKE type_t.num5
 DEFINE l_n                       LIKE type_t.num5
 DEFINE l_n2                      LIKE type_t.num5
 DEFINE l_fileloc                 STRING
 DEFINE l_length                  LIKE type_t.num10
 DEFINE region                    CellRangeAddress
 DEFINE l_m                       LIKE type_t.num5
 DEFINE l_flag                    LIKE type_t.chr100
 DEFINE l_n1                      LIKE type_t.num5
 DEFINE l_num                     FLOAT
 DEFINE li_font_size              LIKE type_t.num5
 DEFINE l_time                    LIKE pmaa_t.pmaacrtdt
 DEFINE l_string                  LIKE type_t.chr200
 DEFINE l_dex                     LIKE type_t.num5
 DEFINE l_m_n                     LIKE type_t.num5
 DEFINE l_number                  FLOAT
 DEFINE l_sql                     STRING
 DEFINE l_row                     LIKE type_t.num10
 DEFINE l_row1                    LIKE type_t.num10
 DEFINE l_sum_days                LIKE type_t.num5
 DEFINE l_imaa001                 LIKE imaa_t.imaa001             
 DEFINE r_docno         DYNAMIC ARRAY OF RECORD  
       l_xcah004            LIKE   xcah_t.xcah040,    #主件料号
       l_xcah004_desc       LIKE   type_t.chr200,     #主件品名
       l_xcah004_1_desc     LIKE   type_t.chr200,     #主件规格
       l_xcaeud015_sum      LIKE   xcae_t.xcaeud015,  #合计工时
       l_xcah031_a_sum      LIKE   type_t.num20_6,    #合计材料费
       l_price_ws           LIKE   type_t.num20_6,    #未税单价
       l_xcah031_b_sum      LIKE   type_t.num20_6,    #合计人工费
       l_xcah031_b_szb      LIKE   type_t.num20_6,    #人工费用占比
       l_xcah031_a_szb      LIKE   type_t.num20_6,    #材料费用占比
       l_xcah022            LIKE   xcah_t.xcah022,    #元件料号
       l_xcah022_desc       LIKE   type_t.chr200,     #元件品名
       l_xcah022_1_desc     LIKE   type_t.chr200,     #元件规格
       l_xcaeud015          LIKE   xcae_t.xcaeud015,  #各阶段标准工时
       l_xcaeud016          LIKE   xcae_t.xcaeud016,  #各阶段标准机时
       l_xcah031_b          LIKE   type_t.num20_6,    #各阶段人力费
       l_xcah031_a          LIKE   type_t.num20_6,    #各阶段材料费
       l_xcah026            LIKE   xcah_t.xcah026,    #工时占比(各阶段/总)
       l_xcah025            LIKE   xcah_t.xcah025     #材料占比(各阶段/总)
 END RECORD
 DEFINE l_date       LIKE type_t.dat
 DEFINE l_day        LIKE type_t.num5
 DEFINE l_field      LIKE type_t.chr200
 DEFINE l_i_dex      LIKE type_t.num10

 CALL ui.Interface.frontCall("standard","opendir",["C:", "File Browser"],[g_showmsg])
 
 LET workbook = XSSFWorkbook.create()   #创建工作簿
 
 #设定EXCEL单元格式1
 LET style2 = workbook.createCellStyle()
 CALL style2.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style2.setAlignment(XSSFCellStyle.ALIGN_CENTER)    
 CALL style2.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style2.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style2.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style2.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style2.setWrapText(true)
 
 #设定EXCEL单元格式2 包涵背景颜色 
 LET style3 = workbook.createCellStyle()
 #CALL style3.setFillForegroundColor(IndexedColors.LIME.getIndex())
 CALL style3.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style3.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 CALL style3.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style3.setAlignment(XSSFCellStyle.ALIGN_CENTER)   
 CALL style3.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style3.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style3.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style3.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style3.setWrapText(true)
 
# LET style7 = workbook.createCellStyle()
# #CALL style7.setFillForegroundColor(IndexedColors.LIME.getIndex())
# CALL style7.setFillForegroundColor(IndexedColors.LEMON_CHIFFON.getIndex())
# CALL style7.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
# CALL style7.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
# CALL style7.setAlignment(XSSFCellStyle.ALIGN_CENTER)   
# CALL style7.setBorderBottom(XSSFCellStyle.BORDER_THIN)
# CALL style7.setBorderLeft(XSSFCellStyle.BORDER_THIN)
# CALL style7.setBorderTop(XSSFCellStyle.BORDER_THIN)
# CALL style7.setBorderRight(XSSFCellStyle.BORDER_THIN)
# CALL style7.setWrapText(true)
 
 
 
 #小计栏位
 LET style3_5 = workbook.createCellStyle()
 CALL style3_5.setFillForegroundColor(IndexedColors.YELLOW.getIndex())
 CALL style3_5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 CALL style3_5.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style3_5.setAlignment(XSSFCellStyle.ALIGN_CENTER)   
 CALL style3_5.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style3_5.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style3_5.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style3_5.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style3_5.setWrapText(true)
    
 #设定EXCEL单元格式2 包涵背景颜色,保留小数位
 LET  style4 = workbook.createCellStyle()
 #CALL style4.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex())
 CALL style4.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 LET format1 = workbook.createDataFormat()
 CALL style4.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style4.setDataFormat(format1.getFormat("0.000000"))
 CALL style4.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style4.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style4.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style4.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style4.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style4.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style4.setWrapText(true)
 
 LET  style4_1 = workbook.createCellStyle()
 #CALL style4.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex())
 CALL style4_1.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 LET format1 = workbook.createDataFormat()
 CALL style4_1.setFillForegroundColor(IndexedColors.RED.getIndex())
 CALL style4_1.setDataFormat(format1.getFormat("0.000000"))
 CALL style4_1.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style4_1.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style4_1.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style4_1.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style4_1.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style4_1.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style4_1.setWrapText(true)
 
 LET li_font_size = 11
 LET  style4_3 = workbook.createCellStyle()
 LET font2 = workbook.createFont()
 CALL font2.setFontName("Microsoft YaHei")       
 CALL font2.setFontHeightInPoints(li_font_size)     
 CALL font2.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD)
 CALL style4_3.setFont(font2)
 CALL style4_3.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style4_3.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 LET format1 = workbook.createDataFormat()
 CALL style4_3.setDataFormat(format1.getFormat("0.00%"))
 CALL style4_3.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style4_3.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style4_3.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style4_3.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style4_3.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style4_3.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style4_3.setWrapText(true)
 
 LET li_font_size = 11
 LET  style4_3_1 = workbook.createCellStyle()
 LET font2 = workbook.createFont()
 CALL font2.setFontName("Microsoft YaHei")       
 CALL font2.setFontHeightInPoints(li_font_size)     
 CALL font2.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD)
 CALL style4_3_1.setFont(font2)
 CALL style4_3_1.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex())
 CALL style4_3_1.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 LET format1 = workbook.createDataFormat()
 CALL style4_3_1.setDataFormat(format1.getFormat("0.00%"))
 CALL style4_3_1.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style4_3_1.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style4_3_1.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style4_3_1.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style4_3_1.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style4_3_1.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style4_3_1.setWrapText(true)
 
 #设定小计的黄色小数点
 LET  style6 = workbook.createCellStyle()
 CALL style6.setFillForegroundColor(IndexedColors.YELLOW.getIndex())
 CALL style6.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 LET format1 = workbook.createDataFormat()
 CALL style6.setDataFormat(format1.getFormat("0.00"))
 CALL style6.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style6.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style6.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style6.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style6.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style6.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style6.setWrapText(true)
 
 #第一行标题
 LET li_font_size = 28 
 #字体设定
 LET  font1 = workbook.createFont() #创建字体
 #CALL font1.setFontName("Microsoft JhengHei")#字体类型,比如宋体、雅黑等等
 CALL font1.setFontName("Microsoft YaHei")
 CALL font1.setFontHeightInPoints(li_font_size)#字体大小     
 CALL font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD)#字体加粗
 #字体加粗,加大,标题栏目
 LET  style5 = workbook.createCellStyle()
 #CALL style5.setFillForegroundColor(IndexedColors.LIME.getIndex())
 CALL style5.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 CALL style5.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)
 CALL style5.setAlignment(XSSFCellStyle.ALIGN_CENTER)   
 CALL style5.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style5.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style5.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style5.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style5.setFont(font1) #设置上述创建字体
 CALL style5.setWrapText(true)
 
 #第三行标题
 LET li_font_size = 11
 LET style7 = workbook.createCellStyle()
 LET font3 = workbook.createFont()
 CALL font3.setFontName("Microsoft YaHei")       
 CALL font3.setFontHeightInPoints(li_font_size)     
 CALL font3.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD)
 CALL style7.setFont(font3)
 CALL style7.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex())
 CALL style7.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 CALL style7.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style7.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style7.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style7.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style7.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)   
 CALL style7.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 CALL style7.setWrapText(true)
 
 #第二行标题
 LET li_font_size = 18
 LET style8 = workbook.createCellStyle()
 LET font4 = workbook.createFont()
 CALL font4.setFontName("Microsoft YaHei")       
 CALL font4.setFontHeightInPoints(li_font_size)     
 CALL font4.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD)
 CALL style8.setFont(font4)
 CALL style8.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style8.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
 CALL style8.setBorderBottom(XSSFCellStyle.BORDER_THIN)
 CALL style8.setBorderLeft(XSSFCellStyle.BORDER_THIN)
 CALL style8.setBorderTop(XSSFCellStyle.BORDER_THIN)
 CALL style8.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style8.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)   
 CALL style8.setAlignment(XSSFCellStyle.ALIGN_CENTER)
 
 #最后一行的文件编码
 LET style9 = workbook.createCellStyle()
 CALL style9.setFont(font2)
 CALL style9.setFillForegroundColor(IndexedColors.WHITE.getIndex())
 CALL style9.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND)
# CALL style9.setBorderBottom(XSSFCellStyle.BORDER_THIN)
# CALL style9.setBorderLeft(XSSFCellStyle.BORDER_THIN)
# CALL style9.setBorderTop(XSSFCellStyle.BORDER_THIN)
# CALL style9.setBorderRight(XSSFCellStyle.BORDER_THIN)
 CALL style9.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER)   
 CALL style9.setAlignment(XSSFCellStyle.ALIGN_CENTER)


 LET l_str = "成本明细"
 LET sheet = workbook.createSheet(l_str)
#=======================================页面开始第一行=====================================================    
    LET row = sheet.createRow(0)    #创建行
    CALL row.setHeightInPoints(40)  #设置行高
    
    FOR l_i = 0 TO 8
      LET cell = row.createCell(l_i)    
      CALL cell.setCellStyle(style5)
      LET l_str = "在制项目标准成本明细"
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
    END FOR
    #合并单元格
    LET region = CellRangeAddress.create(0,0,0,8) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
    CALL sheet.addMergedRegion(region)                  #执行上述单元格条件合并
    LET region = CellRangeAddress.create(0,0,9,17) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
    CALL sheet.addMergedRegion(region)                  #执行上述单元格条件合并
    
    #第二行
    LET row = sheet.createRow(1)    #创建行
    CALL row.setHeightInPoints(30)  #设置行高
    FOR l_i = 0 TO 8
      LET cell = row.createCell(l_i)    
      CALL cell.setCellStyle(style8)
      LET l_str = "成品"
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
    END FOR
    FOR l_i = 9 TO 17
      LET cell = row.createCell(l_i)    
      CALL cell.setCellStyle(style8)
      LET l_str = "各工段"
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
    END FOR
    #合并单元格
    LET region = CellRangeAddress.create(1,1,0,8) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
    CALL sheet.addMergedRegion(region)                  #执行上述单元格条件合并
    LET region = CellRangeAddress.create(1,1,9,17) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
    CALL sheet.addMergedRegion(region)                  #执行上述单元格条件合并
    #第三行
    LET row = sheet.createRow(2)    #创建行
    CALL row.setHeightInPoints(20)  #设置行高
    FOR l_i = 0 TO 17
      CASE l_i 
        WHEN 0  LET l_str = '主件料号'
        WHEN 1  LET l_str = '主件品名'
        WHEN 2  LET l_str = '主件规格'
        WHEN 3  LET l_str = '合计工时(秒)'
        WHEN 4  LET l_str = '合计材料费'
        WHEN 5  LET l_str = '未税单价'
        WHEN 6  LET l_str = '合计人工费'
        WHEN 7  LET l_str = '人力占比'
        WHEN 8  LET l_str = '材料占比'
        WHEN 9  LET l_str = '料号'
        WHEN 10 LET l_str = '品名'
        WHEN 11 LET l_str = '规格'
        WHEN 12 LET l_str = '标准工时(秒)'
        WHEN 13 LET l_str = '标准机时(秒)'
        WHEN 14 LET l_str = '人力成本'
        WHEN 15 LET l_str = '材料成本'
        WHEN 16 LET l_str = '工时占比'
        WHEN 17 LET l_str = '材料占比'
      END CASE 
      LET cell = row.createCell(l_i)    
      CALL cell.setCellStyle(style7)
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
    END FOR
    
 LET l_sql = "SELECT DISTINCT xcag004 FROM xcag_t
              WHERE xcagent = ",g_enterprise," AND xcagsite = '",g_site,"' 
              AND xcag001 = '101' AND ",g_master.wc
 PREPARE l_imaa001_code FROM l_sql
 DECLARE l_imaa001_curs CURSOR FOR l_imaa001_code 
     
 LET l_imaa001 = ''
 LET l_row1 = 2
 #开始循环
 FOREACH l_imaa001_curs INTO l_imaa001
    #传递参数取数据
    CALL cxcr600_get_data(l_imaa001) RETURNING r_docno
    #第三行下面的数据
    LET l_cnt = r_docno.getLength()  #获取数组总笔数
    
    FOR l_i = 1 TO l_cnt
       #创建行
       LET l_row = l_i + l_row1
       LET row = sheet.createRow(l_row)    #创建行
       CALL row.setHeightInPoints(20)      #设置行高
       
       #主件料号
       LET cell = row.createCell(0)    
       CALL cell.setCellStyle(style3)
       LET l_str = r_docno[l_i].l_xcah004
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(0,l_length)
       
       #主件品名
       LET cell = row.createCell(1)    
       CALL cell.setCellStyle(style3)   
       LET l_str = r_docno[l_i].l_xcah004_desc
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(1,l_length)
       
       #主件规格
       LET cell = row.createCell(2)    
       CALL cell.setCellStyle(style3)   
       LET l_str = r_docno[l_i].l_xcah004_1_desc
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(2,l_length)
       
       #合计工时
       LET cell = row.createCell(3)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcaeud015_sum
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(3,l_length)
       
       #合计材料费
       LET cell = row.createCell(4)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcah031_a_sum
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(4,l_length)
       
       #未税单价
       LET cell = row.createCell(5)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_price_ws
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(5,l_length)
       
       #合计人工费
       LET cell = row.createCell(6)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcah031_b_sum
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(6,l_length)
       
       #人力占比
       LET cell = row.createCell(7)    
       CALL cell.setCellStyle(style4_3)   
       LET l_num = r_docno[l_i].l_xcah031_b_szb
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(7,l_length)
       
       #材料占比
       LET cell = row.createCell(8)    
       CALL cell.setCellStyle(style4_3)   
       LET l_num = r_docno[l_i].l_xcah031_a_szb
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(8,l_length)
       
       #料号
       LET cell = row.createCell(9)    
       CALL cell.setCellStyle(style3)   
       LET l_str = r_docno[l_i].l_xcah022
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(9,l_length)
       
       #品名
       LET cell = row.createCell(10)    
       CALL cell.setCellStyle(style3)   
       LET l_str = r_docno[l_i].l_xcah022_desc
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(10,l_length)
       
       #规格
       LET cell = row.createCell(11)    
       CALL cell.setCellStyle(style3)   
       LET l_str = r_docno[l_i].l_xcah022_1_desc
       CALL cell.setCellValue(l_str)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(11,l_length)
              
       #标准工时
       LET cell = row.createCell(12)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcaeud015
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(12,l_length)
       
       #标准机时
       LET cell = row.createCell(13)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcaeud016
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(13,l_length)
       
       #人力成本
       LET cell = row.createCell(14)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcah031_b
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(14,l_length)
       
       #材料成本
       LET cell = row.createCell(15)    
       CALL cell.setCellStyle(style4)   
       LET l_num = r_docno[l_i].l_xcah031_a
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(15,l_length)
       
       #工时占比
       LET cell = row.createCell(16)    
       CALL cell.setCellStyle(style4_3)   
       LET l_num = r_docno[l_i].l_xcah026
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(16,l_length)
             
       #材料占比
       LET cell = row.createCell(17)    
       CALL cell.setCellStyle(style4_3)   
       LET l_num = r_docno[l_i].l_xcah025
       CALL cell.setCellValue(l_num)
       LET l_length = (11.33+0.72)*300
       CALL sheet.setColumnWidth(17,l_length)
       
    END FOR
    
    #合并行

    #起始行
    LET l_n2 = l_row1+1
    #客户分组合并
    FOR l_i = 0 TO 8
    FOR l_n = 1 TO l_cnt
      #当前行比较上一行的客户数据对比
      IF l_n > 1  THEN
         LET l_n1 = l_n - 1 #上一笔
         IF r_docno[l_n].l_xcah004 <> r_docno[l_n-1].l_xcah004 THEN
           LET l_m_n = l_n1 + l_row1   
           #第l_i列
           LET region = CellRangeAddress.create(l_n2,l_m_n,l_i,l_i) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
           CALL sheet.addMergedRegion(region)                 #执行上述单元格条件合并
         END IF
       
      END IF
      
      IF l_n = l_cnt AND l_n > 1 THEN   #到最后一行了
         IF r_docno[l_n].l_xcah004 = r_docno[l_n-1].l_xcah004 THEN
            LET l_m_n = l_n + l_row1
            LET region = CellRangeAddress.create(l_n2,l_m_n,l_i,l_i) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
            CALL sheet.addMergedRegion(region)                 #执行上述单元格条件合并
         END IF
             
      END IF
    END FOR
    END FOR 
    LET l_row1 = l_row1+l_cnt
    
    LET l_imaa001 = '' 
    
 END FOREACH 
 LET l_row = l_row1+1
 LET row = sheet.createRow(l_row)    #创建行
    CALL row.setHeightInPoints(20)  #设置行高
    
#    FOR l_i = 0 TO 2
      LET cell = row.createCell(1)    
      CALL cell.setCellStyle(style9)
      LET l_str = "表单编号:7-6-2-T_002(ZJA) V01"
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
#    END FOR
#    FOR l_i = 15 TO 17
      LET cell = row.createCell(16)    
      CALL cell.setCellStyle(style9)
      LET l_str = "惠州至精精密技术有限公司"
      CALL cell.setCellValue(l_str)
      LET l_length = (11.33+0.72)*300
      CALL sheet.setColumnWidth(l_i,l_length)
#    END FOR
#    #合并单元格
#    LET region = CellRangeAddress.create(l_row,l_row,0,2) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
#    CALL sheet.addMergedRegion(region)                  #执行上述单元格条件合并
#    LET region = CellRangeAddress.create(l_row,l_row,15,17) #单元格合并(起始行号,终止行号, 起始列号,终止列号)0-4共有五个单元格,对应实际表格即为将第一行的第一列到第五列合并
#    CALL sheet.addMergedRegion(region)
 
 CALL sheet.createFreezePane( 9, 3, 0, 0 )   #冻结窗口
 CALL cxcr600_drop_tmp()
 
 LET l_time = cl_get_current()
 LET l_string = ''
 SELECT to_char(l_time,'yyyymmddhh24miss') INTO l_string FROM DUAL
  
 LET l_xlsname = l_string,"cxcr600.xlsx"
 LET l_xlsfile = FGL_GETENV("TEMPDIR")||'/',l_xlsname
 LET fo = FileOutputStream.create(l_xlsfile)
 CALL workbook.write(fo)
 CALL fo.close()
 
 
 LET l_target = os.Path.join(FGL_GETENV("TEMPDIR"),l_xlsname)
 LET l_fileloc = os.Path.join(g_showmsg,l_xlsname CLIPPED)
 CALL FGL_PUTFILE(l_target ,l_fileloc)
 
 LET l_str = cl_getmsg('adz-00701',g_lang)
 LET l_str = cl_str_replace(l_str,'%1',l_xlsname)
 CALL cl_ask_confirm3("",l_str)
 
END FUNCTION

PRIVATE FUNCTION cxcr600_get_price(p_imaa001)
  DEFINE  p_imaa001    LIKE  imaa_t.imaa001
  DEFINE  p_time       LIKE  type_t.chr100
  DEFINE  r_price      LIKE  type_t.num20_6
  DEFINE  r_price_ws   LIKE  type_t.num20_6
  DEFINE  r_rate       LIKE  type_t.num20_6
  DEFINE  l_date       LIKE  type_t.dat
  DEFINE  l_bz         LIKE  type_t.chr100    #币种
  DEFINE  l_exrate     LIKE  type_t.num20_6   #汇率
  DEFINE  l_xmdt008    LIKE  xmdt_t.xmdt008   #含税否
  
  
  LET l_date = g_today
  LET r_price = 0
  LET r_rate  = 0 
  LET l_exrate = 0
  LET l_xmdt008 = ''
  
  #判断核价单是否存在单价
  SELECT NVL(xmdu011,0),NVL(xmdu012,0),xmdt005,xmdt008 INTO r_price,r_rate,l_bz,l_xmdt008 FROM (
  SELECT xmdt015,xmdu011,xmdu012,xmdt005,xmdt008 FROM xmdu_t 
  LEFT JOIN xmdt_t ON xmdtent = xmduent AND xmdtsite = xmdusite AND xmdtdocno = xmdudocno
  WHERE xmdtent = g_enterprise AND xmdtsite = g_site AND xmdtstus = 'Y' AND xmdu002 = p_imaa001 AND xmdu011 <> 0
  AND xmdt015 <= l_date ORDER BY XMDT015 DESC ) WHERE rownum = 1
  #存在对应的币种
  IF NOT cl_null(l_bz) THEN
    LET g_prog = 'axmt540'
    CALL s_axmt540_get_exchange('2',l_bz,l_date) RETURNING l_exrate
    LET g_prog = 'cxcr600'
  END IF
  #获取到单价
  IF NOT cl_null(r_price) AND r_price <> 0 AND NOT cl_null(l_bz) THEN
     IF l_xmdt008 = 'Y' THEN   #含税单价
       LET r_price = r_price*l_exrate
       LET r_price_ws = r_price/(1+(r_rate/100))
       RETURN r_price_ws
     END IF 
     IF l_xmdt008 = 'N' THEN   #不含税单价
       LET r_price_ws = r_price*l_exrate
       LET r_price = r_price*l_exrate*(1+(r_rate/100))
       RETURN r_price_ws
     END IF
  END IF
  
  #当核价单没有单价的时候,从订单去寻找
  SELECT NVL(xmdc015,0)*xmda016,NVL(xmdc017,0) INTO r_price,r_rate FROM (
  SELECT xmdc001,xmdc015,xmdc017,xmdadocdt,xmda016 FROM xmdc_t 
  LEFT JOIN xmda_t ON xmdcent = xmdaent AND xmdcsite = xmdasite AND xmdadocno = xmdcdocno
  WHERE xmdaent = g_enterprise AND xmdasite = g_site AND xmdastus NOT IN  ('N','X') AND xmdc001 = p_imaa001 AND xmdc015 <> 0
  AND xmdadocdt <= l_date ORDER BY xmdadocdt DESC) WHERE rownum = 1
  
  #获取到单价
  IF NOT cl_null(r_price) AND r_price <> 0 THEN
     LET r_price_ws = r_price/(1+(r_rate/100))
     RETURN r_price_ws
  END IF
  
  LET r_price = 0
  LET r_price_ws  = 0

  RETURN r_price_ws
END FUNCTION

PRIVATE FUNCTION cxcr600_drop_tmp()
  DROP TABLE cxcr600_tmp;
END FUNCTION

 

标签:ERP,LIKE,表格,XSSFCellStyle,CALL,LET,docno,DEFINE,自定义
From: https://www.cnblogs.com/sanmulx/p/17531674.html

相关文章

  • Python 使用xlsxwriter绘制Excel表格
    最近在统计资产,正好看到了xlsxwriter这个表格生成模块,借此机会,熟悉一下,写点有趣的小案例,一开始想使用C++QT图形化开发一套自动化运维平台,但后来发现不仅消耗时间而且需要解决QTQssh远程模块的一些问题,后来没有使用QT做,xlsxwriter模块来做非常的简单,所以使用它。上班不能摸鱼,我要......
  • 前端Vue自定义顶部导航栏navBar 导航栏搜索框searchBar 导航栏右侧菜单按钮button
    前端Vue自定义顶部导航栏navBar导航栏搜索框searchBar导航栏右侧菜单按钮button,下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=13342效果图如下:cc-headerSearch使用方法<!--icon:右侧菜单图标@searchClick:搜索点击 @rigIconClick:右......
  • 前端Vue自定义带历史记录的搜索框组件searchBar 支持搜索输入框清空 搜索历史存储记录
    前端Vue自定义带历史记录的搜索框组件searchBar支持搜索输入框清空搜索历史存储记录清除,下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=13343效果图如下:cc-hisSearchBar使用方法//不同的业务功能历史记录设置不同存储keyconstkStora......
  • elment ui展开行嵌套表格 进行修改数据后展开行自动收起
    https://it.cha138.com/python/show-74200.html tags:篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ElmentPlus表格展开行后,进行修改数据后展开行自动收起相关的知识,希望对你有一定的参考价值。ElmentPlus表格展开行后,进行修改数据后展开行自动收起场景:在......
  • 自定义异常类-MyException
    packageutils;publicclassMyExceptionextendsException{ publicMyException(){ super(); } publicMyException(Strings){ super(s); }} ......
  • springboot 加载自定义的属性配置文件 或者xml文件
    1、properties user.propertiesname=zhangshanage=18  2、xml Pen1.xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEpropertiesSYSTEM"http://java.sun.com/dtd/properties.dtd"><properties><......
  • Postgresql 大象数据库long自定义自增
     Postgresql --创建序列CREATESEQUENCEuser_long_id_seqSTART100000;CREATESEQUENCEdepartments_long_id_seqSTART100000;CREATESEQUENCEpositions_long_id_seqSTART100000;CREATESEQUENCEposition_grades_long_id_seqSTART100000;--设置对应列Key值A......
  • 2023-04-27-LinerProgramming
    开始吟唱问题引入定义线性规划是在一组线性约束条件下,求一线性目标函数最大或最小的问题。标准形式要求目标函数要求\(\max\)约束条件均为等式决策变量为非负约束形式\[\begin{matrix}\maxz=\sum_{j=1}^{n}c_jx_j\\s.t\begin{cases}\sum_{j......
  • Element 自定义指令 下拉分页,获取无限数据
    template代码<el-form-item><el-selectv-model="form.batchId"v-loadmore="loadmoreBatchList"placeholder="请输入批次名称"filterableclearable><el-optionv-for="(item,......
  • 通过 openpyxl 操作 excel 表格
    博客地址:https://www.cnblogs.com/zylyehuo/STEP1:导入相关库importosfromopenpyxlimportload_workbookSTEP2:构建存放路径,将上传文件下载到服务器该路径下excel_stus=request.FILES.get("excel_stus")#获取文件path=os.path.join("media","files",excel_s......