I've created a Excel task pane app with VS2015 (Excel Web Addin) and Office tools.
On the basis of this article, I've also created an ms sql database, including the models and controllers.
How can I populate the contents of the table Movie in Excel?
This is the controller:
namespace DatabaseWeb.Controllers { public class controllerMovie : Controller { private modelMovie db = new modelMovie(); // GET: controllerMovie public ActionResult Index() { return View(db.Movies.ToList()); }
This is the home.js (not working)
function loadSampleData() { var values = getMovies(); // Run a batch operation against the Excel object model Excel.run(function (ctx) { // Create a proxy object for the active sheet var sheet = ctx.workbook.worksheets.getActiveWorksheet(); // Queue a command to write the sample data to the worksheet sheet.getRange("B3:D5").values = values; // Run the queued-up commands, and return a promise to indicate task completion return ctx.sync(); }) .catch(errorHandler); } function getMovies() { $.ajax({ type: "GET", url: "Controllers/controllerMovie", success: function (result) { return result; }, error: function (response) { return "fout"; } }); }
Can I request the table Movies data via ajax and what is the exact syntax?