开发者

How to deserialize Excel file to 2-dimensional array?

开发者 https://www.devze.com 2023-04-12 03:46 出处:网络
I have an Excel wor开发者_Python百科ksheet where all the fields are strings. I would like to de-serialize all the data from the excel file to a 2D array (matrix).

I have an Excel wor开发者_Python百科ksheet where all the fields are strings. I would like to de-serialize all the data from the excel file to a 2D array (matrix).

Any ideas how I can get started?


If your Excel file is built like a table, you can use ADO.NET to access your Excel file like a database and pull your data via SQL.
Excel 97-2003: http://connectionstrings.com/excel#p21
Excel 2007+: http://connectionstrings.com/excel-2007#p20


If you're trying to open a .xlsx file, you should use the Open Xml SDK.

If you're trying to open a .xls file, I recommend saving yourself some headaches and checking out filehelpers.sourceforge.net.


You can do

Sub ReadArray()

Dim MyArray As Variant

MyArray = Sheets(1).Range("A1").CurrentRegion

End Sub

[]'s

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号