The igGridExcelExport permits exporting a grid to a new Excel file. Is it possible to add the data as a worksheet to an existing Excel file?
Hi Ray,
I found another more clean approach for exporting the grid to an existing excel file, without iterating through the whole worksheet.You can bind to the headerCellExporting event of the igGridExcelExporter and add the following code snippet:
headerCellExporting: function(sender, args) { var headerArr = []; // We will save all the headers coming to our array for retrieval later on headerArr.push(args.headerText); if (args.columnIndex === 0) { sender._workbook = workbook; sender._worksheet = sender._workbook.worksheets(1); } }
Here is a sample for your reference:
igGridExcelExportToExistingFile (2).zip
Please, let me know if you have any questions.
Best regards,Hristo Popov
This last technique works very well, although the header columns for the worksheet created do not have the grid header names. I assume the headerArr was going to be used to correct this, but it wasn't shown how in the sample. However, I was able to call a function we already had to set the header exactly as required.
Thank you for your assistance.
I will take a look at this last technique.
We currently were implementing something similar to the first technique recommended, which was extremely slow when the grid contained many rows. So we switched to using igGridExcelExporter, which was must faster, but always created a separate workbook.
So I tried the second technique, to use the exportEnding event handler, but iterating through the whole worksheet was again very time consuming and much slower than creating a separate workbook.
So I will try this last technique to see whether or not the speed is acceptable.