Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, June 14, 2012

Retrieve Excel Workbook Sheet Names


C# - Retrieve Excel Workbook Sheet Names



Originally posted on 

/// <summary>
/// This mehtod retrieves the excel sheet names from an excel workbook.
/// </summary>
/// <param name="excelFile">The excel file.</param>
/// <returns>String[]</returns>
private String[] GetExcelSheetsNames(string excelFile)
{

    OleDbConnection objConn = null;
    System.Data.DataTable dt = null;

    try
    {
        // Connection String. Change the excel file to the file you will search.
        String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + excelFile + ";Extended Properties=Excel 8.0;";
        // Create connection object by using the preceding connection string.
        objConn = new OleDbConnection(connString);
        // Open connection with the database.
        objConn.Open();
        // Get the data table containg the schema guid.
        dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

        if (dt == null)
        {
            return null;
        }

        String[] excelSheets = new String[dt.Rows.Count];
        int i = 0;

        // Add the sheet name to the string array.
        foreach (DataRow row in dt.Rows)
        {
            excelSheets[i] = row["TABLE_NAME"].ToString();
            i++;
        }

        // Loop through all of the sheets if you want too...
        for (int j = 0; j < excelSheets.Length; j++)
        {
            // Query each excel sheet.
        }

        return excelSheets;
    }
    catch (Exception ex)
    {
        return null;
    }
    finally
    {
        // Clean up.
        if (objConn != null)
        {
            objConn.Close();
            objConn.Dispose();
        }
        if (dt != null)
        {
            dt.Dispose();
        }
    }
}

Wednesday, June 6, 2012

How to deploy web application that is using SAMS certificate to authenticate site


How to deploy web application that is using SAMS certificate to authenticate site



Permissions
1.       For Windows 2008 server, grant ‘read/write’ permission to user everyone for folder ‘C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys’.
2.       For Windows 2003 server, grant ‘read/write’ permission to user everyone for folder ‘C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys’.
3.       Allow firewall to access URL ‘https: //api.sams.itm.test.semantico.net’.  
Installation of client certificate in Personal folder

1.       Open a Command Prompt window.
2.       Type mmc and press the ENTER key. Note that to view certificates in the local machine store; you must be in the Administrator role.
3.       On the File menu, click Add/Remove Snap In.
4.       Click Add.
5.       In the Add Standalone Snap-in dialog box, select Certificates.
6.       Click Add.
7.       In the Certificates snap-in dialog box, select Computer account and click Next.
8.       Now highlight personal
9.       Right click all tasks import.
10.    Select p12 certificate given by Semantico.

Installation of client certificate in Trusted Root Certification Authorities folder

1.       Open a Command Prompt window.
2.       Type mmc and press the ENTER key. Note that to view certificates in the local machine store; you must be in the Administrator role.
3.       On the File menu, click Add/Remove Snap In.
4.       Click Add.
5.       In the Add Standalone Snap-in dialog box, select Certificates.
6.       Click Add.
7.       In the Certificates snap-in dialog box, select Computer account and click Next.
8.       Now highlight Trusted Root Certification Authorities
9.       Right click Certificates, all tasks import.
10.    Select p12 certificate given by Semantico


Installation of MSXML4