首页 > 解决方案 > 如何使用 Excel 脚本将动态范围转换为表格?

问题描述

我是使用带有电源自动化功能的 excel 脚本的新手。试图将一些数据转换为表格。问题是每次的行数都会不同。

我已经在 excel 桌面上完成了这项工作,但不知道如何使用 excel 脚本来完成。

标签: excelpower-automateoffice-scripts

解决方案


问题是在 excel(Office 脚本)中找到使用的范围。一旦你有了它,我假设你知道如何将它转换为表格。

function main(workbook: ExcelScript.Workbook) 
{
  // Get the current, active worksheet.
  let currentWorksheet = workbook.getActiveWorksheet();

  // Get the range containing all the cells with data or formatting.
  let usedRange = currentWorksheet.getUsedRange();

  // Log the range's address to the console.
  console.log(usedRange.getAddress());
}

链接供您参考


推荐阅读