i would like to save the contents of a datagridview to an xml file
i will then want to open the xml file using excel
perhaps i should be exporting it to CSV file instead of XML?
i dont care what method to use, i just need the simplest and fastest
i guess the process should be
- c开发者_JS百科opy the datagridview data into a datatable
- save the datatable to a csv/xml
how would i accomplish this?
please note that i do not want to save the datasource of the datagridview (because i make changes to datagridview in runtime), i want to make sure to iterate through the datagridview and save the data that way
Set the DataGridView's Datasource as the datatable: DataGridView.DataSource
Create a Datastream and export the Datatable using the built in Serialization: DataTable.WriteXML(stream)
I understand that you want the Datagridview table to export to a Datatable which then exports to a XML file. Consider that you can bind the Datatable to the Datagridview before Displaying your form. The Datatable will update along with your DataGridView as it acts a bindable source.
moreto follow
精彩评论