Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Cell formatting on export to excel
posted

Hi there,

I'm wondering if there is a way to auto-size all grid columns when we export to Excel using the $.ig.GridExcelExporter() javascript libraries.

I can see a "defaultColumnWidth" setting, but nothing to indicate we can auto-size the column. I know i can set the igniteUI grids to auto-size by using  a "*" as the defined column width, but that doesn't seem to work on export.

Parents
  • 700
    Offline posted

    Hello Andrew,

    Thank you for posting in our community!

    I have been looking into your question and an approach I could suggest is using the exportEnding event which gives a reference to the Excel worksheet. Then, you could use the columns and autoFitWidth methods in order to auto size the exported columns.

    $.ig.GridExcelExporter.exportGrid(
        $("#grid"),
        {
            fileName: "igGrid",
        },
        {
            exportEnding: function (event, args) {
                args.worksheet.columns(0).autoFitWidth();
                args.worksheet.columns(1).autoFitWidth();
                ...
            },
        }
    );

    Here could be found a small sample demonstrating my suggestion.

    Please test this approach on your side and let me know if you need any further assistance regarding this matter.

    Looking forward to your reply.

    Sincerely,
    Riva Ivanova
    Software Developer

Reply Children