Creating Excel Spreadsheets in IE

xiaoxiao2021-03-06  80

Let's Use the Same Example You Have A View, Column 1 IS Categorized, Column 2 and 3 Are Totals. In The Spreadsheet, Columns D and e Will Be Computed.

To make things easy, let's do this in an agent. So the URL will be .... agentName? OpenAgent. The simplest way to create a spreadsheet is to send an HTML table directly to Excel in your agent. This is done by setting The Content Type in your agent. The content type will send the information directly to excel. here's an example:

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 { } print {} print {

} Print {} print {
Conference } print { Home Wins } print { Home win% } print { cumulative win% < / B> } print {}

The Content Type of

application / vnd.ms-excel tells the browser to use Excel. Then we simply build a table. The first row, we set the column widths and put the headers in bold. (Last week we set the column widths and made the headers bold After Everything else Was Done). The Same Variables Will Be Needed this time.

rowNum = 2 'Current row of data' Get a NotesViewNavigator from our view Set db = session.CurrentDatabase Set view = db.GetView ( "vwByConference") Set nav = view.CreateViewNav Set entry = nav.GetFirstThis is the same as last week - setting up the view navigator.

'Go Through all the entries in the view while not entry is nothing print {

} & entry.columnvalues ​​(0) & { }print {} & cstr (entry .COLUMNVALUES (1)) & {} Print {} & cstr (entry.columnvalues ​​(2)) & {} Print { = B} & cstr (Rownum) & {/ (B} & cstr (Rownum) & { C} & cstr (Rownum) & {) } print { = SUM (B2..b} & cstr (rower) & {) / (SUM (B2..b} & cstr (rownum) & {) sum (C2..c} _ & cstr (rownum) & {)) } print {} rownum = rownum 1 set entry = nav.getnextcategory (entry) Wend

This is a little different than last week. This time, we are printing out HTML that will end up being the cell values. Columns A, B, and C are straightforward. For columns D and E, we want to create a formula. That's Why We Start Out The Cell Data with The Equals Sign. Then It's The formula, in The Same Way You Would Type It in To Excel. So, For Row # 4, The Value in Column D Will BE

= B4 / (B4 C4). Again, for the "cumulative" Row, The Sum is Computed from Row 2 THROUGH The CURRENT ROW.

Print " " End Sub

Since all the formatting was done in The first row of the table, nothing more is needed

转载请注明原文地址:https://www.9cbs.com/read-107258.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.040, SQL: 9