Beispiel #1
0
        /// <summary>
        /// xls文档
        /// </summary>
        /// <param name="xlsStream">xls流</param>
        /// <exception cref="ArgumentNullException"></exception>
        public XlsDoc(Stream xlsStream)
        {
            if (xlsStream == null)
            {
                throw new ArgumentNullException(nameof(xlsStream));
            }

            using var dataset = XlsReader.ReadAsDataSet(xlsStream);
            this.sheets       = this.Parse(dataset).ToList();
        }
Beispiel #2
0
        /// <summary>
        /// xls文档
        /// </summary>
        /// <param name="xls">xls文件路径</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="FileNotFoundException"></exception>
        public XlsDoc(string xls)
        {
            if (xls.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(xls));
            }

            if (File.Exists(xls) == false)
            {
                throw new FileNotFoundException($"找不到文件:{xls}");
            }

            using var xlsStream = new FileStream(xls, FileMode.Open, FileAccess.Read);
            using var dataset   = XlsReader.ReadAsDataSet(xlsStream);
            this.sheets         = this.Parse(dataset).ToList();
        }