Beispiel #1
0
        public void RemoveWorsheet(SheetTab sheetTab)
        {
            Excel.Worksheet worksheet = (Excel.Worksheet)Application.ActiveWorkbook.Worksheets[sheetTab.Worksheet.Index];
            worksheet.Delete();

            NumTabs--;
        }
Beispiel #2
0
        public void AddWorsheet(SheetTab sheetTab)
        {
            sheetTab.Worksheet = NumTabs == 1 ? (Excel.Worksheet)Application.ActiveWorkbook.Worksheets.Add(missing, missing, missing, missing)
                : (Excel.Worksheet)Application.ActiveWorkbook.Worksheets.Add(missing, Application.ActiveWorkbook.Worksheets[NumTabs - 1], missing, missing);

            sheetTab.Worksheet.Name = sheetTab.Name;

            NumTabs++;
        }
Beispiel #3
0
        public void InsertTab(int index, string title)
        {
            var tab = new SheetTab(this.rgView, this.Context)
            {
                Text = title,
            };

            this.innerView.AddView(tab);

            UpdateTabWidthForText(tab);
        }
Beispiel #4
0
        public void UpdateTab(int index, string title, Color backgroundColor, Color foregroundColor)
        {
            SheetTab tab = this.GetChildAt(index) as SheetTab;

            if (tab != null)
            {
                tab.Text = title;
                tab.SetTextColor(foregroundColor);
                tab.SetBackgroundColor(backgroundColor);

                UpdateTabWidthForText(tab);
            }
        }
Beispiel #5
0
        public void OnBtnAddWorksheetClick()
        {
            AddWorksheet addWorsheet = new AddWorksheet();

            addWorsheet.ShowDialog();

            if (addWorsheet.DialogResult.Value)
            {
                SheetTab sheetTab = new SheetTab()
                {
                    Name = addWorsheet.ViewModel.Name
                };
                SheetTabs.Add(sheetTab);
                _thisAddIn.AddWorsheet(sheetTab);
            }
        }
Beispiel #6
0
            protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
            {
                int x = 0;

                for (int i = 0; i < this.ChildCount; i++)
                {
                    SheetTab tab = this.GetChildAt(i) as SheetTab;

                    if (tab != null)
                    {
                        int height = bottom - top;
                        tab.Layout(x, 0, x + tab.TabWidth, height);
                        x += tab.TabWidth;
                    }
                }
            }
Beispiel #7
0
        private void UpdateTabWidthForText(SheetTab tab)
        {
            using (var p = new Paint())
            {
                p.TextSize = tab.TextSize;

                Rect rect = new Rect();
                p.GetTextBounds(tab.Text, 0, tab.Text.Length, rect);

                tab.TabWidth = (int)Math.Round(rect.Width() + 10.0f * this.rgView.baseScale);

                if (tab.TabWidth < 70 * this.rgView.baseScale)
                {
                    tab.TabWidth = (int)Math.Round(70 * this.rgView.baseScale);
                }
            }

            this.UpdateContainerWidth();
        }
Beispiel #8
0
        public void AddDataBlock(SheetTab sheetTab, SheetBlock sheetBlock)
        {
            try
            {
                if (sheetBlock.Type == "input" || sheetBlock.Type == "single")
                {
                    int nColumns = sheetBlock.SheetColumns.Count;
                    if (nColumns <= 0)
                    {
                        return;
                    }
                    sheetTab.Worksheet.Cells[i, j] = sheetBlock.Name;
                    i++;
                    Excel.Range bBegin = (Excel.Range)sheetTab.Worksheet.Cells[i, j];
                    Excel.Range bEnd   = (Excel.Range)sheetTab.Worksheet.Cells[i, nColumns];

                    Excel.ListObject interopList = sheetTab.Worksheet.ListObjects.Add(
                        Excel.XlListObjectSourceType.xlSrcRange, sheetTab.Worksheet.Range[bBegin, bEnd]);
                    interopList.Name       = sheetBlock.Name != null ? sheetBlock.Name : "";
                    interopList.ShowTotals = true;

                    foreach (SheetColumn sheetColumn in sheetBlock.SheetColumns)
                    {
                        interopList.ListColumns[j].Name = sheetColumn.ModelAttribute.Name;
                        interopList.ListColumns[j].TotalsCalculation = sheetColumn.HasTotal
                            ? GetTotalsCalculation(sheetColumn.TotalType)
                            : Excel.XlTotalsCalculation.xlTotalsCalculationNone;
                        j++;
                    }
                }
                //else if (sheetBlock.Type == "single") { }
                else // sheetBlock.Type == "total"
                {
                }

                i += 4;
                j  = 1;
            }
            catch (Exception ex) { }
        }
Beispiel #9
0
 public void ChangeSelection(SheetTab sheetTab)
 {
     sheetTab.Worksheet.Select();
 }
Beispiel #10
0
		private void InsertSheet(SheetTab sheetTab) {
			if (Workbook != null) {
				sheetHolder.TabPages.Add(sheetTab);
				sheetHolder.SelectTab(sheetTab);
			}
		}
Beispiel #11
0
 public void OnChangeSelection(SheetTab sheetTab)
 {
     _thisAddIn.ChangeSelection(sheetTab);
 }