Hi,
Thanks for your inquiry.
Kindly note the InsertArray function is designed to insert an array of data into a range in Excel Worksheet. For your situation, if your byte array data is an Excel file, you could use the following method to convert the byte array to workbook.
- Code: Select all
//Your byte array
byte[] bytes = File.ReadAllBytes("test.xlsx");
//Load from byte array
Workbook workbook = new Workbook();
workbook.LoadFromStream(new MemoryStream(bytes));
//Save to Excel file
workbook.SaveToFile("result.xlsx", ExcelVersion.Version2013);
If you just want to insert some data in the form of byte array in a worksheet, please refer to the following sample code. If there is any question, please freel free to write back.
- Code: Select all
//Create a workbook
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Byte array
byte[] myByteArray = new byte[] { 0x01, 0x02, 0x03 };
//Insert the data in worksheet
sheet.InsertArray<byte>(myByteArray, 1, 1, true);
//Save to Excel file
workbook.SaveToFile("result.xlsx", ExcelVersion.Version2013);
Sincerely,
Nina
E-iceblue support team