Exemple #1
0
        private void refreshButton_Click(object sender, EventArgs e)
        {
            try
            {
                Worksheet ws = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;

                var columnCount = ws.UsedRange.Columns.Count;
                var rowCount    = ws.UsedRange.Rows.Count;
                var lists       = DataTableExt.RangeToLists(ws.UsedRange, columnCount);
                Account.ColumnIndexMapper = new Dictionary <string, int>();
                for (int i = 0; i < lists[0].Count; i++)
                {
                    Account.ColumnIndexMapper.Add(lists[0][i], i);
                }
                for (var i = 1; i < lists.Count; i++)
                {
                    var login = lists[i][Account.ColumnIndexMapper["login"]];
                    if (login.ToLower() == "y")
                    {
                        ws.Cells[i + 1, Account.ColumnIndexMapper["login"] + 1].Value = "r";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void LoadSetting()
        {
            Worksheet ws          = Globals.ThisAddIn.Application.ActiveWorkbook.Sheets["setting"];
            var       columnCount = ws.UsedRange.Columns.Count;
            var       rowCount    = ws.UsedRange.Rows.Count;
            var       lists       = DataTableExt.RangeToLists(ws.UsedRange, columnCount);

            ExePath    = lists[0][1];
            ArgsPath   = lists[1][1];
            TaskPath   = lists[2][1];
            PayeePath  = lists[3][1];
            StatusPath = lists[4][1];
            //MessageBox.Show(String.Join(",", lists[0]));
        }
Exemple #3
0
        private List <Account> LoadAccounts()
        {
            try
            {
                Worksheet ws = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;

                var columnCount = ws.UsedRange.Columns.Count;
                var rowCount    = ws.UsedRange.Rows.Count;
                var lists       = DataTableExt.RangeToLists(ws.UsedRange, columnCount);
                Account.ColumnIndexMapper = new Dictionary <string, int>();
                for (int i = 0; i < lists[0].Count; i++)
                {
                    Account.ColumnIndexMapper.Add(lists[0][i], i);
                }
                var accounts = new List <Account>();
                for (var i = 1; i < lists.Count; i++)
                {
                    var account = new Account
                    {
                        email    = lists[i][Account.ColumnIndexMapper["email"]],
                        phone    = lists[i][Account.ColumnIndexMapper["phone"]],
                        password = lists[i][Account.ColumnIndexMapper["password"]],
                        mode     = lists[i][Account.ColumnIndexMapper["mode"]],
                        pages    = lists[i][Account.ColumnIndexMapper["pages"]],
                        category = lists[i][Account.ColumnIndexMapper["category"]],
                        login    = lists[i][Account.ColumnIndexMapper["login"]],
                        //StatusFilePath = textBox3.Text,
                        discountRate = Double.Parse(lists[i][Account.ColumnIndexMapper["discount rate"]]),
                        RowIndex     = i
                    };
                    accounts.Add(account);
                }
                return(accounts);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                MessageBox.Show("无权限");
            }
            return(null);
        }