Add() private method

private Add ( ) : object
return object
示例#1
0
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        /// <param name="overWrite"></param>
        internal WorkSheet(WorkBook wbook, string sheetName, bool overWrite = false)
        {
            wb = wbook;

            // Look for an existing worksheet
            WorkSheet[] worksheets = wbook.WorkSheets;
            WorkSheet   wSheet     = worksheets.FirstOrDefault(n => n.ws.Name == sheetName);

            if (wSheet == null)
            {
                // If you don't find one, create one.
                ws = (Worksheet)wb.Add();

                ws.Name = sheetName;
                wb.Save();
                return;
            }

            // If you find one, then use it.
            if (overWrite)
            {
                // if there is only one worksheet, we need to add one more
                // before we can delete the first one
                ws = (Worksheet)wb.Add();
                wSheet.ws.Delete();
                ws.Name = sheetName;
                wb.Save();
            }
            else
            {
                ws = wSheet.ws;
            }
        }
示例#2
0
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        internal WorkSheet(WorkBook wbook, string sheetName)
        {
            wb = wbook;
            WorkSheet wSheet = wbook.WorkSheets.FirstOrDefault(n => n.ws.Name == sheetName);

            if (wSheet != null)
            {
                // Overwrite sheet
                DSOffice.ExcelInterop.App.DisplayAlerts = false;
                wSheet.ws.Delete();
                DSOffice.ExcelInterop.App.DisplayAlerts = true;
            }
            ws      = (Worksheet)wb.Add();
            ws.Name = sheetName;

            wb.Save();
        }
示例#3
0
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        internal WorkSheet(WorkBook wbook, string sheetName)
        {
            wb = wbook;

            // Look for an existing worksheet
            WorkSheet wSheet = wbook.WorkSheets.FirstOrDefault(n => n.ws.Name == sheetName);

            // If you find one, then use it.
            if (wSheet != null)
            {
                ws = wSheet.ws;
            }
            // If you don't find one, create one.
            else
            {
                ws      = (Worksheet)wb.Add();
                ws.Name = sheetName;
                wb.Save();
            }
        }
示例#4
0
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        /// <param name="overWrite"></param>
        internal WorkSheet(WorkBook wbook, string sheetName, bool overWrite = false)
        {
            wb = wbook;

            // Look for an existing worksheet
            WorkSheet[] worksheets = wbook.WorkSheets;
            WorkSheet wSheet = worksheets.FirstOrDefault(n => n.ws.Name == sheetName);

            if (wSheet == null)
            {
                // If you don't find one, create one.
                ws = (Worksheet) wb.Add();
                ws.Name = sheetName;
                wb.Save();
                return;
            }
            
            // If you find one, then use it.
            if (overWrite)
            {
                // if there is only one worksheet, we need to add one more
                // before we can delete the first one
                ws = (Worksheet) wb.Add();
                wSheet.ws.Delete();
                ws.Name = sheetName;
                wb.Save();

            }
            else
                ws = wSheet.ws;
        }
示例#5
0
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        internal WorkSheet(WorkBook wbook, string sheetName)
        {
            wb = wbook;
            ws = (Worksheet)wb.Add();
            ws.Name = sheetName;

            wb.Save();
        }
示例#6
0
文件: Excel.cs 项目: heegwon/Dynamo
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        internal WorkSheet (WorkBook wbook, string sheetName)
        {
            wb = wbook;
            WorkSheet wSheet = wbook.WorkSheets.FirstOrDefault(n => n.ws.Name == sheetName);
            
            if (wSheet != null)
            {
                // Overwrite sheet
                DSOffice.ExcelInterop.App.DisplayAlerts = false;
                wSheet.ws.Delete();
                DSOffice.ExcelInterop.App.DisplayAlerts = true;
            }
            ws = (Worksheet)wb.Add();
            ws.Name = sheetName;

            wb.Save();
        }
示例#7
0
文件: Excel.cs 项目: whztt07/Dynamo
        /// <summary>
        /// create new worksheet from given workbook and name (AddExcelWorksheetToWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="sheetName"></param>
        internal WorkSheet (WorkBook wbook, string sheetName)
        {
            wb = wbook;

            // Look for an existing worksheet
            WorkSheet wSheet = wbook.WorkSheets.FirstOrDefault(n => n.ws.Name == sheetName);

            // If you find one, then use it.
            if (wSheet != null)
            {
                ws = wSheet.ws;
            }
            // If you don't find one, create one.
            else
            {
                ws = (Worksheet)wb.Add();
                ws.Name = sheetName;
                wb.Save();
            }
        }