vendredi 12 septembre 2014

c# / lire fichier xlsx / dk.xlsxreader

            FileStream f = File.Open(@"C:\MYFILE.xlsx", FileMode.Open);

            XlsxReader xr = new XlsxReader(f);
            TRJsonFactoryProcessor.XlsxReader.Sheet s = xr.FirstSheet;
            log(s.Rows.Count().ToString());

            int rowCounter = 0;
            IEnumerable<IEnumerable<KeyValuePair<string, string>>> ikvp = s.Rows;
            foreach (IEnumerable<KeyValuePair<string, string>> kvp in ikvp)
            {
                string strText = string.Empty;

                rowCounter++;

                IEnumerable<KeyValuePair<string, string>> currentRow = kvp;

                List<string> json_content = new List<string>();
                int currentColIndex = 0;
                foreach (KeyValuePair<string, string> currentCell in currentRow)
                { ... here you access your data ... }
            }