vuexcel-utils
Version:
Utils for vuexcel
40 lines • 1.46 kB
JavaScript
export default function (options) {
if (options === void 0) { options = null; }
// 转换传入的options
if (typeof options === 'string') {
options = {
promptText: options
};
}
/**
* 调用Office的系统对话框
* 要获取区域只能使用Matrix
* */
// 正式获取
return new Promise(function (resolve, reject) {
Office.context.document.bindings.addFromPromptAsync(Office.BindingType.Matrix, options, function (asyncResult) {
if (asyncResult.status === 'succeeded') {
Excel.run(function (ctx) {
var id = asyncResult.value.id;
var binding = ctx.workbook.bindings.getItem(id);
var range = binding.getRange();
range.load('address');
return ctx.sync()
.then(function () {
Office.context.document.bindings.releaseByIdAsync(asyncResult.value.id);
resolve(range.address);
});
})
.catch(function (e) {
reject(e);
Office.context.document.bindings.releaseByIdAsync(asyncResult.value.id);
});
// 删除刚刚绑定的id
}
else {
reject(asyncResult);
}
});
});
}
//# sourceMappingURL=prompt.js.map