Пример #1
0
        /// <summary>
        /// Extract the data from :
        /// - Excel table
        /// and create a csv file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDynamicExtract_Click(object sender, RibbonControlEventArgs e)
        {
            var excelHandle = AddInUtils.GetExcelWindowHandle();

            //userInputOption = GetUserInputOption(excelHandle);
            bool secondWindowResult = false;

            // ask for data input type
            using (var frmDESelectInput = new frmDESelectInput())
            {
                do
                {
                    if (frmDESelectInput.ShowDialog(excelHandle) == DialogResult.Cancel)
                    {
                        frmDESelectInput.Close();
                        return;
                    }

                    //frmDESelectInput.Hide();

                    // get what the user selected from the frmDESelectInput
                    // 1 = Tabular Form radio button
                    userInputOption = frmDESelectInput.UserSelection;

                    // user didn't press "Cancel" on the data input type form
                    if (userInputOption > 0)
                    {
                        switch (userInputOption)
                        {
                        // user selected the Tabular Form radio button
                        case 1:
                            // the user chose "Yes"
                            processTabularFormInput(excelHandle, frmDESelectInput);

                            break;

                        // user selected option 2 radio button
                        case 2:
                            processOption2Input(excelHandle, frmDESelectInput);
                            break;
                        }
                    }
                }while (_secondWindowClosed == true);

                frmDESelectInput.Close();
            }
        }