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

CSV Export from a virtual grid

How do you export to a CSV file a virtual grid, I tries CopyTextToClipboard, but I get a divide by zero error. Thanks.

5 Replies

AD Administrator Syncfusion Team October 4, 2005 03:58 PM UTC

Try using this.gridControl1.TextDataExchange.CopyTextToBuffer.


JL Jose Lacson October 4, 2005 04:23 PM UTC

Sorry. That''s actually what i was using. Here''s my code: Private Sub Export() Me.m_oVGrid.Model.TextDataExchange.ExportTabDelim = "," Dim oRangeList As New Syncfusion.Windows.Forms.Grid.GridRangeInfoList Dim oRange As Syncfusion.Windows.Forms.Grid.GridRangeInfo oRange = Me.m_oVGrid.GridCellsRange.Rows(1, 5) oRangeList.Add(oRange) Dim sBuffer As String Dim nRows, nCols As Long Dim bReturn as Boolean bReturn = Me.m_oVGrid.TextDataExchange.CopyTextToBuffer(sBuffer, oRangeList, nRows, nCols) End Sub bReturn returns false sBuffer is blank, but length is > 0, Why is that? Thanks. >Try using this.gridControl1.TextDataExchange.CopyTextToBuffer.


AD Administrator Syncfusion Team October 4, 2005 04:35 PM UTC

The range has to be a cell range an dnot a row range. Try code like: oRange = gridControl1.GridCellsRange.Rows(1, 5) oRange = oRange.ExpandRange(1, 1, Me.gridControl1.RowCount, Me.gridControl1.ColCount) oRangeList.Add(oRange)


KE Ken January 25, 2006 11:42 PM UTC

I''ve followed the code to convert GridGroupingControl to CSV, but it missed the last row. Can you try? I think that might be a bug if the code below is correct. Here is the code I used. this.gridGroupingControl1.TableModel.TextDataExchange.ExportTabDelim = ","; string buffer; int coldone; int rowdone; Syncfusion.Windows.Forms.Grid.GridRangeInfoList rangeInfoList = new Syncfusion.Windows.Forms.Grid.GridRangeInfoList(); Syncfusion.Windows.Forms.Grid.GridRangeInfo gridRangeInfo = new Syncfusion.Windows.Forms.Grid.GridRangeInfo(); gridRangeInfo = this.gridGroupingControl1.TableModel.GridCellsRange; gridRangeInfo = gridRangeInfo.ExpandRange(0, 0, 1, 1); rangeInfoList.Add(gridRangeInfo); this.gridGroupingControl1.TableModel.TextDataExchange.CopyTextToBuffer( out buffer, rangeInfoList, out rowdone, out coldone); Console.WriteLine(rowdone); Console.WriteLine(coldone); Console.WriteLine(buffer);


ST stanleyj Syncfusion Team January 27, 2006 06:20 AM UTC

Hi Ken, This code works without leaving the last row, I tried in 4.1. What version of grid are you using? In 4.1, there is also a new support to convert grid contents to excel using XlsIO libraries. Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl converter = new Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl(); converter.GroupingGridToExcel(this.gridGroupingControl1,"Test.xls", Syncfusion.GridExcelConverter.ConverterOptions.Default); Best regards, Stanley

Loader.
Live Chat Icon For mobile
Up arrow icon