Esempio n. 1
0
        // load a single sheet from a book
        void _btnLoadSheet_Click(object sender, System.EventArgs e)
        {
            // choose file
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = "xls";
            dlg.FileName   = "*.xls";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // clear data source, if any
            _flex.DataSource = null;
            string[] sheets = _flex.LoadExcelSheetNames(dlg.FileName);
            Console.WriteLine("Found {0} sheets in this book.", sheets.Length);
            foreach (string sheet in sheets)
            {
                Console.WriteLine(" - {0}", sheet);
            }

            // load the first sheet in the book
            FileFlags flags = (_chkFixed.Checked)? FileFlags.IncludeFixedCells: FileFlags.None;

            _flex.LoadGrid(dlg.FileName, FileFormatEnum.Excel, flags);
        }