SoFunction
Updated on 2025-04-07

Vue download Excel implementation code background using post method

The parameters of the background method must be modified by @RequestBody.

Front desk key code:

axios ( {
     method : 'post',
     url :  , // Request address     data : {
      choose : type,
      begindate : startDate,
      enddate : endDate
     },
     responseType : 'arraybuffer',
     observe: 'response',
    } )
     .then ( ( res ) => {

      const fileName = ""+filename+".xlsx"
      let blob = new Blob([], {type: "application/"});
      if ( 'download' in  ( 'a' ) ) { // Non-IE download       const elink =  ( 'a' )
        = fileName
        = 'none'
        =  ( blob )
        ( elink )
        ()
        (  ) // Release URL object        ( elink )
      } else { // IE10+ download        ( blob, fileName )
      }
     })
download(data) {
    if (!data) {
     return
    }
    let url = (new Blob([data]))
    let link = ('a')
     = 'none'
     = url
    ('download', '')

    (link)
    ()
   },

Summarize

The above is the post method for the implementation code of Vue download Excel introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!