public void Write(Stream stream, string templatePath, DataSet ds, ExcelExtendType extendType = ExcelExtendType.XLSX) { TemplateConfig config = new TemplateConfig(); config.Load(templatePath); TTemplate template = config.GetTemplate(); Write(stream, template, ds); }
public bool WriteFile(string outputFilePath, DataSet ds, TTemplate template) { POIStream stream = new POIStream(); stream.AllowClose = false; ExcelExtendType extendType = outputFilePath.IndexOf(".xlsx") > 0 ? ExcelExtendType.XLSX : ExcelExtendType.XLS; if (template == null) { Write(stream, ds, extendType); } else { Write(stream, template, ds, extendType); } bool result = WriteFile(outputFilePath, stream); return(result); }
public void Write(Stream stream, TTemplate template, DataSet ds, ExcelExtendType extendType = ExcelExtendType.XLSX) { if (extendType == ExcelExtendType.XLS) { workbook = new HSSFWorkbook(); } else { workbook = new XSSFWorkbook(); } foreach (TSheet tSheet in template.Sheets) { ISheet sheet = workbook.CreateSheet(tSheet.Title); string tableName = string.IsNullOrEmpty(tSheet.Name) ? tSheet.Title : tSheet.Name; fillSheet(sheet, tSheet, ds.Tables[tableName]); } workbook.Write(stream); }