exceljs - Excel js,无法进行休息通话
问题描述
我们正在使用 Excel JS 开发一个 excel 插件。用java编写并部署在wildfy服务器中的服务器代码。
通过 excel 插件,我无法进行其余调用来检索用户数据。目的是执行登录操作并检索存储在服务器中的excel字节格式并显示在excel中。
有什么建议么?以下是我们迄今为止尝试过的示例代码。
索引.html
<body class="ms-font-m ms-welcome">
<div id="content-header">
<div class="padding">
<h1>Welcome</h1>
</div>
</div>
<div id="content-main">
<button id="ping-server3" onclick="pingServer2()">Ping server2</button>
<p id="demo"></p>
<p id="demo1"></p>
<button id="ping-server">Ping server</button>
<p></p>
<div class="padding">
<form>
<div class="container">
<label for="uname"><b>Username</b></label>
<input id="uname" type="text" placeholder="Enter Username"
name="uname" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw"
required>
<button id="login-button" onclick="pingServer2()">Login</button>
</div>
<div class="container" style="background-color:#f1f1f1">
<span class="psw"><a href="#">Need password help?</a></span>
</div>
</form>
</div>
</div>
<script type="text/javascript" src="node_modules/core-js/client/core.js">
</script>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js">
</script>
<script type="text/javascript" src="node_modules/office-ui-fabric-
js/dist/js/fabric.js"></script>
<script type="text/javascript" src="app.js" ></script>
<script type="text/javascript" src="utility.js" ></script>
</body>
应用程序.js
(function () {
Office.initialize = function (reason) {
$(文档).ready(函数 () {
if (!Office.context.requirements.isSetSupported('ExcelApi', 1.7)) {
alert("ERROR");
console.log('Sorry. The tutorial add-in uses Excel.js APIs that are
not available in your version of Office.');
}
$('#login-button').click(createTable);
});
};
function createTable() {
axios({
method: 'post',
url: 'http://localhost:8183/x/operation.do?&operationId=LOGIN_USER',
data: {emailAddress : 'x@xyz.com,password : '123@asdA'}
})
.then(response => {
$('#demo').innerHTML = response.data;
content=response.data.uiUser.createdBy;
$('#demo1').innerHTML = content;
})
.catch(error => {
$('#demo').innerHTML = response.status;
});
Excel.run(function (context) {
const currentWorksheet =
context.workbook.worksheets.getActiveWorksheet();
const expensesTable = currentWorksheet.tables.add("A1:D1", true
/*hasHeaders*/);
expensesTable.name = "ExpensesTable";
expensesTable.getHeaderRowRange().values = [["Date", "Merchant",
"Category", "Amount"]];
expensesTable.rows.add(null /*add at the end*/, [["1/1/2017", "The
Phone Company", "Communications", "120"], ["1/2/2017", "Northwind
Electric Cars", "Transportation", "142.33"], ["1/5/2017", "Best For You
Organics Company", "Groceries", "27.9"], ["1/10/2017", "Coho Vineyard",
"Restaurant", "33"], ["1/11/2017", "Bellows College", "Education",
"350.1"], ["1/15/2017", "Trey Research", "Other", "135"], ["1/15/2017",
"Best For You Organics Company", "Groceries", "97.88"]]);
expensesTable.columns.getItemAt(3).getRange().numberFormat =
[['€#,##0.00']];
expensesTable.getRange().format.autofitColumns();
expensesTable.getRange().format.autofitRows();
return context.sync();
}).catch(function (error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
}
})
解决方案
您尝试发布的 URL 是http格式:
http://localhost:8183/x/operation.do?&operationId=LOGIN_USER
Excel AddIn 使用https部署。如果您使用 F12 调试器工具检查加载项,您将看到混合内容错误。
混合内容:“ https://Your_AddIn_Url ”处的页面是通过 HTTPS 加载的,但请求了不安全的资源“ http://localhost:8183/x/operation.do?&operationId=LOGIN_USER ”。此请求已被阻止;内容必须通过 HTTPS 提供。
使用 https 端点应该可以解决您的问题。
推荐阅读
- javascript - 单击返回箭头和日期返回;单击前进箭头和日期以前进
- python - 从类体调用类方法
- android - android中websockets的证书固定
- python - 网页抓取时面临“''block block-block-content block-block-contente1ace621-3e0d-4b51-848d-aa830cd4a1c5”''的问题
- xcode - 找不到模块映射文件'/Users/"my_flutter_project_path"/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap'?
- json - 在Java中将JSON字符串转换为Avro GenericRecord(生成的Schema是通过相同的Json字符串)
- android - 获取 java.lang.IllegalArgumentException: width and height must be > 0 error while initializing Mat in android
- c# - 如果存在重复节点,如何查找节点
- flutter - 如何将地图列表获取到日历?[扑]
- postgresql - 在表中添加列,按组进行值分区