igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Issue with export excel/csv from grid

Open Eralmidia opened this issue 7 years ago • 13 comments

Description

Are there any known issues with the export function in the toolbar of the grid? When I set image it looks like this: image The buttons are there, but no icon or text: image

When clicking, it gives the following error: image

  • igniteui-angular version: 7.1.3
  • browser: Chrome latest

Steps to reproduce

Create a igx grid Set the exportExcel and exportCsv to true

Eralmidia avatar Jan 30 '19 07:01 Eralmidia

@Eralmidia In addition to enabling the export (via the two boolean properties), one needs to specify the actual text that will be shown in the drop-down for each option. Our assumption is that the developer would specify the text that best fits their application, so we don't have default values, hence the tiny empty drop-down. exportExcelText="Export to Excel" exportCsvText="Export to CSV" However, I am not able to reproduce the exception at our end. Could you, please, share some more details or attach a small sample application that demonstrates it?

gedinakova avatar Feb 01 '19 09:02 gedinakova

Hi Galina

I was able to reproduce the issue in a fork of your grid sample app. For some reason, on my dev server it fails on both excel and csv. In the sample app, it works on excel, but fails on csv when using the toolbar. But at least that should give you a starting point to find the error:

https://stackblitz.com/edit/angular-uueun1

Eralmidia avatar Feb 04 '19 10:02 Eralmidia

@Eralmidia Thank you for providing the sample, it helped a lot. The issue was that the IgxCsvExporterService was not provided in the NgModule and not injected in the component's constructor. I updated the sample with these 2 changes and the export seems to be successful. Please, let me know if you still experience any issues. https://stackblitz.com/edit/angular-export-configuration

gedinakova avatar Feb 04 '19 18:02 gedinakova

Ah, the exports are their own module. That makes sense. Thanks for the support

Eralmidia avatar Feb 07 '19 10:02 Eralmidia

So, after providing the services, the export works. But whenever I choose excel, I get the following message:

image

Clicking yes opens the file, and the data seems to be ok. On the CSV there are no errors. This is tested on latest office 365 desktop app

Eralmidia avatar Feb 07 '19 10:02 Eralmidia

Ok, that's not good. Unfortunately, we cannot reproduce this on our end. I would really appreciate if you can send me the 2 excel files - the exported one before recovery and then the recovered so we can investigate this further.

gedinakova avatar Feb 08 '19 11:02 gedinakova

Ok, I've attached one file where I have pressed yes to recover, and one where I have not.

Data export recovered.xlsx Data export.xlsx

Eralmidia avatar Feb 13 '19 10:02 Eralmidia

Thank you. I get the corrupted file error for both of these 2 files. So I compared them and they seem to be absolutely the same. Can you, please, make sure the repaired one was properly saved and resend it? Thanks in advance.

gedinakova avatar Feb 15 '19 13:02 gedinakova

Actually, it seems like repairing and saving the file doesn't really fix the issue. If I repair, and save it as a new workbook, the next time I open it, it needs to repair again. Here is one untouched corrupted, and one which has been repaired and saved as a new workbook:

Export_corrupted.xlsx Export1.xlsx

image

Repair log: image

Eralmidia avatar Feb 21 '19 14:02 Eralmidia

@Eralmidia I've noticed when excel recovers the corrupted files that you've sent, they contain an empty column - with no header and cell values. So, I've updated the app with similar grid - to contain an empty column. Here is the app: https://stackblitz.com/edit/angular-export-configuration-pnbzmt

On that project, if you click on the exportExcel you will get the same Excel message. So can you please share, do you have such a column in your igxGrid?

astaev avatar Mar 05 '19 13:03 astaev

@astaev Ah, good catch. I didn't notice that. Yes actually, we do have a column which is templated with a few buttons, for actions which can be applied for each row: image

It is templated like this image

The columnsData is just a "meta data" array used to determine how the columns shoud render: image

So the actions field doesn't really have any data, it is just used to identify the template to use. How can I mark the actions column to be excluded from the export then?

Eralmidia avatar Mar 06 '19 07:03 Eralmidia

@Eralmidia, you can easily skip that column by handling the excelExporter's onColumnExport event. The event args contain each column details - like header and index. So you can easily skip a column with empty header or by particular column index with this code:

// place the code inside your constructor, where injecting the excelExporter excelExportService.onColumnExport.subscribe( (value: IColumnExportingEventArgs) => { if(value.header === '' /* || value.columnIndex === 0 */) { value.cancel = true; //skip that column from exporting } });

astaev avatar Mar 06 '19 14:03 astaev

@astaev Thanks, I'll that a go then

Eralmidia avatar Mar 07 '19 09:03 Eralmidia