没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|行业资讯|编辑:胡涛|2024-08-15 14:20:37.037|阅读 53 次
概述:在这篇博文中,我们将学习如何使用 C# 在 Excel 中读取、添加和编辑线程注释,欢迎查阅
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Excel 中的线程注释是协作工作的重要功能。它允许多个用户在共享文档中添加、编辑和查看对话线程。在某些情况下,我们可能需要以编程方式管理这些线程注释。在这篇博文中,我们将学习如何使用 C# 在 Excel 中读取、添加和编辑线程注释。
Aspose.Cells 是Excel电子表格编程API,可加快电子表格的管理和处理任务,支持构建能够生成,修改,转换,呈现和打印电子表格的跨平台应用程序。同时不依赖于Microsoft Excel或任何Microsoft Office Interop组件,Aspose API 支持旗下产品覆盖文档、图表、PDF、条码、OCR、CAD、HTML、电子邮件等各个文档管理领域,为全球.NET 、Java、C ++等10余种平台开发人员提供丰富的开发选择。
为了处理 Excel 工作表中的线程注释,我们将使用Aspose.Cells for .NET API。它是一个功能强大的电子表格编程 API,使开发人员能够在 .NET 应用程序中创建、操作和转换 Excel 文件。通过利用 Aspose.Cells for .NET,我们可以轻松地在 Excel 工作表中添加、读取、编辑或删除线程注释。
要使用 API,请下载 DLL或使用以下命令从NuGet安装它:
PM> Install-Package Aspose.Cells
以下代码示例显示如何使用 C# 向 Excel 工作表添加线程注释。
// This code example demonstrates how to add threaded comments in an Excel worksheet // Create an instance of the Workbook class Workbook workbook = new Workbook(); // Access the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Add an Author var authorIndex = workbook.Worksheets.ThreadedCommentAuthors.Add("Aspose Test", "", ""); var author = workbook.Worksheets.ThreadedCommentAuthors[authorIndex]; // Add Threaded Comment worksheet.Comments.AddThreadedComment("A1", "Test Threaded Comment", author); // Save the output file workbook.Save("AddThreadedComments_out.xlsx");
要从 Excel 工作表中的指定单元格读取线程注释,请按照以下步骤操作:
以下代码示例显示如何使用 C# 从 Excel 工作表中读取指定列的线程注释。
// This code example demonstrates how to read threaded comments for a specified cell in an Excel worksheet // Load an existing Excel file Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); // Access the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Get Threaded Comments for a specific cell var threadedComments = worksheet.Comments.GetThreadedComments("A1"); // Read the threaded comments foreach (var comment in threadedComments) { Console.WriteLine("Author Name: " + comment.Author.Name); Console.WriteLine("Threaded comment Notes:" + comment.Notes); } Author Name: author@domain.com Threaded comment Notes:Test Threaded Comment
类似地,我们可以按照以下步骤读取 Excel 工作表中所有可用的主题评论:
以下代码示例显示如何使用 C# 从 Excel 工作表读取所有线程注释。
// This code example demonstrates how to read threaded comments for a specified cell in an Excel worksheet // Load an existing Excel file Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); // Access the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Get all the comments var comments = worksheet.Comments; // Read all the threaded comments foreach (var comment in comments) { // Process threaded comments foreach (var threadedComment in comment.ThreadedComments) { Console.WriteLine("Author Name: " + threadedComment.Author.Name); Console.WriteLine("Threaded comment author User Id: " + threadedComment.Author.UserId); Console.WriteLine("Threaded comment author ProviderId:" + threadedComment.Author.ProviderId); Console.WriteLine("Threaded comment Notes:" + threadedComment.Notes); } }
请按照以下步骤更新 Excel 中的任何主题评论:
以下代码示例展示如何使用 C# 编辑 Excel 工作表中的线程注释
// This code example demonstrates how to edit threaded comments in an Excel worksheet // Load an existing Excel file Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); // Access the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Get Threaded Comments for a specific cell var threadedComments = worksheet.Comments.GetThreadedComments("A1"); var comment = threadedComments[0]; // Update the comment note comment.Notes = "Updated Comment"; // Save the output file workbook.Save("EditThreadedComments.xlsx");
我们还可以按照以下步骤删除Excel工作表中特定单元格的线程注释:
以下代码示例显示如何使用 C# 删除 Excel 工作表中的线程注释。
// This code example demonstrates how to delete threaded comments in an Excel worksheet // Load an existing Excel file Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); // Get all the comments var comments = workbook.Worksheets[0].Comments; // Remove Comments comments.RemoveAt("A1"); // Save the output file workbook.Save("DeleteThreadedComments.xlsx");
在本文中,我们学习了如何使用 C# 读取、添加、编辑和删除 Excel 工作表中的线程注释。通过利用 Aspose.Cell for .NET,您可以轻松地在 C# 应用程序中操作 Excel 工作表。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
通过 HOOPS Luminate,TopSolid 的客户能在设计阶段就获得接近成品的视觉效果,缩短方案确认时间,提升成交效率。
随着应用跨平台需求的增加,测试环境的碎片化问题日益突出——设备、浏览器、操作系统版本的多样性使得测试覆盖率难以提升,同时本地维护测试环境的成本也急剧上升。借助SmartBear的两款产品——TestComplete与BitBar云,这些问题将迎刃而解。TestComplete作为一款强大的自动化GUI测试工具,结合BitBar云的跨平台测试能力,可以轻松实现多环境并行测试,显著提升测试效率与覆盖率
Sparx EA的三维功能体系构成了企业数字化转型的智能导航系统:可视化路线图提供方向指引,业务流程模拟实现路径优化,场景分析则保障行程安全。这套完整的方法论和工具组合,正在帮助越来越多的企业在数字化转型的复杂旅程中保持方向正确、执行有力、风险可控,最终实现战略目标。
专业的电子表格控件,无需MS Excel也可满足一切Excel表格功能。
Aspose.Cells for C++专业操作Excel电子表格的C ++ API
Aspose.Words for .NET无需Microsoft Word也可在任何平台上满足Word文档的一切操作需求。
Aspose.PDF for .NETPDF文档创建组件,无需Adobe Acrobat,也可以在任何平台上操作PDF文档。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号