本简短指南解释了如何使用 Node.js 删除 Excel 中的评论。它包含设置开发和测试功能的环境的所有详细信息、编写应用程序的步骤列表以及演示如何使用 Node.js 在 Excel 中删除注释的准备运行的示例代码。此功能不需要在您的系统上安装任何第三方工具或软件。
使用 Node.js 在 Excel 中删除注释的步骤
- 设置环境以使用 Aspose.Cells for Node.js 通过 Java 删除评论
- 加载带有评论的 workbook
- 访问要从中删除 comments 的所需工作表
- 访问评论集合并调用removeAt()方法
- 删除注释后保存结果工作簿
这些步骤提供了如何使用 Node.js 在 Excel 中删除弹出注释的摘要。该过程首先加载工作簿、访问工作表,然后访问所选工作表中的评论集合。最后,通过提供单元格名称来调用 CommentCollection 类中的 removeAt() 方法。
使用 Node.js 从 Excel 中删除注释的代码
var aspose = aspose || {}; | |
aspose.cells = require("aspose.cells"); | |
// Set the license | |
new aspose.cells.License().setLicense("License.lic"); | |
// Load a workbook | |
var workbook = new aspose.cells.Workbook("InputWithComments.xlsx"); | |
// Access any worksheet with comments from the workbook | |
var worksheet = workbook.getWorksheets().get(0); | |
// Remove the comments | |
worksheet.getComments().removeAt("A3"); | |
// For clearing all comments | |
// worksheet.clearComments(); | |
// Save the output XLSX file | |
workbook.save("output.xlsx"); | |
console.log("Comment deleted successfully"); |
此代码演示了使用 Node.js 清除 Excel 中的注释的过程。 CommentCollection 类具有根据您的要求删除所有或特定评论的功能。您可以通过提供单元格名称或行/列信息来删除单个注释,也可以根据要求使用clearComments()方法一次性删除所有注释。
本文教我们自动从 Excel 文件中删除注释的过程。如果您想了解在Excel文件中显示公式而不是值的过程,您可以参考如何使用 Node.js 在 Excel 中显示公式上的文章。