[]
IDocumentPropertyCollection提供对标准工作簿元数据的访问,例如作者、标题、主题、公司、管理者、应用程序名称以及其他预定义文档属性。使用 Workbook.getBuiltInDocumentProperties() 可获取此集合,并读取或更新工作簿公开的内置属性。
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("A1").setValue("Quarterly Report");
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setAuthor("Author");
properties.setCompany("Example");
properties.setTitle("Quarterly Report");
String xlsxFileName = "BuiltInDocumentProperties.xlsx";
workbook.save(xlsxFileName);
booleanintgetPages()booleangetTitle()intintgetWords()voidvoidsetCategory(String value) voidsetComments(String value) voidsetCompany(String value) voidsetContentStatus(String value) voidsetContentType(String value) voidsetCreatedDate(Calendar value) voidsetDocumentVersion(String value) voidsetHyperlinkBasey(String value) voidsetKeywords(String value) voidsetLanguage(String value) voidsetLastPrinted(Calendar value) voidsetLastSavedBy(String value) voidsetLastSavedTime(Calendar value) voidsetLinksUpToDate(boolean value) voidsetManager(String value) voidsetNameOfApplication(String value) voidsetPages(int value) voidsetRevisionNumber(String value) voidsetScaleCrop(boolean value) voidsetSubject(String value) voidsetTemplate(String value) voidvoidsetTotalEditingTime(int value) voidsetWords(int value) 返回用于存储负责管理文档的人员姓名的内置文档属性。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setManager("Manager");
String manager = properties.getManager();
null。设置用于存储负责管理文档的人员姓名的内置文档属性。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setManager("Manager");
value - 管理者属性值;可以为 null。使用此属性可读取存储在内置文档属性中的应用程序名称。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setNameOfApplication("Example App");
String applicationName = properties.getNameOfApplication();
使用此属性可设置存储在内置文档属性中的应用程序名称。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setNameOfApplication("Example App");
value - 应用程序名称。使用此属性可获取存储估计页数的内置文档元数据值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setPages(12);
int pages = properties.getPages();
使用此属性可设置存储估计页数的内置文档元数据值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setPages(12);
value - 文档的估计页数。使用此属性可获取存储在内置文档属性中的修订号。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setRevisionNumber("5");
String revisionNumber = properties.getRevisionNumber();
使用此属性可将修订号存储到内置文档属性中。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setRevisionNumber("5");
value - 文档的修订号。使用此属性可获取存储在内置文档属性中的模板名称。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTemplate("Quarterly Report Template");
String template = properties.getTemplate();
使用此属性可设置存储在内置文档属性中的模板名称。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTemplate("Quarterly Report Template");
value - 文档模板的信息性名称。此方法返回内置 Title 文档属性的值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTitle("Quarterly Sales Report");
String title = properties.getTitle();
此方法设置内置 Title 文档属性的值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTitle("Quarterly Sales Report");
value - 文档的标题。此属性存储为文档记录的累计编辑时间。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTotalEditingTime(90);
int totalEditingTime = properties.getTotalEditingTime();
此属性存储为文档记录的累计编辑时间。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setTotalEditingTime(90);
value - 总编辑时间,以分钟为单位。此属性表示存储在工作簿中的内置文档版本。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setDocumentVersion("2.1");
String documentVersion = properties.getDocumentVersion();
此属性表示存储在工作簿中的内置文档版本。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setDocumentVersion("2.1");
value - 文件的文档版本。使用此属性可以确定文档缩略图是否以缩放裁剪模式显示。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setScaleCrop(true);
boolean scaleCrop = properties.getScaleCrop();
true;否则为 false。使用此属性可设置文档缩略图是否以缩放裁剪模式显示。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setScaleCrop(true);
value - 如果文档缩略图使用缩放裁剪模式,则为 true;否则为 false。使用此方法可从文档元数据中检索内置主题属性。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setSubject("Quarterly Sales Report");
String subject = properties.getSubject();
使用此方法可从文档元数据中设置内置主题属性。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setSubject("Quarterly Sales Report");
value - 文档的主题。修改文档时,此属性不会自动更新。使用 setLastSavedTime(Calendar) 可更改存储的值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar lastSavedTime = Calendar.getInstance();
lastSavedTime.set(2024, Calendar.JANUARY, 15, 10, 30, 0);
properties.setLastSavedTime(lastSavedTime);
Calendar savedTime = properties.getLastSavedTime();
使用此方法可以显式指定内置文档属性值。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar lastSavedTime = Calendar.getInstance();
lastSavedTime.set(2024, Calendar.JANUARY, 15, 10, 30, 0);
properties.setLastSavedTime(lastSavedTime);
value - 本地时区的上次保存时间。允许为 null。修改文档时,此属性不会自动更新。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLastSavedBy("Author");
String lastSavedBy = properties.getLastSavedBy();
修改文档时,此属性不会自动更新。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLastSavedBy("Author");
value - 上次保存文档的作者名称。在读取上次打印时间之前,使用 setLastPrinted(Calendar) 将其存储到内置文档属性中。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar lastPrinted = Calendar.getInstance();
lastPrinted.set(2024, Calendar.JANUARY, 15, 10, 30, 0);
properties.setLastPrinted(lastPrinted);
Calendar printedTime = properties.getLastPrinted();
使用此方法可将上次打印时间戳存储到内置文档属性中。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar lastPrinted = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
lastPrinted.set(2024, Calendar.JANUARY, 15, 9, 30, 0);
properties.setLastPrinted(lastPrinted);
value - 文档上次打印时的 UTC 时间。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLanguage("en-US");
String language = properties.getLanguage();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLanguage("en-US");
value - 文档语言。在检索作者名称之前,使用 setAuthor(String) 指定作者名称。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setAuthor("Author");
String author = properties.getAuthor();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setAuthor("Author");
value - 文档作者的名称。使用此属性可获取存储工作簿描述性注释的内置文档元数据。要指定值,请使用 setComments(String)。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setComments("Quarterly sales report for internal review.");
String comments = properties.getComments();
null。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setComments("Quarterly sales report for internal review.");
value - 文档注释;可以为 null。使用此属性可获取存储工作簿类别的内置文档元数据。要指定值,请使用 setCategory(String)。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setCategory("Finance");
String category = properties.getCategory();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setCategory("Finance");
value - 文档的类别。使用此属性可获取描述文档内容类型的内置文档元数据。要指定值,请使用 setContentType(String)。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setContentType("Monthly Report");
String contentType = properties.getContentType();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setContentType("Monthly Report");
value - 文档的内容类型。使用此属性可读取由 Workbook.getBuiltInDocumentProperties() 返回的文档属性集合中存储的内置内容状态。要更新该值,请使用 setContentStatus(String)。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setContentStatus("Final");
String contentStatus = properties.getContentStatus();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setContentStatus("Final");
value - 文档的内容状态。使用此属性可以检索存储在工作簿内置文档属性中的公司信息。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setCompany("Example");
String company = properties.getCompany();
null。使用此属性可设置存储在工作簿内置文档属性中的公司信息。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setCompany("Example");
value - 公司属性值;可以为 null。此属性存储文档中用于超链接的基路径或 URL。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setHyperlinkBasey("https://www.example.com/docs/");
String hyperlinkBase = properties.getHyperlinkBase();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setHyperlinkBasey("https://example.com/docs/");
value - 超链接基属性值。修改文档时,此属性不会自动更新。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar createdDateValue = new GregorianCalendar(2024, Calendar.JANUARY, 15, 10, 30, 0);
properties.setCreatedDate(createdDateValue);
Calendar createdDate = properties.getCreatedDate();
使用此方法可为工作簿存储内置创建日期属性。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
Calendar createdDate = new GregorianCalendar(2024, Calendar.JANUARY, 15, 9, 30, 0);
properties.setCreatedDate(createdDate);
value - 文档在本地时区的创建日期。如果未指定创建日期,则允许为 null。返回存储在内置文档属性中的关键字。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setKeywords("Budget, Forecast, Sales");
String keywords = properties.getKeywords();
设置存储在内置文档属性中的关键字。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setKeywords("Budget, Forecast, Sales");
value - 文档关键字。此内置文档属性指示文档的超链接信息是否标记为当前。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLinksUpToDate(true);
boolean linksUpToDate = properties.getLinksUpToDate();
true;否则为 false。此内置文档属性指示文档的超链接信息是否标记为当前。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setLinksUpToDate(true);
value - 如果文档的超链接标记为最新,则为 true;否则为 false。
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setWords(320);
int words = properties.getWords();
IBuiltInDocumentPropertyCollection properties = workbook.getBuiltInDocumentProperties();
properties.setWords(320);
value - 文档的估计字数。