Hi,
Please check the complete running sample code below.
It reads the sample source file into byte array, you will read it from database. Then it creates a memory stream object and then workbook object and prints “Welcome Aspose!” in cell A1 and write the output xlsx file.
I have also attached the source and output xlsx files for your reference.
You can also see the screenshot attached by me.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;
//Read all bytes into a byte array
byte[] bytes = System.IO.File.ReadAllBytes(filePath);
//Create a memory stream
MemoryStream ms = new MemoryStream(bytes);
ms.Position = 0;
//Create a workbook object
Workbook workbook = new Workbook(ms);
//Do some work on workbook object of your choice, i will print Welcome Aspose in cell A1
workbook.Worksheets[0].Cells[“A1”].PutValue(“Welcome Aspose!”);
//Save the workbook
workbook.Save(filePath + “.out.xlsx”, SaveFormat.Xlsx);