Syncfusion.XlsIO.Base
Example 


Description Property (IConnection)

Represent the connection description.
Syntax
'Declaration
 
Property Description As String
'Usage
 
Dim instance As IConnection
Dim value As String
 
instance.Description = value
 
value = instance.Description
string Description {get; set;}
Example
The following code illustrates how description for connection can be set and accessed.
using Syncfusion.XlsIO;
using System;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook= application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Set Connection string for DataSource
            string ConnectionString = "OLEDB;Provider=Microsoft.JET.OLEDB.4.0;Password=\"\";User ID=Admin;Data Source=AccessDB.mdb";
            
            //Add a connection to the workbook
            IConnection Connection = workbook.Connections.Add("Connection1", "Sample connection with MsAccess", ConnectionString, "", ExcelCommandType.Sql);
            
            //Add a QueryTable to sheet object
            IListObject table = worksheet.ListObjects.AddEx(ExcelListObjectSourceType.SrcQuery, Connection, worksheet.Range["A1"]);
            
            //Set Command Text for the Connection
            table.QueryTable.CommandText = "Select * from tbltest";
            
            // Import data to the sheet from the database
            table.Refresh();
            
            //Get Description
            Console.WriteLine(Connection.Description);
            
            //Apply AutoFit
            worksheet.UsedRange.AutofitColumns();
            
            //Save and Dispose
            workbook.SaveAs("Tables.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
//Output will be
//Sample connection with MsAccess
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also