/// <summary> /// Initializes this instance. /// </summary> protected override void Init() { base.Init(); this.workbook = null; this.workbookName = string.Empty; this.flagName = false; }
/// <summary> /// Removes the worksheet from workbook. /// </summary> /// <param name="workbook">The workbook.</param> /// <param name="worksheet">The worksheet.</param> internal static void RemoveWorksheetFromWorkbook(Dt.Cells.Data.Workbook workbook, Worksheet worksheet) { int index = workbook.Sheets.IndexOf(worksheet); int num2 = (index == (workbook.Sheets.Count - 1)) ? (workbook.Sheets.Count - 2) : (index + 1); ICalcSource replacedSource = (num2 == -1) ? null : ((ICalcSource)workbook.Sheets[num2]); workbook.Sheets[index].CalcAxial.RemoveSheet(workbook.Sheets, replacedSource); worksheet.Workbook = null; }
/// <summary> /// Creates a new section that contains all the worksheets for the specified workbook. /// </summary> /// <param name="workbook">The <see cref="P:Dt.Cells.Data.GcAllSheetSection.Workbook" /> object.</param> public GcAllSheetSection(Dt.Cells.Data.Workbook workbook) { if (workbook == null) { throw new ArgumentNullException("workbook"); } this.Init(); this.workbook = workbook; this.workbookName = this.workbook.Name; }
/// <summary> /// Adds the worksheet in workbook. /// </summary> /// <param name="workbook">The workbook.</param> /// <param name="worksheet">The worksheet.</param> internal static void AddWorksheetInWorkbook(Dt.Cells.Data.Workbook workbook, Worksheet worksheet) { if (workbook == null) { throw new ArgumentNullException("workbook"); } if (worksheet == null) { throw new ArgumentNullException("worksheet"); } using (IEnumerator <Worksheet> enumerator = workbook.Sheets.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.Name == worksheet.Name) { throw new NotSupportedException(ResourceStrings.AnotherWorksheetWithTheSameNameError); } } } if ((worksheet.Name == null) || (worksheet.Name == string.Empty)) { worksheet.Name = GeneralNewSheetName(workbook); } new Dictionary <ulong, ulong>(); if (!workbook.Sheets.Contains(worksheet)) { if ((worksheet.NamedStyles == null) && (workbook != null)) { worksheet.NamedStyles = workbook.NamedStyles; } if ((workbook != null) && (worksheet.NamedStyles == workbook.NamedStyles)) { worksheet.NamedStyles.Owner = workbook; } worksheet.Workbook = workbook; } int index = workbook.Sheets.IndexOf(worksheet); if ((index > 0) && (index < (workbook.Sheets.Count - 1))) { worksheet.CalcAxial.InsertSheet(workbook.Sheets); } }
/// <summary> /// Generals the new name of the sheet. /// </summary> /// <returns></returns> static string GeneralNewSheetName(Dt.Cells.Data.Workbook workbook) { int num = 0; if (workbook != null) { foreach (Worksheet worksheet in workbook.Sheets) { if ((worksheet.Name != null) && Regex.Match(worksheet.Name, "^Sheet[1-9][0-9]*$", (RegexOptions)RegexOptions.IgnoreCase).Success) { string s = worksheet.Name.Substring("Sheet".Length, worksheet.Name.Length - "Sheet".Length); int result = -1; if (int.TryParse(s, out result)) { num = Math.Max(num, result); } } } } return(string.Format("Sheet{0}", (object[])new object[] { ((int)(num + 1)) })); }
/// <summary> /// Initializes a new instance of the <see cref="P:Dt.Cells.Data.WorksheetCollection.Workbook" /> class. /// </summary> internal WorksheetCollection(Dt.Cells.Data.Workbook workbook) { this.workbook = workbook; }
/// <summary> /// Adds the worksheet in workbook. /// </summary> /// <param name="workbook">The workbook.</param> /// <param name="worksheet">The worksheet.</param> protected internal virtual void AddWorksheetInWorkbookInternal(Dt.Cells.Data.Workbook workbook, Worksheet worksheet) { AddWorksheetInWorkbook(workbook, worksheet); }