POI生成的excel的文件属性

import org.apache.poi.hpsf.CustomProperties;
import org.apache.poi.hpsf.DocumentSummaryInformation;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.FileOutputStream;
import java.io.OutputStream;

public class Test {

public static void main(String args[]) throws Exception {
    OutputStream out = null;
    //为文件添加用户名,ip,时间等信息
    try {
        HSSFWorkbook workbook = new HSSFWorkbook();
        workbook.createInformationProperties();
        SummaryInformation suminfoInformation = workbook.getSummaryInformation();
        DocumentSummaryInformation info = workbook.getDocumentSummaryInformation();
        //添加备注信息
        suminfoInformation.setComments("beizhu");
        suminfoInformation.setAuthor("zhangsan");
        //添加自定义属性
        CustomProperties customProperties = new CustomProperties();
        customProperties.put("IP","172.193.444");
        info.setCustomProperties(customProperties);
        out = new FileOutputStream("F://2.xls");
        workbook.write(out);
    } catch (Exception e) {
        e.printStackTrace();
    }finally{
        if (out!=null) {
            out.close();
        }
    }
}

}

你可能感兴趣的:(javaweb)