We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Drag and Drop Excel Formulas

Hello,

I can drag and drop an Excel cell contents over to the grid but if the Excel cell contains a formula I cannot get the formula pasted into the Syncfusion grid.

When I drag and drop a Syncfusion cell about I do get the formula carried along automatically. What do I have to do to get an Excel cell drop to carry along the formula with it?

Thanks,
Ben

1 Reply

AD Administrator Syncfusion Team October 12, 2007 09:10 AM UTC

By default, GridControl supports 2 Clipboard formats. One uses GridStyleInfo objects, and the other is just text.

So, when you copy/paste or D&D from the grid to the grid, then grid can access the style information on the clipboard to handle the formulas.

But when you are coming from excel, there is no style information on the clipboard (or in the drag object), so this means that the grid can only use the text support, which normally only has the computed values from excel and not the formulas.

Here are 2 ways you can address this issue.

The first is simple and requires no coding. In excel, before you copy or initiate a drag, press ctl+` to tell excel to show all formulas. Then the formulas get put on the clipboard as text, and will get pasted into the grid as formulas (as long as you have set up up all cells to be formulas with code such as grid.TableStyle.CellType = "FormulaCell".)

The other way is significantly more work, but does not rely on your users using ctl+` to toggle formula displaying in excel. Instead, it requires that you handle the Paste or the drop in the grid, get the excel object from the clipboard, and handle setting the formulas directly into the grid cells. Our XlsIO would be useful in doing this, but this would take some coding.

Loader.
Live Chat Icon For mobile
Up arrow icon