Esempio n. 1
0
 public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename)
 {
     return new WorkBook(workbook, filename);
 }
Esempio n. 2
0
 public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name)
 {
     return workbook.GetWorksheetByName(name);
 }
Esempio n. 3
0
 public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name)
 {
     return new WorkSheet(workbook, name);
 }
Esempio n. 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();
        }
Esempio n. 5
0
 public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook)
 {
     return workbook.WorkSheets;
 }
Esempio n. 6
0
 internal WorkSheet(Worksheet ws, WorkBook wb)
 {
     this.ws = ws;
     this.wb = wb;
 }
Esempio n. 7
0
 public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename)
 {
     return(new WorkBook(workbook, filename));
 }
Esempio n. 8
0
 public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name)
 {
     return(new WorkSheet(workbook, name));
 }
Esempio n. 9
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();
            }
        }
Esempio n. 10
0
 public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook)
 {
     return(workbook.WorkSheets);
 }
Esempio n. 11
0
 public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name)
 {
     return(workbook.GetWorksheetByName(name));
 }
Esempio n. 12
0
 public static WorkBook ReadExcelFile(string file)
 {
     return(WorkBook.ReadExcelFile(file));
 }
Esempio n. 13
0
 public static WorkBook ReadExcelFile(FileInfo file)
 {
     return(WorkBook.ReadExcelFile(file.FullName));
 }
Esempio n. 14
0
 internal WorkSheet(Worksheet ws, WorkBook wb)
 {
     this.ws = ws;
     this.wb = wb;
 }
Esempio n. 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;
 }
Esempio n. 16
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();
        }
Esempio n. 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;
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }

        }
Esempio n. 20
0
 public static WorkBook ReadExcelFile(string path)
 {
     return(WorkBook.ReadExcelFile(path));
 }