public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename) { return new WorkBook(workbook, filename); }
public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name) { return workbook.GetWorksheetByName(name); }
public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name) { return new WorkSheet(workbook, name); }
/// <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(); }
public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook) { return workbook.WorkSheets; }
internal WorkSheet(Worksheet ws, WorkBook wb) { this.ws = ws; this.wb = wb; }
public static WorkBook SaveAsExcelWorkbook(WorkBook workbook, string filename) { return(new WorkBook(workbook, filename)); }
public static WorkSheet AddExcelWorksheetToWorkbook(WorkBook workbook, string name) { return(new WorkSheet(workbook, name)); }
/// <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(); } }
public static WorkSheet[] GetWorksheetsFromExcelWorkbook(WorkBook workbook) { return(workbook.WorkSheets); }
public static WorkSheet GetExcelWorksheetByName(WorkBook workbook, string name) { return(workbook.GetWorksheetByName(name)); }
public static WorkBook ReadExcelFile(string file) { return(WorkBook.ReadExcelFile(file)); }
public static WorkBook ReadExcelFile(FileInfo file) { return(WorkBook.ReadExcelFile(file.FullName)); }
/// <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; }
/// <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(); }
/// <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; }
/// <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); } }
/// <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); } }
public static WorkBook ReadExcelFile(string path) { return(WorkBook.ReadExcelFile(path)); }