export points as csv?

957
2
03-27-2011 11:00 AM
BobLooney
New Contributor
I have been unable to find an add in for Desktop that will allow me to export points to a csv file. Is there a way to do this?
0 Kudos
2 Replies
BrianLeroux
Occasional Contributor III
I modified the query features add-in sample that came with the SDK. I essentially added an export button which will export the points that were selected to an excel spreadsheet. This will only work with a point layer from a shapefile or geodatabase. Hopefully that is what you are looking for.
0 Kudos
BrianLeroux
Occasional Contributor III
If you are familiar with the .NET SDK, I use the following code in an add-in to export items from a data grid view. I implemented this in the Query Features sample provided with the SDK.

Private Sub buttonExport_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles buttonExport.Click

        Dim xlApp As Microsoft.Office.Interop.Excel.Application
        Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
        Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
        xlApp = New Microsoft.Office.Interop.Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = CType(xlWorkBook.Sheets("Sheet1"), Worksheet)

        For Each col As DataGridViewColumn In
            dataGridView1.Columns
            xlWorkSheet.Cells(1, col.Index + 1) = col.HeaderText
            For Each rowa As DataGridViewRow In dataGridView1.Rows
                xlWorkSheet.Cells(rowa.Index + 2, col.Index + 1) = rowa.Cells(col.Index).Value
            Next
        Next
        xlApp.Visible = True
    End Sub
0 Kudos