读取 excel 并在 typescript 中填充二维数组

Posted

技术标签:

【中文标题】读取 excel 并在 typescript 中填充二维数组【英文标题】:Read excel and populate 2 dimensional array in typescript 【发布时间】:2021-05-24 04:06:30 【问题描述】:

我想在 Excel 工作表中读取一个简单的表格(x 行,y 列)并在 typescript 中填充一个二维数组。如下所示:

client_id orderid 1 : 12 3 45 78 97 2 : 67 89 12 3 : 7 90 23

你知道一个好的excel库吗?谢谢

问候, 蒂蒂

【问题讨论】:

【参考方案1】:

您只需指定表名,然后可以使用getRange().getValues() 将表中的值捕获为 2 天数组。示例:

function main(workbook: ExcelScript.Workbook) 
 const theTableName:string = "table1"; // or whatever the name is
 var theTable = workbook.getTable(theTableName);
 var allValues = theTable.getRange().getValues();
 // allVallues is now an 2-day array with values

【讨论】:

以上是关于读取 excel 并在 typescript 中填充二维数组的主要内容,如果未能解决你的问题,请参考以下文章