简体   繁体   English

使用C#将Treeview数据导出到Excel工作表

[英]Exporting Treeview data to excel sheet using C#

I am using Visual Studio 2010. I have a form which has a treeview control which generate values from an xml file. 我正在使用Visual Studio2010。我有一个带有Treeview控件的表单,该控件从xml文件生成值。 When I select a particular treeview node, I need to export the selected node data and its child nodes to an excel sheet as rows and columns. 当我选择一个特定的树视图节点时,我需要将选定的节点数据及其子节点作为行和列导出到excel工作表中。

Could any one guide me how can I proceed with this? 谁能指导我该如何进行呢?

Appreciate your immediate response. 感谢您的即时回应。

Thanks 谢谢

You need to loop through the children of the select node then add to exel workbook 您需要遍历选择节点的子节点,然后添加到exel工作簿

this code show how to get to the children of the select node 此代码显示如何到达选择节点的子节点

foreach(TreeNode node in yourTreeview.SelectedNode.Nodes)
{
      // write code to export data to excel.
}

You can read for exporting data to excel How can I export data to an Excel file 您可以阅读将数据导出到Excel的方法如何将数据导出到Excel文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM