1) We currently only export delimited text. Direct support of XLS (BIFF) is on our to-do and we hope to have this support in teh next few months.
Here are some snippets that read and write CSV files.
//CSV CODE
//save text
private void button3_Click(object sender, System.EventArgs e)
{
this.gridControl1.Model.TextDataExchange.ExportTabDelim = ",";
string outPut;
int nRows, nCols;
GridRangeInfoList rangeInfoList = new GridRangeInfoList();
rangeInfoList.Add(GridRangeInfo.Cells(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount));
bool b = this.gridControl1.Model.TextDataExchange.CopyTextToBuffer(out outPut, rangeInfoList, out nRows, out nCols);
if(b)
{
StreamWriter writer = new StreamWriter("test.csv");
writer.Write(outPut);
writer.Close();
}
}
//load text
private void button4_Click(object sender, System.EventArgs e)
{
this.gridControl1.Model.TextDataExchange.ImportTabDelim = ",";
StreamReader reader = new StreamReader("test.csv");
string s = reader.ReadToEnd();
reader.Close();
this.gridControl1.BeginUpdate();
//reset grid
this.gridControl1.RowCount = 1;
this.gridControl1.ColCount = 1;
this.gridControl1.Model.TextDataExchange.PasteTextFromBuffer(s, GridRangeInfo.Cell(1,1), 0);
this.gridControl1.EndUpdate();
}
2) There is no method to support copying values to an array. But you can spend up looping through the cells by directly accessing the GridData object instead of using a direct indexer on the GridControl. We are talking of speeding things up by 100 to 200 times. If you need direct access to a significant amount of data, then going through the GridData object is worth the effort. Below is a code snippet.
//C#
private void button2_Click(object sender, System.EventArgs e)
{
//GridData method
int start = Environment.TickCount;
int[,] A = new int[this.gridControl1.RowCount, this.gridControl1.ColCount];
GridData data = this.gridControl1.Model.Data;
for(int row = 1; row <= this.gridControl1.RowCount; ++ row)
for(int col = 1; col <= this.gridControl1.ColCount; ++col)
{
A[row-1, col-1] = (int) (new GridStyleInfo(data[row, col])).CellValue;
}
Console.WriteLine("GridData {0}", Environment.TickCount-start);
}
'VB.NET
Private Sub button2_Click(sender As Object, e As System.EventArgs)
'GridData method
Dim start As Integer = Environment.TickCount
Dim A(Me.gridControl1.RowCount, Me.gridControl1.ColCount) As Integer
Dim data As GridData = Me.gridControl1.Model.Data
Dim row As Integer
While row <= Me.gridControl1.RowCount
Dim col As Integer
While col <= Me.gridControl1.ColCount
A(row - 1, col - 1) = CInt(New GridStyleInfo(data(row, col)).CellValue)
End While
End While
Console.WriteLine("GridData {0}", Environment.TickCount - start)
End Sub 'button2_Click