Excel tab design and get an workbook in byte[]

I am generating converting a report from BO server in xls format. basically I am creating a base workbook and for each page of the report, i am creating a temporary workbook and adding it as a sheet in the orginal work book. ( if there is a better way to do this, please advice).


Problem:

I need to get the byte[] of workbook. Please help me

Workbook workbook = new Workbook();
for(int i = 0; i <documentInstance.getReports().getCount(); i++){
xlsReportTab = documentInstance.getReports().getItem(i);
xlsReportTab.setPaginationMode(PaginationMode.Page);
binaryView = (BinaryView)xlsReportTab.getView(OutputFormatType.XLS);
Workbook workbookTab = new Workbook();
workbookTab.getWorksheets().addSheet(0, xlsReportTab.getName());
workbookTab.open(binaryView.getContentType());
// workbookTab.loadData(binaryView.getContentType());
workbook.getWorksheets().addSheet(i, xlsReportTab.getName());
workbook.getWorksheets().getSheet(i).copy(workbookTab.getWorksheets().getSheet(0));
}

Hello

Thanks for your inquiry. I will move your request to the Aspose.Cells forum and my colleagues will answer you shortly.

Best regards,

Hi,

To get byte[] of Workbook, I think you can just save it to a ByteArrayOutputStream and then get byte[] from it.

Code sample:

ByteArrayOutputStream baos = new ByteArrayOutputStream(1024000);
workbook.save(baos);
byte[] arr = baos.toByteArray();


Please download the latest Aspose.Cells for Java v2.5.3.4.