[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

Excel spreadsheet in IE (did a Domino R5 Agent) - need to know how to have the agent create a second worksheet

Agent name is "ExportCompleted.xls.  In the Initialize section of my agent, I have the following code:

Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim excel As Variant
      Dim worksheet As Variant
      Dim cell As Variant
      Dim view As NotesView
      Dim nav As NotesViewNavigator
      Dim entry As NotesViewEntry
      Dim rowNum As Integer
      
      Print {Content-Type:application/vnd.ms-excel}
      Print {<HTML><HEAD>}
      Print {</HEAD>}
      Print {<BODY>}
      Print {<TABLE>}
      Print {<TR>}
      Print {<TD WIDTH="65"><B>AI Change No</B></TD>}
      Print {<TD WIDTH="100"><B>Status</B></TD>}
      Print {<TD WIDTH="90"><B>Date Rcvd</B></TD>}
      Print {<TD WIDTH="120"><B>Requestor</B></TD>}            
      Print {<TD WIDTH="150"><B>Platform</B></TD>}
      Print {<TD WIDTH="120"><B>Servers Impacted</B></TD>}
      Print {<TD WIDTH="160"><B>Applications Impacted</B></TD>}
      Print {<TD WIDTH="200"><B>Type of Change</B></TD>}      
      Print {<TD WIDTH="150"><B>Red Watch</B></TD>}
      Print {<TD WIDTH="160"><B>Start Date/Time</B></TD>}      
      Print {<TD WIDTH="160"><B>End Date/Time</B></TD>}                  
      Print {<TD WIDTH="80"><B>Chg Ticket Rcvd</B></TD>}                  
      Print {<TD WIDTH="90"><B>Risk</B></TD>}            
      Print {<TD WIDTH="140"><B>Mop/Backout Plan Received</B></TD>}      
      Print {<TD WIDTH="400"><B>Scheduling Status</B></TD>}            
      Print {<TD WIDTH="140"><B>NFC Created for REDWATCH Apps</B></TD>}            
      Print {<TD WIDTH="120"><B>Duration & Outage</B></TD>}            
      Print {<TD WIDTH="400"><B>Details of Change</B></TD>}            
      Print {<TD WIDTH="120"><B>Scheduling Prime</B></TD>}            
      Print {<TD WIDTH="150"><B>IBM/CSA Contact</B></TD>}            
      
      Print {</TR>}
      
      rowNum = 2
' Current row of data
      
   ' Get a NotesViewNavigator from our view
      Set db = session.CurrentDatabase
      Set view = db.GetView("AI_CRCompleted")
      Set nav = view.CreateViewNav
      Set entry = nav.GetFirst
      
       ' Go through all the entries in the view
      While Not entry Is Nothing
            Print {<TR>}
            Print {<TD>} & entry.ColumnValues(2) & {</TD>}
            Print {<TD>} & entry.ColumnValues(3) & {</TD>}
            Print {<TD>} & entry.ColumnValues(4) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(5)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(6)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(7)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(8)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(9)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(10)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(11)) & {</TD>}
            
            Print {<TD>} & Cstr(entry.ColumnValues(12)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(13)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(14)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(15)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(16)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(17)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(18)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(19)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(20)) & {</TD>}
            Print {<TD>} & Cstr(entry.ColumnValues(21)) & {</TD>}
            
            Print {</TR>}
            
            rowNum = rowNum + 1
            Set entry = nav.GetNext(entry)
      Wend
      
      
      Print "</TABLE></BODY></HTML>"
      
End Sub

My questions is that I have another agent that outputs "Cancelled requests" using the same columns.  How can I have that report outputting to the same spreadsheet but in another worksheet when I run my agent?  

The code for the cancelled requests is the same except the view name is different.


0
mermaidink
Asked:
mermaidink
  • 3
  • 2
  • 2
2 Solutions
 
SysExpertCommented:
From WHat I can see, you are using HTML to create an excel compatible table.

I do not see the use of the variables defined

  Dim worksheet As Variant
     Dim cell As Variant

Anywhere in your code.

I would say that via HTML it will NOT be possible,  you will need to do it using either Excel VBA or COM objects in Excel or Notes.


I hope this helps !
0
 
marilyngCommented:
Near as I can tell, you're creating your excel spreadsheet using html?  And by using the content type, you're using the excel viewer in a browser to display an excel spreadsheet.

Since you're not activating the excel object directly, you can't tell it to create a workbook and then another worksheet, only to create another html page.

Is there a particular reason you did it this way?  It is clever, I must admit :)

If you, instead, used the com objects, then adding a worksheet becomes really easy:

Something like this:

        Set xlApp = CreateObject("Excel.Application")
      xlApp.Visible = False 'hide Excel while processing
      xlApp.Workbooks.Add      
      xlApp.ReferenceStyle = 2
      Set xlSheet = xlApp.Workbooks(1).Worksheets(1)
      xlSheet.Name = "Lotus Export"
        Set xlSheet2 = xlApp.Workbooks(1).Worksheets(2)
        if xlSheet2 is nothing then
             Set xlSheet2 = xlApp.Workbooks(1).Worksheets.add
        end if
             xlSheet2.Name = "Another Name"
--------

But I can be wrong, so wait for someone else to decide if you can add another worksheet using html.. hmm.. you could if you printed out to xml, and defined the second worksheet in the xml style sheet..

That's all I have!

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
marilyngCommented:
Sorry, Mike, I didn't refresh when I posted my comments, so yours weren't there.  

I like Qwaletee's comment about the excel export posted at Q_20819577 :  "That's some messed up code..."  ;)

A Nice. clean example: http://www.bluestream.org/Domino/ExportToExcelViaNotes.htm

Here are others:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21826566.html
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21828050.html

Multiple Worksheets:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_20255907.html

Regards!
0
 
mermaidinkAuthor Commented:
The code I attached does work. It creates an excel sheet in the browser.  I will have to look at those links in your comments and see  how I can alter the code.
0
 
mermaidinkAuthor Commented:
From a link given by marilyng, I got to this page.  My users are on the web and don't have Notes.  This is why I wrote the initial one in HTML.  
Would this type of solution (link below) have a coding ability to do multiple worksheet when exporting to excel via a web browser?
http://www.bluestream.org/Domino/ExportToExcelViaWeb.htm

I also looked closely at Q_20255907 and didn't know if that was for exporting to excel to the WEB...

Can someone clarify?


0
 
marilyngCommented:
No, none of the links I posted, nor sysExpert's links will export to web.  You would have to use the link examples to create your Excel objects and export Notes to excel, then use the Excel methods and properties to export  EACH worksheet to  an html file.  You can probably do this all in Lotus Script.

Question - Why not just flash the Notes form or view on the web?  users can be assigned an html name and password in a secondary address book, and can hit the web page via a browser using the internal server name:  http://notesserver/database.nsf/Viewname?OpenView

The server has to be running the http task, and port 80 needs to be available to the internal users.  (So, you don't have to enable port 80 externally if you don't want to)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now