예제 #1
0
 public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename)
 {
     return new WorkBook(workbook, filename);
 }
예제 #2
0
 public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name)
 {
     return workbook.GetWorksheetByName(name);
 }
예제 #3
0
 public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name)
 {
     return new WorkSheet(workbook, name);
 }
예제 #4
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();
        }
예제 #5
0
 public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook)
 {
     return workbook.WorkSheets;
 }
예제 #6
0
 internal WorkSheet(Worksheet ws, WorkBook wb)
 {
     this.ws = ws;
     this.wb = wb;
 }
예제 #7
0
 public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename)
 {
     return(new WorkBook(workbook, filename));
 }
예제 #8
0
 public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name)
 {
     return(new WorkSheet(workbook, name));
 }
예제 #9
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();
            }
        }
예제 #10
0
 public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook)
 {
     return(workbook.WorkSheets);
 }
예제 #11
0
 public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name)
 {
     return(workbook.GetWorksheetByName(name));
 }
예제 #12
0
 public static WorkBook ReadExcelFile(string file)
 {
     return(WorkBook.ReadExcelFile(file));
 }
예제 #13
0
 public static WorkBook ReadExcelFile(FileInfo file)
 {
     return(WorkBook.ReadExcelFile(file.FullName));
 }
예제 #14
0
 internal WorkSheet(Worksheet ws, WorkBook wb)
 {
     this.ws = ws;
     this.wb = wb;
 }
예제 #15
0
 /// <summary>
 ///     Write data to a Microsoft Excel spreadsheet. Data is written by row
 ///     with sublists to be written in successive rows. Rows and columns are
 ///     zero-indexed; for example, the value in the data list at [0,0] will
 ///     be written to cell A1. Null values and empty lists are written to Excel 
 ///     as empty cells. This node requires Microsoft Excel to be installed. 
 /// </summary>
 /// <param name="filePath">File path to the Microsoft Excel spreadsheet.</param>
 /// <param name="sheetName">Name of the workseet to write data to.</param>
 /// <param name="startRow">Start row for writing data. Enter 0 for A, 1 for B, etc.</param>
 /// <param name="startCol">
 ///     Start column for writing data. Enter 0 for col 1, 1 for column 2, ect.
 /// </param>
 /// <param name="data">Data to write to the spreadsheet.</param>
 /// <param name="overWrite"></param>
 /// <returns name="data">Data written to the spreadsheet.</returns>
 /// <search>office,excel,spreadsheet</search>
 public static object[][] WriteToFile(string filePath, string sheetName, int startRow, int startCol, object[][] data, bool overWrite = false)
 {
     WorkBook wb = new WorkBook(filePath);
     WorkSheet ws = new WorkSheet(wb, sheetName, overWrite);
     ws = ws.WriteData(startRow, startCol, data);
     return ws.Data;
 }
예제 #16
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();
        }
예제 #17
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;
        }
예제 #18
0
        /// <summary>
        /// (SaveAsExcelWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="filename"></param>
        internal WorkBook(WorkBook wbook, string filename)
        {
            Name = filename;
            wb = wbook.wb;

            if (wb.FullName == filename)
                wb.Save();
            else
            {
                wb.SaveAs(filename);
            }
        }
예제 #19
0
        /// <summary>
        /// (SaveAsExcelWorkbook node)
        /// </summary>
        /// <param name="wbook"></param>
        /// <param name="filename"></param>
        internal WorkBook(WorkBook wbook, string filename)
        {
            Name = filename;
            wb = wbook.wb;

            if (wb.FullName == filename)
                wb.Save();
            else
            {
                try
                {
                    Workbook workbook = ExcelInterop.App.Workbooks.Open(filename);
                    workbook.Close(false);
                }
                catch (Exception)
                {
                }

                wb.SaveAs(filename);
            }

        }
예제 #20
0
파일: Excel.cs 프로젝트: hipigod/Dynamo
 public static WorkBook ReadExcelFile(string path)
 {
     return(WorkBook.ReadExcelFile(path));
 }