Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please help me guys,

i'm newbie in asp.net(vb). Now i'm still doing the project that using aspxtreelist as the data display. I want to export tools (aspxtextbox,aspxlabel, aspxcombobox, etc) to excel format. I alreaday use treelist node iterator and treelistexporter, it's only export the data from treelist not from the other tools. it's does not meet our requirement. Please help me to export the other tools(i mean full web layout).

i want to export this format

aspxLabel
aspxlabel aspxcheckbox aspxdateedit
~ aspxdateedit aspxlabel aspxcombobox aspxtextbox
aspxlabel aspxtextbox
aspxtreelist

when i use treelist exporter it's only the data from treelist i can export to excel like this project No Project ID ProjectName Cause the data from aspxlabel and the others can't be export i need the code to export them. or any other way i can upload an attachment that contain my sample project

Thanks for your help

regards, gautier
Posted
Updated 2-Feb-15 15:58pm
v6
Comments
Sinisa Hajnal 28-Jan-15 7:54am    
This is not free-code-service. Do some research, create some code and if you find the problem you cannot resolve, come back and ask the question with the relevant code, information about what you tried and how it doesn't behave as you expected it to.
Member 11407164 1-Feb-15 21:13pm    
Hello Sinisa

Do you read all of my question or you just read some part of it?

I already do some research for a month before i asked this question, some professional just give up and a few said there's no function to export full layout when you use treelist

this is the last code i made(only a sample):

Private Sub FormatExcel(ByVal pExl As Microsoft.Office.Interop.Excel.Application)

Const ColorOrange As Single = 49407

With pExl

.Range("A1:A5").EntireRow.Insert(Microsoft.Office.Interop.Excel.XlDirection.xlDown)
.Range("A1").Value = "Title"
.Range("A1").Font.Bold = True
.Range("A1").Font.Size = 11
.Range("A2").Value = "D1"
.Range("A3").Value = "D2"
.Range("B2").Value = "XXXXXXXXXX"
.Range("B3").Value = "XXXXXXXXXX"



If ChkDate.Value = "1" Then
.Range("A4").Value = "EXPECTED DELIVERY DATE"
.Range("B4").Value = " " & DT1.Value
.Range("C4").Value = "~"
.Range("D4").Value = " " & DT2.Value
Else
.Range("A4").Value = ""
End If

.Range("A5").Value = "D3"
.Range("B5").Value = Cbo3.Text
.Range("C5").Value = Tx1.Text
.Range("A7").Value = "C2"
.Range("B7").Value = Cbo2.Text
.Range("E5").Value = "C1"
.Range("F5").Value = Cbo1.Text
.Range("E6").Value = " EX1 "

.Range(.Cells(9, 1), .Cells(9, 1)).Value = "PROJECT NO."
.Range(.Cells(9, 2), .Cells(9, 2)).Value = "ORDER NO."
.Range(.Cells(9, 3), .Cells(9, 3)).Value = "PROJECT NAME"

For I = 2 To 5
.Range(.Cells(0, I), .Cells(0, I)).ColumnWidth = 27
Next

Dim rgAll As Microsoft.Office.Interop.Excel.Range = .Range(.Cells(9, 1), .Cells(Grid1.VisibleRowCount + 9, 18))
DrawAllBorders(rgAll)

Dim rgHeader1 As Microsoft.Office.Interop.Excel.Range = .Range(.Cells(1, 1), .Cells(1, 18))
rgHeader1.Interior.Color = ColorOrange
rgHeader1.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter
rgHeader1.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter

Dim rgHeader2 As Microsoft.Office.Interop.Excel.Range = .Range(.Cells(9, 1), .Cells(9, 18))
rgHeader2.Interior.Color = ColorOrange
rgHeader2.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter
rgHeader2.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter
End With
End Sub

Private Sub ExportExcel()
Dim Exl As New Microsoft.Office.Interop.Excel.Application
Try
up_GridLoad() 'query for export the data
BtnSaveToExcel.Enabled = False
With Exl
.DisplayAlerts = False
.Workbooks.Add()
.Cells.Select()

Dim rg As Microsoft.Office.Interop.Excel.Range = .Selection
rg.Font.Name = "Verdana"
rg.Font.Size = 9
.Range("A1").Select()

FormatExcel(Exl)
For iRow = 0 To Grid1.VisibleRowCount - 1
.Range(.Cells(iRow + 10, 1), .Cells(iRow + 10, 1)).Value = Grid1.GetRowValues(iRow, "PROJECT_NO")
.Range(.Cells(iRow + 10, 2), .Cells(iRow + 10, 2)).Value = Grid1.GetRowValues(iRow, "ORDER_NO")
.Range(.Cells(iRow + 10, 3), .Cells(iRow + 10, 3)).Value = Grid1.GetRowValues(iRow, "PROJECT_NAME")

Next
.DisplayAlerts = True
.Visible = True

End With
Catch ex As Exception

Exl.Quit()
Exl = Nothing
Finally
BtnSaveToExcel.Enabled = True
End Try
End Sub

Member 11407164 1-Feb-15 21:19pm    
Private Sub BtnSaveToExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSaveToExcel.Click
'Rebind WHCode and Set CboWHCode from Variable

Dim ls_WHCode As String = CboWHCode.Text
Call up_FillComboWarehouse()
CboWHCode.Text = ls_WHCode

Dim ls_Order As String = CboOrderNo.Text
Call up_FillComboOrder()
CboOrderNo.Text = ls_Order

Dim ls_Project As String = CboProjNo.Text
Call up_FillComboProject()
CboProjNo.Text = ls_Project

Dim node1 As TreeListNode
up_GridLoad()
node1 = TreeList1.Nodes(0)
ProcessNodes(node1)

TreeListExporter.WriteXlsToResponse()

TreeListExporter.WriteXlsxToResponse()

Call ExportExcel()
End Sub

that's the code, i already edit and combine some code before i use this excel format with gridview. How to change this gridview export to excel format code to aspxtreelist export to excel format code?

Please help me guys,

Regards Gautier
Sinisa Hajnal 2-Feb-15 3:02am    
Sorry if my comment came out as too harsh, we see lots of "gimme the codez" questions and yours didn't include any mention of finished code.

Now, be so kind and move this code into the question with proper formating. Use Improve question link. You're much more likely to get help that way.

As for the solution, I'd use one of the reporting tools (such as Crystal Reports or FastReports), create a report and use their export functions.

That said, in your first "code comment" you seem to have some idea of how to export into XLS. What is wrong (that is what doesn't go as expected) with the code above?
Member 11407164 2-Feb-15 21:54pm    
Okay no problem, but i mention this: or any other way i can upload an attachment that contain my sample project.Cause if i just post some code, i don't think it will solved my problem.

when i try with treelist exporter it can not export the treelist node data and the other element
when i try with treelist node iterator it can export treelist node data but not for the other element.
so i try to use gridview as the new idea, but it does not meet our needs.
After that i try to asked some of professional and they said no function to export data from treelist, because D***** still does not support to export entire web layout.
Until the rest suggest to use grid export custom format, and still can not export it. I already combine the code with treelist node iterator, change the grid to treelist and as the result it's only export the data from treelist or does not get the data because treelist can't get data from row values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900