SumCellsShade = 35
SCellsShade = 34
Dim WS As New NotesUIWorkspace
Set session = New NotesSession
Set db=session.CurrentDatabase
Dim fd As NotesDocumentCollection
Set uidoc = ws.CurrentDocument
formul = {date_priem >=[} & uidoc.FieldGetText("date1") & {] & date_priem <=[} & uidoc.FieldGetText("date2") & {]}
Set v=db.GetView("u_svod_rep")
v.SelectionFormula = formul
Call v.Refresh
'Call v.ViewRebuild
Set tst=v.GetFirstDocument
If tst Is Nothing Then
answ = Messagebox("Нет данных за данный период!" , MB_OK+MB_ICONINFORMATION,"Нет данных")
Exit Sub
End If
Print "Идет создание отчета. Пожалуйста подождите..."
Set xl = CreateObject("Excel.Application")
Set xlWbk = xl.Workbooks.Add("c:\lotus\rep_svod_1.xlt")
xlWbk.ActiveSheet.Rows("6:6").Select
row=6
Set docX=v.GetFirstDocument
values=Split(docX.ColumnValues(0),", ")
Forall vl In values
vals="urep "& vl
If Not docX Is Nothing Then
Call docX.PutInFolder(vals,True)
End If
End Forall
While Not docX Is Nothing
Set docX=v.GetNextDocument(docX)
If Not docX Is Nothing Then
values=Split(docX.ColumnValues(0),", ")
Forall vl In values
vals="urep "& vl
Call docX.PutInFolder(vals,True)
End Forall
End If
Wend
doccount=0
col=1
Set v=db.GetView("(ispolnotels)")
If Not v Is Nothing Then
Set docX=v.GetFirstDocument
End If
doccount_sum = 0
control_count_sum = 0
count_rassm_sum=0
count_ud_rassm_sum=0
count_us_rassm_narush_sum =0
count_ost_rassm_sum=0
count_ost_rassm_dop_contr_sum=0
srow = False
While Not docX Is Nothing
doccount=0
values=Split(docX.ColumnValues(1),", ")
Forall vl In values
vals="urep "& vl
Set v1=db.GetView(vals)
If Not v1 Is Nothing Then
Set docx1=v1.GetFirstDocument
control_count=0
count_rassm=0
count_ud_rassm=0
count_us_rassm_narush =0
count_ost_rassm=0
count_ost_rassm_dop_contr=0
count_ost_rassm_narush=0
While Not docX1 Is Nothing
doccount=doccount+1
If docX1.ColumnValues(4)="Контроль" Then
control_count=control_count+1
control_count_sum = control_count_sum +1
End If
If docX1.ColumnValues(5)<>"" Then
count_rassm=count_rassm+1
count_rassm_sum=count_rassm_sum+1
End If
If docX1.ColumnValues(5)<>4 Then
If docX1.ColumnValues(5)<>"" Then
count_ud_rassm=count_ud_rassm+1
count_ud_rassm_sum=count_ud_rassm_sum+1
End If
End If
If docX1.ColumnValues(2)<docX1.ColumnValues(6) Then
count_us_rassm_narush=count_us_rassm_narush+1
End If
If docX1.ColumnValues(2)<docX1.ColumnValues(6) Then
If docX1.ColumnValues(5)="" Then
count_ost_rassm_narush_sum=count_ost_rassm_narush_sum+1
count_ost_rassm_narush=count_ost_rassm_narush+1
End If
End If
If docX1.ColumnValues(7)="Доп контроль" Then
count_ost_rassm_dop_contr=count_ost_rassm_dop_contr+1
count_ost_rassm_dop_contr_sum=count_ost_rassm_dop_contr_sum+1
End If
Set docX1=v1.GetNextDocument(docX1)
Wend
If srow=True Then
scel=SCellsShade
Else
scel=2
End If
xlWbk.ActiveSheet.Cells(row, col)=docX.ColumnValues(1)
xlWbk.ActiveSheet.Cells(row, col).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+1)=docX.ColumnValues(0)
xlWbk.ActiveSheet.Cells(row, col+1).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+1).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+2)=doccount
xlWbk.ActiveSheet.Cells(row, col+2).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+2).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+3)=control_count
xlWbk.ActiveSheet.Cells(row, col+3).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+3).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+4)=count_rassm
xlWbk.ActiveSheet.Cells(row, col+4).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+4).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+5)=count_ud_rassm
xlWbk.ActiveSheet.Cells(row, col+5).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+5).Interior.ColorIndex = scel
If count_rassm<>0 Then
xlWbk.ActiveSheet.Cells(row, col+6)=count_us_rassm_narush
xlWbk.ActiveSheet.Cells(row, col+6).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+6).Interior.ColorIndex = scel
Else
xlWbk.ActiveSheet.Cells(row, col+6)=0
xlWbk.ActiveSheet.Cells(row, col+6).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+6).Interior.ColorIndex = scel
End If
xlWbk.ActiveSheet.Cells(row, col+7)=doccount-count_rassm
xlWbk.ActiveSheet.Cells(row, col+7).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+7).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+8)=count_ost_rassm_narush
xlWbk.ActiveSheet.Cells(row, col+8).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+8).Interior.ColorIndex = scel
xlWbk.ActiveSheet.Cells(row, col+9)=count_ost_rassm_dop_contr
xlWbk.ActiveSheet.Cells(row, col+9).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+9).Interior.ColorIndex = scel
doccount_sum = doccount_sum + doccount
row=row+1
srow=Not srow
End If
End Forall
Set docX=v.GetNextDocument(docX)
Wend
xlWbk.ActiveSheet.Cells(row, col+1)="Итого"
xlWbk.ActiveSheet.Cells(row, col+1).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+2)=doccount_sum
xlWbk.ActiveSheet.Cells(row, col+2).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+2).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+3)=control_count_sum
xlWbk.ActiveSheet.Cells(row, col+3).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+3).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+4)=count_rassm_sum
xlWbk.ActiveSheet.Cells(row, col+4).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+4).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+5)=count_ud_rassm_sum
xlWbk.ActiveSheet.Cells(row, col+5).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+5).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+6)=count_us_rassm_narush_sum
xlWbk.ActiveSheet.Cells(row, col+6).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+6).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+7)=doccount_sum-count_rassm_sum
xlWbk.ActiveSheet.Cells(row, col+7).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+7).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+8)=count_ost_rassm_narush_sum
xlWbk.ActiveSheet.Cells(row, col+8).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+8).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(row, col+9)=count_ost_rassm_dop_contr_sum
xlWbk.ActiveSheet.Cells(row, col+9).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row, col+9).Interior.ColorIndex = SumCellsShade
xlWbk.ActiveSheet.Cells(3,1)="с " & uidoc.FieldGetText("date1") & " по " & uidoc.FieldGetText("date2")
xlWbk.ActiveSheet.Range("A7").Select
xl.Visible=True
Print "Создание отчета завершено"