示例#1
0
        public IExcel Read(string fileName)
        {
            using (var file = _fileUtils.GetStreamFromFile(fileName))
            {
                CheckFileName(fileName ?? throw new ArgumentNullException(nameof(fileName)));

                var isXml = IsXml(fileName, file);
                file.Seek(0, SeekOrigin.Begin);

                if (isXml)
                {
                    try
                    {
                        _processor.RemoveInvalidUrls(file);
                    }
                    catch
                    {
                        // ignored
                        // do nothing in case of password protected file
                    }
                    file.Seek(0, SeekOrigin.Begin);
                }

                return(new NPoiExcelFile(file, _fileUtils, isXml, fileName));
            }
        }