Modifier une connexion de données SQL existante avec Aspose.Cells for Node.js via C++

Modifier une connexion de données SQL existante à l’aide d’Aspose.Cells

L’échantillon suivant illustre l’utilisation de Aspose.Cells for Node.js via C++ pour modifier la connexion de données SQL du classeur. Vous pouvez télécharger le fichier Excel source utilisé dans ce code ainsi que le fichier Excel de sortie généré par le code à partir des liens suivants.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Create workbook object
const workbook = new AsposeCells.Workbook(path.join(dataDir, "DataConnection.xlsx"));


// Access first Data Connection
const conn = workbook.getDataConnections().get(0);

// Change the Data Connection Name and Odc file
conn.setName("MyConnectionName");
conn.setOdcFile("C:\\Users\\MyDefaulConnection.odc");

// Change the Command Type, Command and Connection String
const dbConn = conn;
dbConn.setCommandType(AsposeCells.OLEDBCommandType.SqlStatement);
dbConn.setCommand("Select * from AdminTable");
dbConn.setConnectionString("Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False");

// Save the workbook
workbook.save(path.join(dataDir, "output_out.xlsx"));