Ejemplo n.º 1
0
        private void BtnOpenSelected_Click(object sender, RoutedEventArgs e)
        {
            //Excel.Application xlApp = new Excel.Application();

            string password = TextBoxPassword.Text;
            string campaign = TextBoxSearchCriteria.Text;
            string filePath = "";

            try
            {
                filePath = listBoxSearchResults.SelectedItem.ToString();
            }catch (NullReferenceException)
            {
                MessageBox.Show("Please select a listbox item");
                return;
            }
            // Excel.Application is too slow. Let's try something else.

            xlApp = new Excel.Application();

            ExcelCampaign thisCampaign = new ExcelCampaign(xlApp, password, filePath, campaign, "June 2018");

            MessageBox.Show(thisCampaign.FindMonthColumnIndexByHeader("Status").ToString());

            thisCampaign.Close();
            xlApp.Quit();
        }
Ejemplo n.º 2
0
        public bool OpenCampaign(string filePath, string password, string title, string monthSheet)
        {
            // Let's try opening this workbook
            try
            {
                selectedCampaign = new ExcelCampaign(xlApp, filePath, password, title, "May 2018");
            }
            catch (Exception ex)
            {
                Debug.Write("Could not open excel workbook " + title + "\n" + ex.ToString());
                xlApp.Quit();
                return(false);
            }

            return(true);
        }