Un autre export excel mais pour le web
- Code : Tout sélectionner
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim docX As NotesDocument
Dim col As Integer
Dim lineitem As String
Dim View As String
Set db = session.CurrentDatabase
Print |Content-Type:application/vnd.ms-excel|
Print |Content-Disposition:Attachment; filename="filename.xls"|
On Error Goto errorHandler
'SET YOUR VIEWNAME HERE OR ELSE THE SCRIPT WILL BOMB!
View="vw_stat"
Set v = db.GetView(View$)
Call v.refresh
col=1
Print |<Table border>|
lineitem=""
Forall vColumn In v.Columns
If col=1 Then
lineitem=|<th align="center"><FONT SIZE=3 COLOR="0000FF">|+vColumn.Title
Else
lineitem=lineitem+|<th align="center"><FONT SIZE=3 COLOR="0000FF">|+vColumn.Title
End If
col=col+1
End Forall
lineitem=lineitem
Print lineitem
Set docX=v.GetFirstDocument
lineitem=""
While Not docX Is Nothing
col=1
Forall cValue In docX.ColumnValues
If col=1 Then
lineitem=|<tr>|
End If
If cValue="" Then 'blank value still formats the cell
lineitem=lineitem+|<td> </td>|
Elseif Isdate(cValue) Then 'format date
lineitem=lineitem+|<TD ALIGN="right" STYLE="vnd.ms-excel.numberformat:dd-mmm-yyyy">|+cValue+|</td>|
Elseif Isnumeric(cValue) Then
If (v.columns(col-1).numberformat=3) Then 'format monnetaire
lineitem=lineitem+|<td ALIGN="right" STYLE="vnd.ms-excel.numberformat:$#,##0.00">|+cValue+|</td>|
Else 'autre format nombre
lineitem=lineitem+|<td ALIGN="right">|+cValue+|</td>|
End If
Else 'format text
lineitem=lineitem+|<td>|+cValue+|</td>|
End If
col=col+1
End Forall
Print lineitem+|</tr>|
Set docX=v.GetNextDocument(docX)
Wend
Print |</table>|
Exit Sub
errorHandler:
Print "There has been an error " & Err() & " : " & Error() & " - On Line "+Cstr (Erl) & Chr$(13)
Exit Sub
End Sub