I'm developing an Excel Add-in that pulls data from an on-premise Microsoft SQL Server into an Excel worksheet. To authenticate into the server, users would use Microsoft Authentication with the credentials logged into their Windows computer - so that data policies in the SQL server would suffice for data governance.
I was able to read the Microsoft SQL Server in a node.js process using my Windows user credentials with the script below:
const sql = require("msnodesqlv8");
const connectionString = "server=...;Database=...;Trusted_Connection=Yes;Driver={SQL Server}";
const query = 'SELECT * FROM ...';
sql.query(connectionString, query, (err, rows) => {
console.log(rows);
});
However, when I tried to use the msnodesqlv8
module in my Excel Add-in React.js project, the Add-in breaks. From this stack overflow question, it seems that this is because msnodesqlv8
is a server library, which does not work in a browser context.
I am hesitant to create a separate on-premise server because it might make Windows authentication a lot less direct than it is as in the script above.
Is it possible for an Excel Add-in to run a node.js process? How do I read from a Microsoft SQL server in an Excel Add-in? Is it possible to reuse the Data Connection Wizard from the Excel Data Tab in an Excel Add-in?
An Excel add-in is a web application. If it is possible to access an SQL database from client-side JavaScript in a web application, then it can be done in an add-in too. If not, then not. I recommend that you search for information about whether it is possible to access an SQL database from client-side JavaScript.