0

I have added sync fusion package to my android project using nuget installer with the below command.

install-package Syncfusion.Xamarin.XlsIO -sourcehttp://nuget.syncfusion.com/xamarin

The worksheet interface contains reference only to import data, the methods to import data table are not found. Should the sync fusion package be added in any other way? Please help on this

Divya
  • 1
  • 4
  • any other way? You can also add by right clicking on packages in your project and selecting add packages. https://help.syncfusion.com/xamarin/introduction/download-and-installation – Drunken Daddy Nov 27 '16 at 18:39

1 Answers1

0

XlsIO provides portable class library for Xamarin platform. As the data table is not supported in portable platform, so XlsIO doesn’t support import data table into worksheet. However, you can convert the data table into an enumerable object and then import that object into worksheet using Worksheet.ImportData() method.

To know more about import data into worksheet, kindly refer the following documentation.

Documentation: https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-business-objects

However this requirement can be achieved by an workaround. The sample can be downloaded from the following link

Sample link : http://www.syncfusion.com/downloads/support/directtrac/general/ze/XamarineSample1612899830.zip

Kindly refer the following code snippet for your reference

Code Snippet:

private IEnumerable<dynamic> GetDynamicData(DataTable table) 
{
    List<dynamic> dynamicData = new List<dynamic>(table.Rows.Count); 

    foreach (DataRow row in table.Rows) 
    { 
        ExpandoObject expando = new ExpandoObject(); 
        foreach (DataColumn column in table.Columns) 
        { 
            (expando as IDictionary<string, object>).Add(column.ColumnName, row[column]); 
        } 
        dynamicData.Add(expando); 
    } 

    return dynamicData; 
} 

I work for Syncfusion.

Regards,

Abirami