public void RemoveWorsheet(SheetTab sheetTab) { Excel.Worksheet worksheet = (Excel.Worksheet)Application.ActiveWorkbook.Worksheets[sheetTab.Worksheet.Index]; worksheet.Delete(); NumTabs--; }
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++; }
public void InsertTab(int index, string title) { var tab = new SheetTab(this.rgView, this.Context) { Text = title, }; this.innerView.AddView(tab); UpdateTabWidthForText(tab); }
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); } }
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); } }
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; } } }
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(); }
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) { } }
public void ChangeSelection(SheetTab sheetTab) { sheetTab.Worksheet.Select(); }
private void InsertSheet(SheetTab sheetTab) { if (Workbook != null) { sheetHolder.TabPages.Add(sheetTab); sheetHolder.SelectTab(sheetTab); } }
public void OnChangeSelection(SheetTab sheetTab) { _thisAddIn.ChangeSelection(sheetTab); }