Dump a two-dimensional array into an XLSheet

Posted by: javier.garcia on 20 January 2022, 2:11 am EST

  • Posted 20 January 2022, 2:11 am EST

    Hello, is it possible to dump a two-dimensional array of integers directly into an XLSheet object, or is it necessary to dump the values ​​cell by cell?

    I've tried to see if it's possible using XLCellRange objects, but I haven't been able to find any information or examples.

    Thank you!
  • Marked as Answer

    Replied 20 January 2022, 11:20 pm EST

    Hi Javier,

    We are sorry but C1Excel doesn't have provide any method to load a 2d array so you need to do it cell by cell.

    However, you can take a look at our latest excel library which is more feature-rich, faster & customizable as compared to C1Excel. You can download the GrapeCity.Documents.Excel NuGet package to get the library and implement your requirement as follows:

    GrapeCity.Documents.Excel.Workbook workbook = new GrapeCity.Documents.Excel.Workbook();
    var array2d = new int[2, 2]
    {2, 3},
    {2, 4},
    workbook.ActiveSheet.Range[0, 0, array2d.GetLength(0), array2d.GetLength(1)].Value = array2d;

    You can refer here for more information regarding our latest excel library.


    JFYI, our new excel library is a standalone product so you would need to purchase a license for the same.

    Best Regards,
  • Replied 23 January 2022, 7:47 pm EST

    Hello, thanks for the answer. I'll take a look at the documentation for the new library you suggest. Thanks a lot.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels