Cerca e Sostituisci Dati in un Intervallo con Node.js tramite C++
Contents
[
Hide
]
A volte è necessario cercare e sostituire specifici dati in un intervallo ignorando eventuali valori delle celle al di fuori dell’intervallo desiderato. Aspose.Cells for Node.js via C++ ti permette di limitare una ricerca a un intervallo specifico. Questo articolo spiega come.
Aspose.Cells for Node.js via C++ fornisce il metodo FindOptions.setRange(CellArea) per specificare un intervallo durante la ricerca di dati. Di seguito un esempio di codice che cerca e sostituisce dati in un intervallo.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "input.xlsx");
const workbook = new AsposeCells.Workbook(filePath);
const worksheet = workbook.getWorksheets().get(0);
const area = AsposeCells.CellArea.createCellArea("E9", "H15");
const opts = new AsposeCells.FindOptions();
opts.setLookInType(AsposeCells.LookInType.Values);
opts.setLookAtType(AsposeCells.LookAtType.EntireContent);
opts.setRange(area);
let cell = null;
do {
cell = worksheet.getCells().find("search", cell, opts);
if (cell === null || cell.isNull()) {
break;
}
cell.putValue("replace");
} while (true);
workbook.save(path.join(dataDir, "output.out.xlsx"));