Open byte array Excel

Asked 2 years ago, Updated 2 years ago, 48 views

I would like to read the Excel file stored in DB into the byte array and open Excel. Please let me know if you know how.
What is the assumed code deployed in the byte array?

c# excel

2022-09-29 22:32

1 Answers

Why don't you write the contents of buffer to a temporary file to generate the XSSFWorkbook instance and delete the temporary file when you're done?

//Read Book (Template)
var excelTemplate=new ExcelReport(_db,_logger) {TemplateId=FdId.FD1210};
byte [ ] buffer = excelTemplate.GetExcelTemplate();
string tempFilePath=System.IO.Path.GetTempFileName();
System.IO.File.WriteAllBytes(tempFilePath, buffer);
XSSFWorkbook book = new XSSFWorkbook (tempFilePath);

// (Something to Do)

// Delete temporary files when finished
System.IO.File.Delete(tempFilePath);


2022-09-29 22:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.