public void GetAllSheetDataTest() { ExcelStream xlsxfile = new ExcelStream(@"C:\Users\maxgr\OneDrive\Documents\Fiverr\C#\Drag n chart\Sample data\Data Template 2b.xlsx"); xlsxfile.Select(4); var test = xlsxfile.GetAllSheetData(); xlsxfile.Close(); }
public void OpeningAndShowing() { ExcelStream xlsxfile = new ExcelStream(@"C:\Users\maxgr\OneDrive\Documents\Fiverr\C#\Drag n chart\Sample data\Data Template 2b.xlsx"); xlsxfile.Select(4); string actual = xlsxfile.GetCellData(5, 4).ToString().Trim(); string expected = "2.26"; Assert.AreEqual(expected, actual); xlsxfile.Close(); }
public void OpeningTest2() { ExcelStream file = new ExcelStream(); try { file = new ExcelStream(@"C:\Users\maxgr\OneDrive\Documents\Fiverr\C#\Drag n chart\Sample data\New Microsoft Word Document.docx"); Assert.Fail(); //It should not reach this point if the method works successfully. } catch (ExtensionException) { MessageBox.Show("Success!"); file.Close(); } }
/// <summary> /// Opens the specified filepath for reading /// </summary> /// <returns></returns> public void OpenExcelReader() { if (ExcelDoc != null) { ExcelDoc.Close(); ExcelDoc.Dispose(); } if (ExcelStream != null) { ExcelStream.Close(); ExcelStream.Dispose(); } ExcelStream = System.IO.File.Open(ExcelFilePath, FileMode.Open, FileAccess.Read); ExcelDoc = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(ExcelStream, false); }