How to export WinForms TreeViewAdv nodes to Excel?
Export TreeViewAdv nodes to Excel
You can export the TreeNodeAdv collection in WinForms TreeView to Excel by using the following code example.
C#
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(2);
IWorksheet sheet = workbook.Worksheets[0];
TreeNodeAdvCollection nodes = treeViewAdv1.Nodes;
foreach (TreeNodeAdv n in nodes)
{
RecursiveNodes(n);
}
ExportTreeToWorksheet(sheet);
workbook.SaveAs("sample1.xls");
Process.Start("Sample1.xls");
VB
Dim excelEngine As New ExcelEngine()
Dim application As IApplication = excelEngine.Excel
Dim workbook As IWorkbook = application.Workbooks.Create(2)
Dim sheet As IWorksheet = workbook.Worksheets(0)
Dim nodes As TreeNodeAdvCollection = treeViewAdv1.Nodes
For Each n As TreeNodeAdv In nodes
RecursiveNodes(n)
Next n
ExportTreeToWorksheet(sheet)
workbook.SaveAs("sample1.xls")
Process.Start("Sample1.xls")
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/TreeViewToExcel486623021.zip