Un autre export excel mais pour le web

Un autre export excel mais pour le web

Messagepar Vince92 » 01 Mars 2006 à 14:20

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>&nbsp;</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
Vince92
Découvre Dominoarea
Découvre Dominoarea
 
Message(s) : 5
Inscrit(e) le : 01 Mars 2006 à 14:12
Localisation : Paris

Messagepar roubech » 17 Juil 2008 à 18:26

variante : export au format csv, qui s'ouvre nativement avec Excel ...

[syntax="LotusScript"]Print "Content-type: text/csv; charset=ISO-8859-1"
Print "titre col1;titre col2;titre col3"
Print doc.champ1(0) & ";" & doc.champ2(0) & ";" & doc.champ3(0)[/syntax]
Avatar de l’utilisateur
roubech
Modérateur
Modérateur
 
Message(s) : 4976
Inscrit(e) le : 01 Fév 2007 à 20:22
Localisation : Lille


Retour vers Importation/Exportation vers d'autres applications