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
475
unable to export hyperlinks to excel using ultragridexcelexporter
posted

Hi I wrote the below code to export the data to excel using ultragridexcelexporter.

 

ultraGridExcelExporter1.Export(mygrid, saveFileDialog1.FileName);

 

During the export, i formatted few columns using the ultraGridExcelExporter1_InitializeColumn event as below.

 


            switch (e.Column.Key)
            {
                case "MyDocumentLink":

e.Column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText;                      

break;

}

 

//here i tried ColumnStyle.URL also. but no luck. If i set URL then the cell is showing

<a href="xxxxxxxxx">doc</a>

 

after exporting to excel the cell is containing value like http://myurl/mydoc.doc.It doesnt looks like a hyperlink but as a normal text cell. I need to press F2 inside the cell to edit and tab out the cell or press enter to activate the hyperlink.

I tried all the forums related to this issue, but they were suggesting to use Infragistics.excel component.

Is there any way to export the hyperlink that shud be active after exporting to excel?

Thanks,

Arun.K.S

  • 469350
    Suggested Answer
    Offline posted

    Hi Arun,

    sarunmphil said:
    I tried all the forums related to this issue, but they were suggesting to use Infragistics.excel component.

    The UltraGridExcelExporter can't identify hyperlinks in the grid cell for you. But you can do it yourself.

    What you would do is handle the CellExported event of the UltraGridExcelExporter. Then you can get teh value of the grid cell and write it to the Excel cell as a Formula.

    The event gives you the grid row and column as well as the Excel worksheet and the current row and column index. So all you have to do is create a formula and apply it to the cell using the ApplyFormula method of the excel worksheet cell.

    The code would be similar to this forum post, except that the worksheet and grid cell are provided by the event args.

    How to create excel file - Infragistics Community