Solution to the timeout (504) problem of exporting a large amount of data to excel in Java Web Development

In web development, it is common to query data from the database or cross system call interface to prepare Excel data, which takes a lot of time. Therefore, the data is not returned to the browser in time, resulting in 504 timeout.

This tool uses servlet OutputStream segmented flush data to the browser. Call mode: first new CSV (), passing in the specified parameters, calling wirte () constantly to write data to the browser, and finally calling close method to close the flow.

The file format exported by this tool is CSV files and windows office tools are encoded as ASCI by default. WPS will match various codes. Libreoffice Calc can specify the code. Therefore, the code is set as GBK, which is compatible with three kinds of Excel software. You can also set the code according to your own needs.

This tool only processes the transcoding of "," in CSV, but does not process double quotation marks.

I hope this article can be helpful to friends who encounter this problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>