Hi,
I need excel export with format XSLB instead XSLS. Is there any way to do that, Please provide any solution if exist.
Regards,
Ravi
Hello, Ravi,
Thank you for reaching out to us.
We want to explain that Flexmonster does not support exporting in .xlsb
format.
As a workaround, we suggest considering one of the following approaches:
destinationType: "plain"
parameter of the exportTo API call to return the component’s content with callbackHandler
. This content will be represented as a Uint8Array
. Next, use the dedicated library to construct the .xlsx
file from the received data. Finally, convert the resulting file to the desired format using the capabilities of the corresponding library.destinationType
parameter as server
. Next, convert the file to the desired format on the server-side. Use the library that allows working with Excel files if needed. Finally, return the resulting .xlsb
file to the client-side and perform downloading.
Our team hopes it helps.
Please contact us in case other questions arise.
Kind regards,
Illia
Hi Illia,
Thank you for the quick response.
Still I'm not clear how to convert Uint8Array to XlSB.
Please provide an example for conversion.
Regards,
Ravi
Hello, Ravi,
Thank you for your feedback.
Currently, our team does not have a sample for converting XLSX format to XLSB.
Still, we found some references that should be useful for you.
We want to notice that the first approach implies the conversion of the Uint8Array
to .xlxs
format. Next, the resulting file should be converted to .xlsb
.
Both conversions should be performed by the client-side library's capabilities that would offer the corresponding functionality. For example, the JavaScript library SheetJS can be used. It provides a wide set of tools to manipulate with Excel, including creating an Excel file from different formats and performing a conversion. Please see an example that demonstrates saving files in different Excel formats, including .xlsb
format.
In case the conversion of the Uint8Array
is not an option for you, we suggest considering the second approach. It implies exporting the file to the server-side and converting it to the desired format (.xlsb
) using a server-side library.
For example, Aspose.Cells for .NET API tool can be used. It allows to manipulate Excel files and convert them to different formats.
After the conversion, send the file back to the client and perform downloading.
Our team hopes it works for you.
Please contact us in case other questions arise.
Regards,
Illia
Hi Illia,
Thanks for the response.
I found an different approach to convert XLSX to XLSB. Sharing it with you, may be in future when somebody requires this conversion, you can point out to this thread.
Below example works for me.
import * as XLSX from 'xlsx';
exportParams = {
header: 'sample header',
footer: 'sample footer'
filename: 'sample file 1',
destinationType: 'plain',
excelSheetName: 'Sheet1'
}
this.flexMonsterGrid.flexmonster.exportTo('excel', exportParams, (resp: any) => {
const tempExcel = resp.data;
const tempBase64String = btoa(String.fromCharCode.apply((this, tempExcel)));
const workbook = XLSX.read(tempBase64String, {type: 'base64'});
const tempFileName = exportParams.filename + '.xlsb';
const workbookOptions = { compression: false };
XLSX.writeFile(workbook, tempFileName, workbookOptions);
});
Regards,
Ravi
Hello, Ravi,
Our team is happy to hear you have found a suitable approach.
Also, thank you for sharing your solution on our forum.
Feel free to contact us in case any other questions arise.
Best regards,
Illia