[flexcoders] Re: From DataGrid to Clipboard and Excel

2013-01-19 Thread Tony Obermeit
This isn't exactly what you asked about but it's close.

I use the method below to copy selected rows to clipboard.  In this use I
have a tab character to separate the columns, elsewhere I provide the user
the choice between tab and comma with a separate dialog.

private function syncCopyToClipboard():void
{
// Separator used between Strings sent to clipboard
// to separate selected cells.
var separator:String = \t;
if (syncComma.selected) separator = ,;

// The String sent to the clipboard
System.setClipboard( );
var dataString:String = ;
var n:int = dgSyncGroupMembers.selectedCells.length;
if (n == 0)
{
Alert.show(You have not selected any rows, to select
all rows: click on the first row, scroll to the bottom and shift click on
the last row. Otherwise, select specific rows before you press the copy to
clipboard button.);
}
for (var i:int = 0; i  n; i++)
{
var cell:Object = dgSyncGroupMembers.selectedCells[i];
var data:Object =
dgSyncGroupMembers.dataProvider[cell.rowIndex];
var nameField:String =
dgSyncGroupMembers.columns[0].dataField;
var valuField:String =
dgSyncGroupMembers.columns[1].dataField;
dataString = data[nameField] + separator +
data[valuField] + \n + dataString;
}

// Write dataString to the clipboard.
System.setClipboard(dataString);
}


RE: [flexcoders] Re: From DataGrid to Clipboard and Excel

2013-01-19 Thread Mark Fuqua
Very sweet.I don't have a particular use for this right now.but I'll sure be
looking for one!

 

From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On
Behalf Of Tony Obermeit
Sent: Saturday, January 19, 2013 12:59 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: From DataGrid to Clipboard and Excel

 

  

This isn't exactly what you asked about but it's close.

I use the method below to copy selected rows to clipboard.  In this use I
have a tab character to separate the columns, elsewhere I provide the user
the choice between tab and comma with a separate dialog.

private function syncCopyToClipboard():void 
{
// Separator used between Strings sent to clipboard
// to separate selected cells.
var separator:String = \t;
if (syncComma.selected) separator = ,;

// The String sent to the clipboard
System.setClipboard( );
var dataString:String = ;
var n:int = dgSyncGroupMembers.selectedCells.length;
if (n == 0)
{
Alert.show(You have not selected any rows, to select
all rows: click on the first row, scroll to the bottom and shift click on
the last row. Otherwise, select specific rows before you press the copy to
clipboard button.);
}
for (var i:int = 0; i  n; i++)
{
var cell:Object = dgSyncGroupMembers.selectedCells[i];
var data:Object =
dgSyncGroupMembers.dataProvider[cell.rowIndex];
var nameField:String =
dgSyncGroupMembers.columns[0].dataField;
var valuField:String =
dgSyncGroupMembers.columns[1].dataField;  
dataString = data[nameField] + separator +
data[valuField] + \n + dataString;
}

// Write dataString to the clipboard.
System.setClipboard(dataString);
}