SAP ABAP 报表程序实现下载文件及上传 Excel 并解析

步骤1:

事务代码 SMW0

选择二进制数据选项点击上方按钮。

在这里插入图片描述

点击新建按钮输入名称和描述,上传模版文件。

在这里插入图片描述

案例传入 EXCEL 如下:
在这里插入图片描述

创建好资源库对象结果如下。

在这里插入图片描述

步骤2:报表效果展示

点击按钮选择上传的文件。
在这里插入图片描述
解析 Excel 文件结果到 alv 内表展示。

在这里插入图片描述
选择需要更新的数据,点击保存,修改成功后结果回写到alv表。
在这里插入图片描述

步骤3:源码

报表源码如下:

*&---------------------------------------------------------------------*
*& Report Z_EXCEL_TEST
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_EXCEL_TEST.
INCLUDE zbcn_excel.
*----------------------------------------------------------------------*
* Type-pools/定义类型池
*----------------------------------------------------------------------*
TYPE-POOLS: slis.
*----------------------------------------------------------------------*
* Initialization/初始事件
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Variable/定义变量
*----------------------------------------------------------------------*
DATA:gv_filter  TYPE string,gs_functxt TYPE smp_dyntxt.
*----------------------------------------------------------------------*
* 声明ALV对象
*----------------------------------------------------------------------*
DATA:gs_layout_lvc TYPE lvc_s_layo,gt_fcat_lvc   TYPE lvc_t_fcat,gs_fcat_lvc   TYPE lvc_s_fcat.
types:
BEGIN OF ts_data,sel type char1,  "是否被选择index    TYPE sy-index,msgtyp   TYPE icon_d,message  TYPE bapi_msg.INCLUDE type zmmtest.TYPES:zdate TYPE DATS,END OF ts_data.
TYPES:tt_data TYPE STANDARD TABLE OF ts_data WITH DEFAULT KEY INITIAL SIZE 0.
DATA: gt_data TYPE tt_data,gs_data TYPE ts_data.*----------------------------------------------------------------------*
* Selection  screen/定义屏幕
*----------------------------------------------------------------------*
SELECTION-SCREEN FUNCTION KEY: 1 .
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE TEXT-t01.
PARAMETERS:p_path LIKE rlgrap-filename MODIF ID m1.
SELECTION-SCREEN END OF BLOCK block1.
INITIALIZATION.gs_functxt-icon_id = icon_export.gs_functxt-quickinfo  = '模板下载'.gs_functxt-icon_text  = '模板下载'.sscrfields-functxt_01 = gs_functxt.*----------------------------------------------------------------------*
* At selection-screen/屏幕事件
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.IF sscrfields-ucomm = 'FC01' .CLEAR: gv_filter.gv_filter = '|EXCEL-Files (*.XLS)|*.XLS|All Files(*.*)|*.*|'.PERFORM frm_download_tmp USING gv_filter 'ZTEST'.ENDIF.*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN ON VALUE-REQUEST.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.gv_filter = 'EXCEL-Files (*.XLS)|*.XLS|EXCEL-Files (*.XLSX)|*.XLSX|All Files(*.*)|*.*|'.PERFORM frm_select_file USING gv_filter p_path.*----------------------------------------------------------------------*
* Start-of-selection/开始选择事件
*----------------------------------------------------------------------*
START-OF-SELECTION.*取数据PERFORM frm_get_data.*----------------------------------------------------------------------*
* End-of-selection/结束选择事件
*----------------------------------------------------------------------*
END-OF-SELECTION.* 确定ALV输出列的属性PERFORM frm_fill_fieldcat.
* 确定ALV输出格式的属性PERFORM frm_fill_layout .
* ALV报表输出PERFORM frm_alv_display.FORM frm_get_data .DATA:lv_row      TYPE n LENGTH 5,lv_message  TYPE bapi_msg.IF p_path IS INITIAL.MESSAGE '请输入上传文件的路径!' TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.ENDIF.DATA: lt_load TYPE TABLE OF zalsmex_tabline,ls_load TYPE zalsmex_tabline.CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'EXPORTINGfilename                = p_pathi_begin_col             = '1'"开始列i_begin_row             = '2'"开始行i_end_col               = '5'"结束列i_end_row               = '10000'"结束行TABLESintern                  = lt_loadEXCEPTIONSinconsistent_parameters = 1upload_ole              = 2OTHERS                  = 3.SORT lt_load BY row col.LOOP AT lt_load INTO ls_load.lv_row = ls_load-row + 4.CASE ls_load-col.WHEN 1.gs_data-id = ls_load-value.WHEN 2.gs_data-name = ls_load-value.WHEN 3.CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.gs_data-age = ls_load-value.ENDCATCH.IF sy-subrc <> 0.lv_message = '第' && lv_row && '行“年龄”列存在非数字的输入'.MESSAGE lv_message TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.ENDIF.WHEN 4.gs_data-hobby = ls_load-value.WHEN 5.PERFORM frm_convert_date USING ls_load-valueCHANGING gs_data-zdate.ENDCASE.AT END OF row.APPEND gs_data TO gt_data.CLEAR:gs_data.ENDAT.ENDLOOP.ENDFORM.FORM frm_fill_fieldcat .REFRESH: gt_fcat_lvc .PERFORM frm_add_field USING 'X' 'MSGTYP'       '状态' '' '' '' '' ''.PERFORM frm_add_field USING 'X' 'MESSAGE'       '消息' '' '' '' '' ''.PERFORM frm_add_field USING ''  'ID'        '学号' '' '' '' '' ''.PERFORM frm_add_field USING ''  'NAME'        '姓名' '' '' '' '' ''.PERFORM frm_add_field USING ''  'AGE'        '年龄' '' '' '' '' ''.PERFORM frm_add_field USING ''  'HOBBY'        '兴趣' '' '' '' '' ''.PERFORM frm_add_field USING ''  'ZDATE'        '日期' '' '' '' '' ''.
ENDFORM.*&---------------------------------------------------------------------*
*&      Form  FRM_FILL_LAYOUT
*&---------------------------------------------------------------------**----------------------------------------------------------------------*
FORM frm_fill_layout .CLEAR:gs_layout_lvc.gs_layout_lvc-zebra     = 'X'.gs_layout_lvc-cwidth_opt   = 'X'.gs_layout_lvc-box_fname   = 'SEL'.   "选择框
ENDFORM.*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
FORM frm_alv_display .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program       = sy-repidi_callback_pf_status_set = 'FRM_PF_STATUS'i_callback_user_command  = 'FRM_USER_COMMAND'is_layout_lvc            = gs_layout_lvcit_fieldcat_lvc          = gt_fcat_lvci_save                   = 'A'TABLESt_outtab                 = gt_dataEXCEPTIONSprogram_error            = 1OTHERS                   = 2.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.
ENDFORM.*&---------------------------------------------------------------------*
*&      Form  FRM_PF_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_pf_status USING pt_extab TYPE slis_t_extab .SET PF-STATUS 'STATUS01' .ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*       自定义的用户命令处理
*----------------------------------------------------------------------*
*      -->PV_UCOMM      用户命令类型
*      -->PS_SELFIELD  用户命令信息
*----------------------------------------------------------------------*
FORM frm_user_command USING pv_ucomm TYPE sy-ucommps_selfield TYPE slis_selfield.DATA: lr_grid TYPE REF TO cl_gui_alv_grid.ps_selfield-refresh    = 'X'.ps_selfield-col_stable = 'X'.ps_selfield-row_stable = 'X'.CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'IMPORTINGe_grid = lr_grid.CALL METHOD lr_grid->check_changed_data.CASE pv_ucomm.WHEN '&SAVE'.PERFORM frm_save.WHEN OTHERS.ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_ADD_FIELD
*&---------------------------------------------------------------------*
*       设置屏幕显示的字段
*----------------------------------------------------------------------*
*      -->P_U_FIELDNAME  text
*      -->P_U_SELTEXT  text
*----------------------------------------------------------------------*
FORM frm_add_field USING pv_keypv_fieldnamepv_seltextpv_nozeropv_sumpv_ref_fieldpv_ref_tablepv_edit.CLEAR:gs_fcat_lvc.gs_fcat_lvc-key       = pv_key.gs_fcat_lvc-fieldname = pv_fieldname.gs_fcat_lvc-coltext   = pv_seltext.gs_fcat_lvc-no_zero   = pv_nozero.gs_fcat_lvc-do_sum    = pv_sum.gs_fcat_lvc-ref_field = pv_ref_field.gs_fcat_lvc-ref_table = pv_ref_table.gs_fcat_lvc-edit      = pv_edit.IF pv_fieldname = 'MSGTYP'.gs_fcat_lvc-icon = 'X'.ENDIF.APPEND gs_fcat_lvc TO gt_fcat_lvc.
ENDFORM. " FRM_ADD_FIELD*&---------------------------------------------------------------------*
*&      Form  FRM_SAVE
*&---------------------------------------------------------------------*
FORM frm_save.DATA:gs_test TYPE zmmtest.LOOP AT gt_data into gs_data WHERE sel = 'X'.CLEAR:gs_test.gs_test = CORRESPONDING #( gs_data ).MODIFY  zmmtest from gs_test.gs_data-msgtyp = icon_led_green.gs_data-message = '新建成功'.modify gt_data from gs_data.ENDLOOP.ENDFORM.*&---------------------------------------------------------------------*
*& Form FRM_CONVERT_DATE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*
*&---------------------------------------------------------------------*
FORM frm_convert_date  USING    pv_value
CHANGING pv_date TYPE d.TRY.CALL METHOD cl_abap_datfm=>conv_date_ext_to_intEXPORTINGim_datext = pv_value
*         IM_DATFMDES  =IMPORTINGex_datint = pv_date
*         EX_DATFMUSED =.CATCH cx_abap_datfm_no_date .
*            MESSAGE 'No Date' TYPE 'S' DISPLAY LIKE 'E'.MESSAGE '日期格式错误' TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.CATCH cx_abap_datfm_invalid_date .
*            MESSAGE 'Invlid Date' TYPE 'S' DISPLAY LIKE 'E'.MESSAGE '日期格式错误' TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.CATCH cx_abap_datfm_format_unknown .
*            MESSAGE 'Unknown Date format' TYPE 'S' DISPLAY LIKE 'E'.MESSAGE '日期格式错误' TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.CATCH cx_abap_datfm_ambiguous .
*            MESSAGE 'Ambiguous Date' TYPE 'S' DISPLAY LIKE 'E'.MESSAGE '日期格式错误' TYPE 'S' DISPLAY LIKE 'E'.LEAVE LIST-PROCESSING.ENDTRY.ENDFORM.

2.包含文件源码如下:

*&---------------------------------------------------------------------*
*& Include ZBCN_EXCEL
*&---------------------------------------------------------------------*
TABLES: sscrfields.DATA: gs_key           LIKE wwwdatatab,gv_stripped_name TYPE rlgrap-filename,gv_file_path     TYPE rlgrap-filename.DATA:gt_iexcel TYPE STANDARD TABLE OF alsmex_tabline,gs_iexcel TYPE alsmex_tabline.*       Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*       messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.DATA: ctumode LIKE ctu_params-dismode VALUE 'N'.
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynproDATA: cupdate LIKE ctu_params-updmode VALUE 'L'.
"S: synchronously
"A: asynchronously
"L: local*&---------------------------------------------------------------------*
*&      Form  FRM_SELECT_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_select_file USING pv_title pv_filename.CALL FUNCTION 'WS_FILENAME_GET'EXPORTINGmask             = ',Excel Files xls,*.xls,Excel Files xlsx,*.xlsx,TXT Files,*.txt,ALL Files,*.*'mode             = '0'title            = pv_titleIMPORTINGfilename         = pv_filenameEXCEPTIONSinv_winsys       = 1no_batch         = 2selection_cancel = 3selection_error  = 4OTHERS           = 5.
ENDFORM. " FRM_SELECT_FILE
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_EXCEL_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_get_excel_data USING pv_filepv_beg_colpv_beg_rowpv_end_colpv_end_rowpv_del_row.REFRESH: gt_iexcel.CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'EXPORTINGfilename                = pv_filei_begin_col             = pv_beg_coli_begin_row             = pv_beg_rowi_end_col               = pv_end_coli_end_row               = pv_end_rowTABLESintern                  = gt_iexcelEXCEPTIONSinconsistent_parameters = 1upload_ole              = 2OTHERS                  = 3.IF sy-subrc <> 0.if sy-langu = '1' .MESSAGE '导入数据文件失败!' TYPE 'S'.else.MESSAGE 'Failed to import data file!' TYPE 'S'.endif.LEAVE LIST-PROCESSING.ENDIF.ENDFORM. " FRM_GET_EXCEL_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_DOWNLOAD_TMP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->pv_filter   text
*      -->pv_objid    text
*----------------------------------------------------------------------*
FORM frm_download_tmp USING pv_filterpv_objid.DATA: pv_fd LIKE rlgrap-filename.if sy-langu = '1' .CALL FUNCTION 'WS_FILENAME_GET'EXPORTINGmask             = pv_filtermode             = '0'title            = '模板下载'IMPORTINGfilename         = pv_fdEXCEPTIONSinv_winsys       = 1no_batch         = 2selection_cancel = 3selection_error  = 4OTHERS           = 5.else.CALL FUNCTION 'WS_FILENAME_GET'EXPORTINGmask             = pv_filtermode             = '0'title            = 'Template download'IMPORTINGfilename         = pv_fdEXCEPTIONSinv_winsys       = 1no_batch         = 2selection_cancel = 3selection_error  = 4OTHERS           = 5.endif.IF pv_fd IS NOT INITIAL.CLEAR: gs_key.gs_key-relid = 'MI'.gs_key-objid = pv_objid.CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'EXPORTINGkey         = gs_keydestination = pv_fd.CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'EXPORTINGfull_name     = pv_fdIMPORTINGstripped_name = gv_stripped_namefile_path     = gv_file_path.ENDIF.
ENDFORM. " FRM_DOWNLOAD_TMP
*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PROGRAM    text
*      -->DYNPRO     text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.CLEAR bdcdata.bdcdata-program  = program.bdcdata-dynpro   = dynpro.bdcdata-dynbegin = 'X'.APPEND bdcdata.
ENDFORM. "BDC_DYNPRO*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.DATA: lv_fval TYPE string.lv_fval = fval.CONDENSE lv_fval.CLEAR bdcdata.bdcdata-fnam = fnam.bdcdata-fval = lv_fval.APPEND bdcdata.
ENDFORM. "BDC_FIELD

需要的结构类型定义:
在这里插入图片描述

3.ZALSM_EXCEL_TO_INTERNAL_TABLE 接口代码

FUNCTION zalsm_excel_to_internal_table .
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(FILENAME) LIKE  RLGRAP-FILENAME
*"     VALUE(SHEET_NAME) TYPE  CHAR50 OPTIONAL
*"     VALUE(I_BEGIN_COL) TYPE  I
*"     VALUE(I_BEGIN_ROW) TYPE  I
*"     VALUE(I_END_COL) TYPE  I
*"     VALUE(I_END_ROW) TYPE  I
*"  TABLES
*"      INTERN STRUCTURE  ZALSMEX_TABLINE
*"  EXCEPTIONS
*"      INCONSISTENT_PARAMETERS
*"      UPLOAD_OLE
*"----------------------------------------------------------------------DATA: excel_tab     TYPE  ty_t_sender.DATA: ld_separator  TYPE  c.DATA: application TYPE  ole2_object,workbook    TYPE  ole2_object,range       TYPE  ole2_object,worksheet   TYPE  ole2_object.DATA: h_cell  TYPE  ole2_object,h_cell1 TYPE  ole2_object.DATA:ld_rc             TYPE i.
*   Rückgabewert der Methode "clipboard_export     "* Makro für Fehlerbehandlung der MethodsDEFINE m_message.CASE sy-subrc.WHEN 0.WHEN 1.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.WHEN OTHERS. RAISE upload_ole.ENDCASE.END-OF-DEFINITION.* check parametersIF i_begin_row > i_end_row. RAISE inconsistent_parameters. ENDIF.IF i_begin_col > i_end_col. RAISE inconsistent_parameters. ENDIF.* Get TAB-sign for separation of fieldsCLASS cl_abap_char_utilities DEFINITION LOAD.ld_separator = cl_abap_char_utilities=>horizontal_tab.* open file in ExcelIF application-header = space OR application-handle = -1.CREATE OBJECT application 'Excel.Application'.m_message.ENDIF.CALL METHOD OF application 'Workbooks' = workbook.m_message.CALL METHOD OF workbook 'Open' EXPORTING #1 = filename.
*  m_message.
*add by hubert begin---------sy-subrc = 0. "强制
*  set property of application 'Visible' = 1.
*  m_message.IF sheet_name = space."用默认模式GET PROPERTY OF application 'ACTIVESHEET' = worksheet.m_message.ELSE.
*   -->读取指定SHEETCALL METHOD OF application 'WORKSHEETS' = worksheetEXPORTING#1 = sheet_name.
*    #2 = 0              "UpdateLinks
*    #3 = 0              "ReadOnly
*    #4 = 1.              "FormatCALL METHOD OF worksheet 'Activate'.m_message.ENDIF.
*add by hubert end--------
*
*  GET PROPERTY OF  application 'ACTIVESHEET' = worksheet.
*  m_message.* mark whole spread sheetCALL METHOD OF worksheet 'Cells' = h_cellEXPORTING #1 = i_begin_row #2 = i_begin_col.m_message.CALL METHOD OF worksheet 'Cells' = h_cell1EXPORTING #1 = i_end_row #2 = i_end_col.m_message.CALL METHOD  OF worksheet 'RANGE' = rangeEXPORTING #1 = h_cell #2 = h_cell1.m_message.CALL METHOD OF range 'SELECT'.m_message.* copy marked area (whole spread sheet) into ClippboardCALL METHOD OF range 'COPY'.m_message.* read clipboard into ABAPCALL METHOD cl_gui_frontend_services=>clipboard_importIMPORTINGdata       = excel_tabEXCEPTIONScntl_error = 1
*     ERROR_NO_GUI         = 2
*     NOT_SUPPORTED_BY_GUI = 3OTHERS     = 4.IF sy-subrc <> 0.MESSAGE a037(alsmex).ENDIF.PERFORM separated_to_intern_convert TABLES excel_tab internUSING  ld_separator.* clear clipboardREFRESH excel_tab.CALL METHOD cl_gui_frontend_services=>clipboard_exportIMPORTINGdata       = excel_tabCHANGINGrc         = ld_rcEXCEPTIONScntl_error = 1
*     ERROR_NO_GUI         = 2
*     NOT_SUPPORTED_BY_GUI = 3OTHERS     = 4.* quit Excel and free ABAP Object - unfortunately, this does not kill
* the Excel processCALL METHOD OF application 'QUIT'.m_message.* >>>>> Begin of change note 575877
* to kill the Excel process it's necessary to free all used objectsFREE OBJECT h_cell.       m_message.FREE OBJECT h_cell1.      m_message.FREE OBJECT range.        m_message.FREE OBJECT worksheet.    m_message.FREE OBJECT workbook.     m_message.FREE OBJECT application.  m_message.
* <<<<< End of change note 575877
ENDFUNCTION.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/28486.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

visual studio配置调用c++ dll opencv为例

1&#xff0c;配置VC目录&#xff0c;包含目录和库目录。 2&#xff0c;链接器->输入->包含目录 3&#xff0c;生成目录下包含对应的dll文件 4&#xff0c;需注意对应的Debug&#xff0c;Release及X86&#xff0c;X64选项

创建型模式 - 建造者模式

概述 将一个复杂对象的构建与表示分离&#xff0c;使得同样的构建过程可以创建不同的表示。 分离了部件的构造(由Builder来负责)和装配(由Director负责)。 从而可以构造出复杂的对象。这个模式适用于&#xff1a;某个对象的构建过程复杂的情况。 由于实现了构建和装配的解耦。…

Java基础---常用类大全以及各数据结构的方法大全

目录 前言 一、Math类 二.Scanner类 三、String类、StringBuilder和StringBuffer类 &#x1f496;String类 &#x1f496;StringBuilder和StringBuffer 四.Arrays类 五.Random类 六.时间类 七.ArrayList顺序表 八、LinkedList与链表 九.Stack栈和Queue队列 十.Pri…

SpringCloud Alibaba——Ribbon的属性配置和类配置优先级

目录 一、Ribbon的属性配置和类配置哪个优先级高二、Ribbon的属性配置和类配置优先级源码解读 一、Ribbon的属性配置和类配置哪个优先级高 类配置优先级高 二、Ribbon的属性配置和类配置优先级源码解读 通过RibbonClientConfiguration类中的ribbonRule方法可知&#xff0c;优…

guava限流器RateLimiter使用简介(Springboot实现)

在大型分布式系统中&#xff0c;限流是一种重要的防护机制&#xff0c;可以帮助我们控制流量并减轻系统的负担。Google的Guava库提供了一种方便的限流器实现&#xff0c;可以帮助我们轻松地实现限流功能。本文将介绍Guava中限流器的基本概念和使用方法。 一、什么是限流器&…

实现小程序商城首页【源码公开】

效果图 页面源码 <view class"index-container"><view class"header"><!--搜索框【仅样式&#xff0c;不做处理】 start--><van-search bindtap"clickSearch" disabled shape"round" background"#9c7bf0&q…

GPT与人类:人工智能是否能够真正复制人类语言?

人类语言是一种复杂的系统&#xff0c;它不仅包含着无数单词和语法规则&#xff0c;更重要的是具有丰富的含义和上下文。这些语言特征涉及到常识、文化、情感和经验等方面&#xff0c;是人类在长期进化和文明发展中所积累起来的丰富知识和经验的体现。然而&#xff0c;人工智能…

Java对日志文件进行加密

最近碰到了一个新的需求&#xff0c;生产环境中Java程序部署的服务器会定期清理数据&#xff0c;需要将保存在程序所在服务器上的日志文件挂载到网盘上&#xff0c;但又不想让用户看到日志文件中的信息&#xff0c;因此需要对日志文件中的内容进行加密。 这里&#xff0c;并不是…

2023牛客暑期多校训练营1(D/H/J/K)

目录 D.Chocolate H.Matches J.Roulette K.Subdivision D.Chocolate 思路&#xff1a;当n1且m1时候先手必输&#xff0c;然后1*k&#xff08;k>2&#xff09;的情况下后手必输&#xff0c;因为先手可以选到只剩下一个格子。而在其它情况里先手第一步可以先选(1,1)的格子…

ARM 架构是什么?

ARM&#xff08;Advanced RISC Machines&#xff09;架构是一种处理器架构&#xff0c;它是一种精简指令集计算机&#xff08;RISC&#xff09;架构。ARM架构最初由ARM Holdings&#xff08;现在是SoftBank Group的子公司&#xff09;开发&#xff0c;并在1980年代末和1990年代…

sort部分

sort主要针对文件内容的操作&#xff0c;对文件内容进行匹配或者过滤&#xff0c;排序 grep 过滤 针对文本内容进行过滤&#xff0c;也就是查找 -i&#xff1a;忽略大小写默认的&#xff0c;可以不加 -n&#xff1a;显示匹配的行号 -c&#xff1a;只统计匹配的行数 &#…

Python 列表 sort()函数使用详解

「作者主页」&#xff1a;士别三日wyx 「作者简介」&#xff1a;CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者 「推荐专栏」&#xff1a;小白零基础《Python入门到精通》 sort函数使用详解 1、升序降序2、sort()和sorted()的区别3、切片排序4、指定排序…