public void TestActionResult_FormatFromFile() { ExcelResult<PersonMoney> result = new ExcelResult<PersonMoney>( new ExportModel<PersonMoney>() { Renderer = new STExcel2003Renderer<PersonMoney>("Templates") { dataSource = DataSourcePersons, StringTemplateFileName = "PersonMoneyExcel2003" }.ApplyCodeFormat(false) } ); result.ExecuteResult(_controllerContext); MemoryStream ms = _controllerContext.HttpContext.Response.OutputStream as MemoryStream; ms.Flush(); ms.Position = 0; StreamReader sr = new StreamReader(ms); Assert.AreEqual(verificationData, sr.ReadToEnd()); }
public void TestActionResult_FormatFromCode() { ExcelResult<PersonMoney> result = new ExcelResult<PersonMoney>( new ExportModel<PersonMoney>() { Renderer = new STExcel2003Renderer<PersonMoney>("Templates") { dataSource = DataSourcePersons }.ApplyCodeFormat(true) } .AddColumns(x => { x.For("Number").named("Money"); x.For(val => val.DepositDate).named("dt").Format("{0:yyyyMMdd}"); x.For(val => val.Name).Visible(false); } )); result.ExecuteResult(_controllerContext); MemoryStream ms = _controllerContext.HttpContext.Response.OutputStream as MemoryStream; ms.Flush(); ms.Position = 0; StreamReader sr = new StreamReader(ms); Assert.AreEqual(verificationData, sr.ReadToEnd()); }