Come ottenere le informazioni sulla connessione OData con Node.js tramite C++
Ottenere informazioni sulla connessione OData
Potrebbero esserci casi in cui gli sviluppatori devono estrarre le informazioni OData dal file Excel. Aspose.Cells for Node.js via C++ fornisce la proprietà Workbook.getDataMashup() che restituisce le informazioni DataMashup presenti nel file Excel. Queste informazioni sono rappresentate dalla classe DataMashup. La classe DataMashup fornisce la proprietà DataMashup.getPowerQueryFormulas() che restituisce la collezione PowerQueryFormulaCollection. Da PowerQueryFormulaCollection puoi accedere a PowerQueryFormula e PowerQueryFormulaItem.
Il seguente frammento di codice dimostra l’uso di queste classi per recuperare le informazioni OData.
Il file di origine utilizzato nello snippet di codice seguente è allegato per il tuo riferimento.
Codice di Esempio
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "ODataSample.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
const PQFcoll = workbook.getDataMashup().getPowerQueryFormulas();
for (let i = 0; i < PQFcoll.getCount(); i++) {
const PQF = PQFcoll.get(i);
console.log("Connection Name: " + PQF.getName());
const PQFIcoll = PQF.getPowerQueryFormulaItems();
for (let j = 0; j < PQFIcoll.getCount(); j++) {
const PQFI = PQFIcoll.get(j);
console.log("Name: " + PQFI.getName());
console.log("Value: " + PQFI.getValue());
}
}
Output della console
Connection Name: Orders
Name: Source
Value: OData.Feed("https://services.odata.org/V3/Northwind/Northwind.svc/", null, [Implementation="2.0"])
Name: Orders_table
Value: Source{[Name="Orders",Signature="table"]}[Data]