public void ConvertXlsBytesTest() { var models = GetModels(); var bytes = ExcelHelper.ObjectToExcelBytes(models); Assert.IsTrue(bytes.Length > 0); var importer = new ExcelImporter(); var result = importer.ExcelToObject <ReportModel>(bytes).ToList(); models.AreEqual(result); }
public void ConvertXlsxBytesTest() { var models = GetModels(); var array = ExcelHelper.ObjectToExcelBytes(models, ExcelType.Xlsx); Assert.IsTrue(array.Length != 0); var excelImporter = new ExcelImporter(); var result = excelImporter.ExcelToObject <ReportModel>(array).ToList(); models.AreEqual(result); }
public void ConvertTest1() { var models = GetModels(); var bytes = ExcelHelper.ObjectToExcelBytes(models); Assert.IsTrue(bytes.Length > 0); var importer = new ExcelImporter(); var result = importer.ExcelToObject <ReportModel>(bytes); Assert.AreEqual(models.Count, result.Count()); }
public void ConvertXlsFileUseObjectToExcelTest() { var models = GetModels(); var path = GetFilePath("test.xls"); ExcelHelper.ObjectToExcel(models, path); Assert.IsTrue(File.Exists(path)); var importer = new ExcelImporter(); var result = importer.ExcelToObject <ReportModel>(path).ToList(); Assert.AreEqual(models.Count, result.Count); models.AreEqual(result); }
public void Test() { var models = GetModels(); var exporter = new ExcelExporter(); var bytes = exporter.ObjectToExcelBytes(models); var path = GetFilePath("text.xls"); Console.WriteLine(path); File.WriteAllBytes(path, bytes); Assert.IsTrue(File.Exists(path)); var importer = new ExcelImporter(); var result = importer.ExcelToObject<ReportModel>(path); Assert.AreEqual(models.Count, result.Count()); }
public void ConvertTest() { var models = GetModels(); var bytes = ExcelHelper.ObjectToExcelBytes(models); var path = GetFilePath("text.xls"); File.WriteAllBytes(path, bytes); Assert.IsTrue(File.Exists(path)); var importer = new ExcelImporter(); var result = importer.ExcelToObject <ReportModel>(path); Assert.AreEqual(models.Count, result.Count()); }
public void EmptyFirstProperty() { var models = GetModels(); var bytes = ExcelHelper.ObjectToExcelBytes(models); Assert.IsNotNull(bytes); Assert.IsTrue(bytes.Length > 0); var importer = new ExcelImporter(); var result = importer.ExcelToObject <ReportModel>(bytes).ToList(); Console.WriteLine(result.FirstOrDefault()); Assert.AreEqual(models.Count, result.Count()); models.AreEqual(result); }
public static IEnumerable <TModel> ExcelToObject <TModel>(string path, string sheetname) where TModel : class, new() { var importer = new ExcelImporter(); return(importer.ExcelToObject <TModel>(path, sheetname)); }