Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Can we use "Datatable" or "Array" object to export to EXcel??
posted

Hi.

With Microsoft interop Excel object, we can use this code( Excel.Range.value with Array )

---------------------------------------------------------------------------------------------------------------------

 DataSet dsExcel = MakeDataSet() 

 int DtColLength; 

 int DtRowLength;

  Excel.Range cel = worksheet.get_Range(app.ActiveCell, app.ActiveCell.get_Offset(DtRowLength - 1, DtColLength - 1)); //starting point

           string[,] MyArray = new string[DtRowLength, DtColLength        

              for (int i = 1; i < DtColLength + 1; i++)
                {
                    for (int j = 1; j < DtRowLength + 1; j++)
                    {
                        MyArray[j - 1, i - 1] = dsExcel.Tables[0].Rows[j - 1][i - 1].ToString();
                    }
                }
                cel.Value2 = MyArray;// Databind
                cel.Columns.AutoFit();  

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

but I have no idea with "Infragistics.Excel.Workbook" object.

Thanks in advance.

Parents Reply Children
No Data