예제 #1
0
        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();
        }
예제 #2
0
        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();

        }
예제 #3
0
 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();
     }
 }
예제 #4
0
        /// <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);
        }