Archive for the ‘Code’ Category

Best Practices for disposing windows SharePoint objects: http://msdn.microsoft.com/en-us/library/aa973248.aspx

Using Solution Packages to Deploy Features and Content in Windows SharePoint Services 3.0: http://msdn.microsoft.com/en-us/library/dd348394.aspx

Troubleshooting SPSite/SPWeb leaks in WSS v3 and MOSS 2007 :  http://blogs.technet.com/stefan_gossner/archive/2008/05/07/troubleshooting-spsite-spweb-leaks-in-wss-v3-and-moss-2007.aspx

SharePoint Dispose() patterns by example: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx

Read Full Post »

A Method to return Sheets Names in an EXCEL file using C# ADO.NET

        public static List<string> GetSheetsNames(string path)
            List<string> sheets = new List<string>();

            string connectionString = @”Provider=Microsoft.Jet.OLEDB.4.0;” +
                “Data Source=” + path + “;” +
                @”Extended Properties=””Excel 8.0;HDR=YES;”””;

            DbProviderFactory factory = DbProviderFactories.GetFactory(“System.Data.OleDb”);
            DbConnection connection = factory.CreateConnection();
            connection.ConnectionString = connectionString;
            DataTable tbl = connection.GetSchema(“Tables”);
            foreach (DataRow row in tbl.Rows)
                string sheetName = (string)row[“TABLE_NAME”];
                if (sheetName.EndsWith(“$”))
                    sheetName = sheetName.Substring(0, sheetName.Length – 1);
            return sheets;
Note that the schema has each sheet name ending with $. you must have the $ in the sheet name in order to read from or write to the excel using ADO.NET

Read Full Post »

« Newer Posts