是否有JavaScript API来格式化嵌入式Excel文件中的单元格?我们能够通过EWS DOM API格式化单元格,但这似乎不稳定且依赖于浏览器。
答案 0 :(得分:0)
是的,绝对有可能。这里有些例子。
function Format1() {
var tableData = new Office.TableData();
Office.select("bindings#MyTableXXX").setFormatsAsync(
[
//row 1
{ cells: { row: 0, column: 2 }, format: { alignHorizontal: "right", fontSize: 15 } },
//row 2
{ cells: { row: 1, column: 0 }, format: { numberFormat: "dd-mmm-yy", fontStyle: "bold" } },
{ cells: { row: 1, column: 1 }, format: { fontColor: "red", fontStyle: "bold", numberFormat: "#,###.00", borderColor: "blue" } },
//row 3
{ cells: { row: 2 }, format: { height: 30 } },
//Whole table: 'Office.Table.All', 'Office.Table.Data' (no headers) and 'Office.Table.Headers'
{ cells: Office.Table.All, format: { borderStyle: "dotted" } },
],
function (asyncResult) {
//NOW DO OUTPUT OR ERROR
if (asyncResult.status === "failed") {
writeToPage('Error Format1: ' + asyncResult.error.message, 3);
}
else {
writeToPage('Table cell formats changed', 1);
}
});
}
有关详细信息,请访问www.microsoft-office-add-ins.com