How to set Author name to excel file using poi

后端 未结 2 430
难免孤独
难免孤独 2021-01-01 15:08

I\'m creating an excel (.xlsx) file using poi (java). After I create the excel file I see the excel file Author as \"Apache POI\". Is there any way to change that?

H

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 15:50

    It's pretty straightforward:

    HSSF:

    SummaryInformation summaryInfo = workbook.getSummaryInformation();
    summaryInfo.setAuthor(author);
    

    XSSF:

    POIXMLProperties xmlProps = workbook.getProperties();    
    POIXMLProperties.CoreProperties coreProps =  xmlProps.getCoreProperties();
    coreProps.setCreator(author);
    

    Have fun :)

提交回复
热议问题