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

            NumTabs--;
        }
예제 #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++;
        }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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;
                    }
                }
            }
예제 #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();
        }
예제 #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) { }
        }
예제 #9
0
 public void ChangeSelection(SheetTab sheetTab)
 {
     sheetTab.Worksheet.Select();
 }
예제 #10
0
		private void InsertSheet(SheetTab sheetTab) {
			if (Workbook != null) {
				sheetHolder.TabPages.Add(sheetTab);
				sheetHolder.SelectTab(sheetTab);
			}
		}
예제 #11
0
 public void OnChangeSelection(SheetTab sheetTab)
 {
     _thisAddIn.ChangeSelection(sheetTab);
 }