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.
Unfortunately, activation email could not send to your email. Please try again.

Copying table to excel via code

Thread ID:

Created:

Updated:

Platform:

Replies:

6411 Aug 12,2003 02:20 AM Aug 12,2003 04:07 AM Windows Forms 1
loading
Tags: GridControl
Stephen Rose
Asked On August 12, 2003 02:20 AM

I am trying to write an option to export my grid to excel. It is quite a complex grid with covered cells and borders etc. If i do Grid.CutPaste.CopyRange(GridRangeInfo.Table) I get a divide by zero. Grid.CutPaste.CopyRange(GridRangeInfo.Row(3)) Excel gives an error in its paste function Grid.CutPaste.CopyRange(GridRangeInfo.Cell(1,1)) Works. Is there a way for me to dump the grid colours, layout and all into excel? Cheers Steve

Administrator [Syncfusion]
Replied On August 12, 2003 04:07 AM

Currently Essential Grid only supports 2 clipboard formats, an internal GridData format, and a DataFormats.Text format (tab separated text with newlines for rows). So, currently the only format that Excel can use is the text format. This only supports the text copying, and not cell colors, etc. We are working on supporting BIFF formats, so in the future you would be able to copy more than text. Biff support will not be in the upcoming 2.0 release, but should be available shortly thereafter. You can call range.ExpandRange on a range object to make sure it is a cell range so the Copy has a fixed set cesll to work with.
private void button1_Click(object sender, System.EventArgs e)
{
	GridRangeInfo range = GridRangeInfo.Col(1);
	range = range.ExpandRange(1, 1, this.gridDataBoundGrid1.Model.RowCount-1, this.gridDataBoundGrid1.Model.ColCount);
	this.gridDataBoundGrid1.Model.CutPaste.CopyRange(range);
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;