I am trying to capture a spreadsheet data in to a 2D array. I am using VSTO.
int rc = 1048576;
int cc = 1638;
string[,] arr = new string[rc, cc];
The last line throws Out of Memory exception. I would like to show message telling the user only 'X' elements can be captured.
Checked MSDN and there is a row count limit mentioned of 16,777,216. No Column count limitation for datatable. Cant find limit either for 2D array.
My issue is not with WHY the exception. What I am looking for is if you are doing VSTO development, and had to capture a worksheet in a DataTable to perform In-Memory joins etc, you will need to do this:
string[,] arr = new string[rc, cc];
Microsoft.Office.Interop.Excel.Range selection
arr = selection.Value as string[,];
and then copy the data from that array to datatable. Now what will be the ideal limit for number of elements a user should select. So I can set that rowcount/columncount lmits and display message when selection exceeds this criteria.