【问题标题】:How does the range function getCellProperties in the JavaScript excel API work?JavaScript excel API 中的范围函数 getCellProperties 是如何工作的?
【发布时间】:2019-06-27 15:35:49
【问题描述】:

我特别想在一个数组上调用这个函数:

https://docs.microsoft.com/en-us/javascript/api/excel/excel.range?view=office-js#getcellproperties-cellpropertiesloadoptions-

从文档中确实不清楚要完成这项工作需要什么。我肯定在这里遗漏了一些东西。以下是我的代码的当前状态。

我还检查了我正在构建的加载项是否在使用 API v1.9 的 Excel 版本中运行。

我尝试设置与 cellPropertiesLoadOptions 描述的接口匹配的各种对象 - 但再次不确定文档中的实际要求是什么。

async function getFormatsForCellRange () {
  return await Excel.run(async context => {
    const table = await context.workbook.tables.getItem(observationConst.TABLE_NAME)
    const range = table.getRange()
    const cellProperties = range.getCellProperties()
    console.log(cellProperties)
  })
}

文档说明调用 getCellProperties 的结果应该是一个二维数组。

【问题讨论】:

  • 抱歉,我的意思是在 Range 上调用 getCellProperties。
  • 请查看stackoverflow.com/a/55466639/678505上的答案,其中给出了API调用的示例。
  • 非常感谢,我以为我遗漏了一些简单的东西。

标签: office-js


【解决方案1】:
var actualData = rangeSrc.getCellProperties({
 format: {
    font: {
           bold: true,
           color: true,
           fill: true
           italic: true,
           name: true,
           underline: true,
           size: true,
           strikethrough: true,
           subscript: true,
           superscript: true,
           tintAndShade: true
    }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    相关资源
    最近更新 更多