Exemple #1
0
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 protected override void Init()
 {
     base.Init();
     this.workbook     = null;
     this.workbookName = string.Empty;
     this.flagName     = false;
 }
Exemple #2
0
        /// <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;
        }
Exemple #3
0
 /// <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;
 }
Exemple #4
0
        /// <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);
            }
        }
Exemple #5
0
        /// <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)) }));
        }
Exemple #6
0
 /// <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;
 }
Exemple #7
0
 /// <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);
 }