Esempio n. 1
0
 /// <summary>
 ///     根据模板导出
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="fileName"></param>
 /// <param name="data"></param>
 /// <param name="template">HTML模板或模板路径</param>
 /// <returns></returns>
 public Task <ExportFileInfo> ExportByTemplate <T>(string fileName, T data, string template) where T : class
 {
     using (var helper = new TemplateExportHelper <T>())
     {
         helper.Export(fileName, template, data);
         return(Task.FromResult(new ExportFileInfo()));
     }
 }
Esempio n. 2
0
        /// <summary>
        ///     根据模板导出
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fileName"></param>
        /// <param name="data"></param>
        /// <param name="template">HTML模板或模板路径</param>
        /// <returns></returns>
        public Task <ExportFileInfo> ExportByTemplate <T>(string fileName, T data, string template) where T : class
        {
            using (var helper = new TemplateExportHelper <T>())
            {
                var file = new FileInfo(fileName);

                helper.Export(template, data, (package) => { package.SaveAs(file); });
                return(Task.FromResult(new ExportFileInfo(file.Name, file.Extension)));
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     根据模板导出到载荷
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="data"></param>
 /// <param name="template">HTML模板或模板路径</param>
 public Task <byte[]> ExportBytesByTemplate <T>(T data, string template) where T : class
 {
     using (var helper = new TemplateExportHelper <T>())
     {
         using (var sr = new MemoryStream())
         {
             helper.Export(template, data, (package) => { package.SaveAs(sr); });
             return(Task.FromResult(sr.ToArray()));
         }
     }
 }