我已经使用 office api 创建了一个表格,我不想在上面有任何样式。默认情况下,当使用 office api 创建表时,我看到应用了默认表样式,我只想要纯数据。
解决方法 1. 我尝试使用某种颜色更改边框颜色和范围填充区域,使其看起来没有任何样式。
我有两个问题要问。1.使用office.js apis创建时如何删除excel表格上的默认样式2.如果第一个不可能,那么如何给范围不加边框,
我尝试使用https://github.com/OfficeDev/office-js-docs/blob/master/reference/excel/rangeborder.md中所述的细线和细边框
但看起来发际线不起作用,发际线和细线给出相同的边界
Excel.run(function (ctx) {
var sheetName = "Sheet1";
var rangeAddress = "A1:F8";
var range = ctx.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range.format.borders.getItem('InsideHorizontal').weight = "Hairline";
range.format.borders.getItem('InsideVertical').weight = "Hairline";
range.format.borders.getItem('EdgeBottom').weight = "Hairline";
range.format.borders.getItem('EdgeLeft').weight = "Hairline";
range.format.borders.getItem('EdgeRight').weight = "Hairline";
range.format.borders.getItem('EdgeTop').weight = "Hairline";
//range.format.borders.getItem('InsideHorizontal').style = "No Border";
//range.format.borders.getItem('InsideVertical').style = 'No Border';
//range.format.borders.getItem('EdgeBottom').style = 'No Border';
//range.format.borders.getItem('EdgeLeft').style = 'No Border';
//range.format.borders.getItem('EdgeRight').style = 'No Border';
//range.format.borders.getItem('EdgeTop').style = 'No Border';
range.format.borders.getItem('InsideHorizontal').color = 'Gray';
range.format.borders.getItem('InsideVertical').color = 'Gray';
range.format.borders.getItem('EdgeBottom').color = 'Gray';
range.format.borders.getItem('EdgeLeft').color = 'Gray';
range.format.borders.getItem('EdgeRight').color = 'Gray';
range.format.borders.getItem('EdgeTop').color = 'Gray'; return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
我的代码看起来与此类似。
请指导我如何从表格中删除边框