本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.getSummaryInformation方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFWorkbook.getSummaryInformation方法的具体用法?Java HSSFWorkbook.getSummaryInformation怎么用?Java HSSFWorkbook.getSummaryInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFWorkbook
的用法示例。
在下文中一共展示了HSSFWorkbook.getSummaryInformation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareHSSFMetaData
import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
*
* Write metadata into HSSF document
*
*/
private void prepareHSSFMetaData() {
HSSFWorkbook currentHSSFWorkbook = (HSSFWorkbook) this.currentWorkbook;
SummaryInformation summaryInfo = currentHSSFWorkbook.getSummaryInformation();
if (summaryInfo==null) {
currentHSSFWorkbook.createInformationProperties();
summaryInfo = currentHSSFWorkbook.getSummaryInformation();
}
SimpleDateFormat formatSDF = new SimpleDateFormat(MSExcelParser.DATE_FORMAT);
for (Map.Entry<String,String> entry: this.howc.getMetadata().entrySet()) {
// process general properties
try {
switch(entry.getKey()) {
case "applicationname":
summaryInfo.setApplicationName(entry.getValue());
break;
case "author":
summaryInfo.setAuthor(entry.getValue());
break;
case "charcount":
summaryInfo.setCharCount(Integer.parseInt(entry.getValue()));
break;
case "comments":
summaryInfo.setComments(entry.getValue());
break;
case "createdatetime":
summaryInfo.setCreateDateTime(formatSDF.parse(entry.getValue()));
break;
case "edittime":
summaryInfo.setEditTime(Long.parseLong(entry.getValue()));
break;
case "keywords":
summaryInfo.setKeywords(entry.getValue());
break;
case "lastauthor":
summaryInfo.setLastAuthor(entry.getValue());
break;
case "lastprinted":
summaryInfo.setLastPrinted(formatSDF.parse(entry.getValue()));
break;
case "lastsavedatetime":
summaryInfo.setLastSaveDateTime(formatSDF.parse(entry.getValue()));
break;
case "pagecount":
summaryInfo.setPageCount(Integer.parseInt(entry.getValue()));
break;
case "revnumber":
summaryInfo.setRevNumber(entry.getValue());
break;
case "security":
summaryInfo.setSecurity(Integer.parseInt(entry.getValue()));
break;
case "subject":
summaryInfo.setSubject(entry.getValue());
break;
case "template":
summaryInfo.setTemplate(entry.getValue());
break;
case "title":
summaryInfo.setTitle(entry.getValue());
break;
case "wordcount":
summaryInfo.setWordCount(Integer.parseInt(entry.getValue()));
break;
default:
LOG.warn("Unknown metadata key: "+entry.getKey());
break;
}
} catch (ParseException pe) {
LOG.error(pe);
}
}
}