Home - Forums-.NET - FlyTreeView (ASP.NET) - Want treeview to be exported in MS word or Excel format

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Want treeview to be exported in MS word or Excel format
Link Posted: 14-Mar-2008 05:37
I want flytreeview to be exported in MS word and Ms Excel format. Can you give me any idea/hint/code so i can get it done.
Link Posted: 14-Mar-2008 05:43
So you need a component/library or a wrapper around MS Office that will provide you an ability to create documents.

To get all nodes from treeview, you can use the FlyTreeView.FindAll(..) method, or just recursively loop through the FlyTreeView.Nodes and Node.ChildNodes collections.
Link Posted: 25-Mar-2008 19:26


Dim NumberOfCharacters As Integer = 2

Private Sub ExportFile()

                Dim fp As StreamWriter
                Dim FilePath As String
                Dim Stream As String
                FilePath = Server.MapPath(".\FolderToBeSavedin\") & "anyfile.doc"
                fp = File.CreateText(FilePath)
                Stream = GetStreamForAllNode()
                fp.WriteLine(Stream)
                fp.Close()
                fp.Dispose()

End Sub


Function GetStreamForAllNode()
            Dim node As FlyTreeNode
            Dim sb As New StringBuilder()
            Dim Level As Integer = 0
            For Each node In TV.Nodes
                sb.AppendLine("".PadLeft(Level * NumberOfCharacters, "-") & node.Text)
                If node.ChildNodes.Count > 0 Then
                    Level += 1
                    AppendChildNodes(sb, Level, node)
                    Level -= 1
                End If
            Next
            GetStreamForAllNode = sb.ToString()
        End Function


Sub AppendChildNodes(ByRef psb As StringBuilder, ByRef pLevel As Integer, ByRef pnode As FlyTreeNode)
            Dim node As FlyTreeNode
            For Each node In pnode.ChildNodes
                psb.AppendLine("".PadLeft(pLevel * NumberOfCharacters, "-") & node.Text)
                If node.ChildNodes.Count > 0 Then
                    pLevel += 1
                    AppendChildNodes(psb, pLevel, node)
                    pLevel -= 1
                End If
            Next

        End Sub