Recevoir des notifications lors de la fusion de données avec des marqueurs intelligents

Recevoir des notifications lors de la fusion des données avec les Smart Markers

Le morceau de code suivant démontre l’utilisation de l’interface ISmartMarkerCallBack pour définir une nouvelle classe qui gère le rappel pour la méthode WorkbookDesigner.process.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
public class SmartMarkerCallBack implements ISmartMarkerCallBack {
Workbook workbook;
SmartMarkerCallBack(Workbook workbook) {
this.workbook = workbook;
}
@Override
public void process(int sheetIndex, int rowIndex, int colIndex, String tableName, String columnName) {
System.out.println("Processing Cell : " + workbook.getWorksheets().get(sheetIndex).getName() + "!"
+ CellsHelper.cellIndexToName(rowIndex, colIndex));
System.out.println("Processing Marker : " + tableName + "." + columnName);
}
}

Afin de simplifier l’exemple et d’aller droit au but, le snippet suivant crée une feuille de calcul du concepteur vide, insère un Smart Marker et la traite avec la source de données créée dynamiquement.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(GetNotificationsWhileMergingData.class);
// Instantiate a new Workbook designer
WorkbookDesigner report = new WorkbookDesigner();
// Get the first worksheet of the workbook
Worksheet sheet = report.getWorkbook().getWorksheets().get(0);
/*
* Set the Variable Array marker to a cell. You may also place this Smart Marker into a template file manually using Excel
* and then open this file via WorkbookDesigner
*/
sheet.getCells().get("A1").putValue("&=$VariableArray");
// Set the data source for the marker(s)
report.setDataSource("VariableArray", new String[] { "English", "Arabic", "Hindi", "Urdu", "French" });
// Set the CallBack property
report.setCallBack(new SmartMarkerCallBack(report.getWorkbook()));
// Process the markers
report.process(false);
// Save the result
report.getWorkbook().save(dataDir);