在使用智能标记合并数据时获取通知
Contents
[
Hide
]
Aspose.Cells APIs 提供 WorkbookDesigner 类来处理 智能标记,其中格式和公式放置在 设计者电子表格 中,然后使用 WorkbookDesigner 类根据指定的智能标记填充数据。有时,可能需要获取有关所处理的单元格引用或特定智能标记的通知。这可以通过 WorkbookDesigner.CallBack 属性和 ISmartMarkerCallBack 接口来实现,该接口在 Aspose.Cells for .NET 8.6.2 版本发布时公开。
以下代码片段演示了ISmartMarkerCallBack 接口的用法,定义了一个处理WorkbookDesigner.Process 方法的新类。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
class SmartMarkerCallBack: ISmartMarkerCallBack | |
{ | |
Workbook workbook; | |
public SmartMarkerCallBack(Workbook workbook) { | |
this.workbook = workbook; | |
} | |
public void Process(int sheetIndex, int rowIndex, int colIndex, String tableName, String columnName) { | |
Console.WriteLine("Processing Cell: " + workbook.Worksheets[sheetIndex].Name + "!" + CellsHelper.CellIndexToName(rowIndex, colIndex)); | |
Console.WriteLine("Processing Marker: " + tableName + "." + columnName); | |
} | |
} |
其余的过程包括使用WorkbookDesigner 加载包含智能标记的设计电子表格,并通过设置数据源处理它。 为了保持示例简单,我们使用一个预定义的设计师电子表格,其中只包含两个智能标记,如下面的快照所示,数据源是动态创建的,以根据指定的智能标记合并数据。
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|