使用 Node.js 在 Excel 中显示文档属性

按照本文使用 Node.js 在 Excel 中显示文档属性。获取设置开发环境的所有详细信息、描述流程的步骤列表以及显示如何使用 Node.js 在 Excel 中显示属性的示例代码。您将学习以各种方式访问这些属性并根据要求显示不同的参数。

使用 Node.js 显示 Excel 文档属性的步骤

  1. 配置开发环境以使用 Aspose.Cells for Node.js via Java 打印属性
  2. 将 Excel 文件加载到 Workbook 对象中并迭代所有自定义属性
  3. 显示每个项目的属性名称和值
  4. 迭代 built-in properties 集合中的所有项目并显示它们
  5. 使用属性名称和索引访问任何属性

这些步骤定义使用 Node.js* 打印 *Excel 电子表格属性的过程。通过加载 Excel 文件并访问其内置和自定义属性集合来启动该过程。解析两个集合并显示每个属性的名称和值。

使用 Node.js 编写 Excel 文件属性代码

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
// Initialize the license
new aspose.cells.License().setLicense("License.lic");
// Open an Excel file
var workbook = new aspose.cells.Workbook("Input.xlsx");
for(let i = 0; i < workbook.getCustomDocumentProperties().getCount();i++)
{
var custProp = workbook.getCustomDocumentProperties().get(i);
console.log(custProp.getName());
console.log(custPrrop.getValue());
}
for(let i = 0; i < workbook.getBuiltInDocumentProperties().getCount();i++)
{
var builtinProperty = workbook.getBuiltInDocumentProperties().get(i);
console.log(builtinProperty.getName());
console.log(builtinProperty.getValue());
}
// Access the builtin properties
var builtinProperties = workbook.getBuiltInDocumentProperties();
// Access the author
var builtinProperty = builtinProperties.get("Author");
console.log(builtinProperty.getName() + " " + builtinProperty.getValue());
// Accessing the first property
builtinProperty = builtinProperties.get(0);
console.log(builtinProperty.getName() + " " + builtinProperty.getValue());
console.log("Properties displayed successfully");

此代码演示了使用 Node.js* 打印 *Excel 工作簿属性的过程。当访问文档属性时,我们可以显示链接的内容源、检查属性是否与内容链接的标志,以及基于其类型的布尔值、日期/时间、双精度、整数或字符串属性值。

在本文中,我们使用 Node.js 显示了Excel 电子表格的属性。要在 Excel 中自动换行,请参阅有关 使用 Node.js 在 Excel 中换行文本 的文章。

 简体中文