using MiniExcelLibs;
using System.Data;

namespace Hotline.Tools
{
    public class ExcelHelper
    {
        public static MemoryStream CreateStream(List<object> values)
        {
            var stream = new MemoryStream();
            stream.SaveAs(values);
            stream.Seek(0, SeekOrigin.Begin);
            return stream;
        }

        public static MemoryStream CreateStream(DataTable dataTable)
        {
            var stream = new MemoryStream();
            stream.SaveAs(dataTable);
            stream.Seek(0, SeekOrigin.Begin);
            return stream;
        }

        public static List<object> Read(Stream stream,bool useHeaderRow)
        {
           return  MiniExcel.Query(stream, useHeaderRow).ToList();
        }
    }
}
