Java does Excel export, converts the value to scientific notation and saves it, and uses postman to send a post request to save the excel file

It is very strange that when other people do excel-related things, scientific notation appears, and scientific notation needs to be removed, but this time I need to convert the exported value in Excel to scientific notation for saving: Excel is as follows: these
two
insert image description here
columns The exported object needs to be set to String type:

    @Excel(name = "p")
    private String pvalue;
    @Excel(name = "d")
    private String fdr;

responseList is the collection object to be exported, traverse the collection, and convert the two columns in scientific notation:
insert image description here
the code is as follows:

  //获取String类型的值
  String pvalue = x.getPvalue();
  //转换为BigDecimal对象
  BigDecimal bd = new BigDecimal(pvalue);
  //String.format转换为科学计数法
  x.setPvalue(String.format("%E",bd));

Export results:
insert image description here
Click here to verify that there is no problem:
insert image description here
Learn a trick here: When postman sends a download request, you can convert the response into a file stream and save it:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_42260782/article/details/130605748