Is there a faster way to parse an excel document with Powershell?

后端 未结 2 1543
一个人的身影
一个人的身影 2021-02-05 18:13

I\'m interfacing with an MS Excel document via Powershell. There is a possibility of each excel document of having around 1000 rows of data.

2条回答
  •  长情又很酷
    2021-02-05 18:22

    If the data is static (no formulas involved, just data in cells), you can access the spreadsheet as an ODBC data source and execute SQL (or at least SQL-like) queries against it. Have a look at this reference for setting up your connectionstring (each worksheet in a workbook will be a "table" for this exercise), and use System.Data to query it the same as you would a regular database (Don Jones wrote a wrapper function for this which may help).

    This should be faster than launching Excel & picking through cell by cell.

提交回复
热议问题