I'm using Closed XML (0.68.1) to read Template document and then to generate new documents from template, but problem is that formatting of cells (Border, colors, ...) is lost after first cycle.
Below my test code
for (int i = 0; i < 4; i++) {
byte[] tTemplate = File.ReadAllBytes("MyTemplate.xlsx");
var workbook = new XLWorkbook(new MemoryStream(tTemplate));
MemoryStream tOut = new MemoryStream();
workbook.SaveAs(tOut);
byte[] tOutData = tOut.ToArray();
string tOutDoc = string.Format("Ret_{0}.xlsx", DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss_fff"));
FileStream tFile = File.Create(tOutDoc);
tFile.Write(tActual, 0, tActual.Length);
tFile.Close();
}
Thanks
Below my test code
for (int i = 0; i < 4; i++) {
byte[] tTemplate = File.ReadAllBytes("MyTemplate.xlsx");
var workbook = new XLWorkbook(new MemoryStream(tTemplate));
MemoryStream tOut = new MemoryStream();
workbook.SaveAs(tOut);
byte[] tOutData = tOut.ToArray();
string tOutDoc = string.Format("Ret_{0}.xlsx", DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss_fff"));
FileStream tFile = File.Create(tOutDoc);
tFile.Write(tActual, 0, tActual.Length);
tFile.Close();
}
Thanks