예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    ExcelStream.Dispose();
                    ExcelDoc.Dispose();
                }

                ExcelStream   = null;
                ExcelDoc      = null;
                disposedValue = true;
            }
        }
예제 #2
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);
        }