Skip to main content
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks

  

Sign in to participate PreviousPrevious NextNext

RE: Export to Excel for Categorized view thru LS
The Capable 17.May.11 11:40 AM a Web browser
Applications Development All Releases Windows 2000


Well Finner!

I wasn't looking for stupid advices but some concrete assistance. Anyway I could code it on my own and here is the logic:

(Action) Excel to Excel

Dim ws As NotesUIWorkspace
Dim uiview As NotesUIView
Dim view As NotesView
Dim nav As NotesViewNavigator
Dim entrya As NotesViewEntry
Dim thisdoc As NotesDocument
Dim response As Variant
Dim values(1) As Variant
Dim excel As Variant
Dim excelWorkbook As Variant
Dim excelSheet As Variant
Dim row, col As Integer
Sub Click(Source As Button)
'Trap any errors that occur:
On Error Goto ErrorTrap
Set ws=New NotesUIWorkspace
'Get handle on current view:
Set uiview = ws.CurrentView
Set view = uiview.View
view.AutoUpdate = False
'Exit if there are no documents in view:
If (view.AllEntries.Count = 0) Then
Msgbox "No Entries in the view",16,"Export to Excel"
Exit Sub
End If
'Create excel object:
Set excel = CreateObject("Excel.Application")
'Create excel workbook:
Set excelWorkbook = excel.Workbooks.Add
'Create excel sheet:
Set excelSheet = excelWorkbook.Sheets(1)
'Format excel data:
excel.Cells.select
excel.Selection.Font.Name = "Arial"
excel.Selection.Font.Size = 8
excel.Selection.ColumnWidth = 10
excel.Selection.WrapText = False
'Format excel headers:
excel.Rows("1:1").Select
excel.Selection.Font.Bold = True
'Set colum counter:
col = 1
'Set row counter:
row = 1
'Add column headers:
Forall column In view.Columns
excelSheet.Cells(row, col).value = column.Title
col = col + 1
End Forall
row = row + 1
values(0) = "SingleCategory"
values(1) = "AllCategories"
response = ws.Prompt (PROMPT_OKCANCELCOMBO, "Select a type", "Select a type to Export.", values(0), values)
If Isempty (response) Then
Messagebox "User canceled", , "Export to Excel"
Exit Sub
End If
If response="SingleCategory" Then
'Call Singlecat() ' Need ot complete it
Else
Call AllCat()
End If
'Display file:
excel.ActiveSheet.Range("A1").Select
excel.Visible = True
excelSheet.Range("R2:S4").Select
excel.Charts.Add
'excelSheet.ActiveChart.ChartType = xl3DPie
xlChartType = -4102 'code of 3DPie chart
xlLocationAsObject = 2
With excel.ActiveWorkbook.ActiveChart
.Name = "Type of Documents"
.ChartType = -4102 'code of 3DPie chart
.Location 2, "Sheet1" 'move chart to worksheet
End With
excel.ActiveSheet.ChartObjects("Chart 1").Activate
excel.ActiveChart.ChartArea.Select 'select chart
'The below lines between With - End WIth doesn't work in the above block, I guess the Chart should be selected to set the below properties
Dim ochart, oseries, olabel As Variant
Set ochart=excel.ActiveWorkbook.ActiveChart
'http://vbcity.com/forums/t/81102.aspx
With ochart
.HasTitle = True
.ChartTitle.Characters.Text = "Data Distribution"
End With
ochart.SeriesCollection(1).HasDataLabels = True
oChart.HasLegend = True
excel.ActiveSheet.Shapes("Chart 1").IncrementLeft -750
excel.ActiveSheet.Shapes("Chart 1").IncrementTop 140
excel.ActiveSheet.Shapes("Chart 1").ScaleWidth 0.7, msoFalse,msoScaleFromTopLeft 'change chart dimensions
excel.ActiveSheet.Shapes("Chart 1").ScaleHeight 0.7, msoFalse, msoScaleFromBottomRight
excel.ActiveSheet.Range("A1").Select
'Call method to recycle objects:
Goto RecycleObjects
Exit Sub
'Method used to recycle objects:
RecycleObjects:
Set excelSheet = Nothing
Set excelWorkbook = Nothing
Set excel = Nothing
Set view = Nothing
Set uiview = Nothing
Exit Sub
'Method used to handle any errors:
ErrorTrap:
Msgbox "Unable to export file due to the following error:" & Chr(10) & Chr(10) & "ERROR on line " & Cstr(Erl) & " (" & Cstr(Err) & ") - " & Error$, 16, "Export to Excel - Click"
If Not (excel Is Nothing) Then
excel.ActiveSheet.Range("A1").Select
excel.Visible = True
End If
Goto RecycleObjects
Exit Sub
End Sub
Sub Firstlogic
Dim counter As Integer
Dim countername As String
counter=0
While Not entrya Is Nothing
col = 1
'Loop thru column values:
Forall column In entrya.ColumnValues
If col= 3 Then countername = columnValue
'Get column value:
If Isarray(column) Then
columnValue = Fulltrim(Join(column))
Else
columnValue = column
End If
'Add entry to excel:
excelSheet.Cells(row, col).value = columnValue
'Update column counter:
col = col + 1
End Forall
row = row + 1
If entrya.IsDocument Then counter=counter+1
Set entrya=nav.GetNext(entrya)
Wend
excelSheet.Cells(row-1, col+10).value = countername
excelSheet.Cells(row-1, col+11).value = counter
End Sub
Sub SingleCat
values(0) = "India"
values(1) = "US"
response = ws.Prompt (PROMPT_OKCANCELCOMBO, "Select a category", "Select a category to Export.", values(0), values)
If Isempty (response) Then
Messagebox "User canceled", , "Export to Excel"
Exit Sub
End If
Set nav =view.CreateViewNavFromCategory(response)
Set entrya=nav.GetFirst
Call firstlogic()

End Sub
Sub AllCat
'Trap any errors that occur:
On Error Goto ErrorTrap
Dim counter As Integer
Dim countername As String
Dim entryb As NotesViewEntry
Dim PieChartrow As Integer
PieChartrow=2
counter=0
Set nav =view.CreateViewNav()
Set entrya=nav.GetFirst
While Not entrya Is Nothing
col = 1
'Loop thru column values:
Forall column In entrya.ColumnValues
If col= 3 Then countername = columnValue
'Get column value:
If Isarray(column) Then
columnValue = Fulltrim(Join(column))
Else
columnValue = column
End If
'Add entry to excel:
If entrya.IsCategory Then
If col = 1 Then
excelSheet.Cells(row, 1).value = columnValue
Elseif col =2 Then
excelSheet.Cells(row, 2).value = columnValue
End If
End If
If col>2 Then
excelSheet.Cells(row, col).value = columnValue
End If
'Update column counter:
col = col + 1
End Forall
row = row + 1
If entrya.IsDocument Then counter=counter+1
Set entryb=entrya
Set entrya=nav.GetNext(entrya)
If Not entrya Is Nothing Then
If entryb.IsDocument And entrya.IsCategory Then
excelSheet.Cells(PieChartrow, col+10).value = countername
excelSheet.Cells(PieChartrow, col+11).value = counter
counter=0
PieChartrow=PieChartrow+1
End If
Else
excelSheet.Cells(PieChartrow, col+10).value = countername
excelSheet.Cells(PieChartrow, col+11).value = counter
End If
Wend
Exit Sub
'Method used to handle any errors:
ErrorTrap:
Msgbox "Unable to export file due to the following error:" & Chr(10) & Chr(10) & "ERROR on line " & Cstr(Erl) & " (" & Cstr(Err) & ") - " & Error$, 16, "Export to Excel"
If Not (excel Is Nothing) Then
excel.ActiveSheet.Range("A1").Select
excel.Visible = True
End If
Exit Sub
End Sub




Export to Excel for Categorized vie... (The Capable 4.May.11)
. . RE: Export to Excel for Categorized... (Doug Finner 4.May.11)
. . . . Export to Excel for Categorized vie... (The Capable 5.May.11)
. . . . . . RE: Export to Excel for Categorized... (Doug Finner 9.May.11)
. . . . . . . . RE: Export to Excel for Categorized... (The Capable 17.May.11)
. . . . . . . . . . RE: Export to Excel for Categorized... (Doug Finner 17.May.11)
. . . . . . . . . . . . RE: Export to Excel for Categorized... (The Capable 18.May.11)
. . . . . . . . . . RE: Export to Excel for Categorized... (Bulent Eskimumc... 27.May.12)
. . RE: Export to Excel for Categorized... (Gary Roberts 6.May.11)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

Sign In or Register

 Sign In or Register
Sign in
Forgot your password?
Forgot your user name?
Create new registration

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
Notes/Domino 4 and 5
IBM Connections
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
IBM SmartCloud Meetings
IBM Web Content Manager
Lotus Domino Document Manager
Lotus e-learning
Lotus Enterprise Integration
Lotus Expeditor
Lotus Protector
Lotus Quickr
Lotus SmartSuite
Lotus Symphony
Lotus Symphony Developer Toolkit Support
Lotus Workflow