public static SpreadsheetFile LoadSpreadsheetFile(string filePath, bool isEditable) { try { SpreadsheetFile newFile = new SpreadsheetFile(filePath); if (!newFile.fileSystemInfo.Exists) { throw new Exception("file does not exist in the given path"); } newFile.documentXmlPackage = SpreadsheetDocument.Open(filePath, isEditable); newFile.InitializeWorkbook(); return(newFile); } catch { throw; } }
public static SpreadsheetFile NewSpreadsheetFile(string filePath, SpreadsheetDocumentType documentType) { try { SpreadsheetFile newFile = new SpreadsheetFile(filePath); if (newFile.fileSystemInfo.Exists) { throw new Exception("file already exist in the given path"); } if (documentType != SpreadsheetDocumentType.Workbook) { throw new Exception("'DevEx.OOXml.SpreadsheetFile' currently supports only 'SpreadsheetDocumentType.Workbook' type."); } newFile.documentXmlPackage = SpreadsheetDocument.Create(filePath, documentType); newFile.InitializeWorkbook(); return(newFile); } catch { throw; } }