von Stephan » Mo, 09.01.2006 19:14
ausgehend von:
Code: Alles auswählen
sub FarbAenderung 'Füllt die Zellen mit Farbe
oDoc = thisComponent 'das Dokument
oSheet = oDoc.sheets(0) 'erstes Tabellenblatt
For ze = 4 to 454 'Zeilenzähler
For sp = 2 to 33 'Spaltenzähler
oCell = oSheet.getCellByPosition(sp,ze)
if oCell.string = "" then oCell.CellBackColor = RGB(255,255, 255) 'keine Farbe
if oCell.string = "J" then oCell.CellBackColor = RGB(0,102, 204) 'Jahresurlaub blau
if oCell.string = "H" then oCell.CellBackColor = RGB(0,102, 204) 'halber Urlaubstag blau
if oCell.string = "K" then oCell.CellBackColor = RGB(250,255, 102) 'Krank gelb
if oCell.string = "B" then oCell.CellBackColor = RGB(0,174, 0) 'Berufsschule grün
if oCell.string = "W" then oCell.CellBackColor = RGB(255,153, 102) 'Weiterbildung orange
if oCell.string = "U" then oCell.CellBackColor = RGB(255,51, 51) 'Fehlen unentschuldigt rot
next
next
end sub
was bei mir etwa 46 Sekunden läuft, ist:
Code: Alles auswählen
Sub FarbAenderung_2()
oDoc = thisComponent 'das Dokument
oSheet = oDoc.sheets(0) 'erstes Tabellenblatt
For ze = 4 to 454 'Zeilenzähler
For sp = 2 to 33 'Spaltenzähler
oCell = oSheet.getCellByPosition(sp,ze)
Select Case oCell.String
Case ""
oCell.CellBackColor = -1
Case "J"
oCell.CellBackColor = RGB(0,102, 204)
Case "H"
oCell.CellBackColor = RGB(0,102, 204)
Case "K"
oCell.CellBackColor = RGB(250,255, 102)
Case "B"
oCell.CellBackColor = RGB(0,174, 0)
Case "W"
oCell.CellBackColor = RGB(255,153, 102)
Case "U"
oCell.CellBackColor = RGB(255,51, 51)
End Select
next
next
End Sub
mit etwa 40 Sekunden nicht wesentlich schneller (ich hätte mehr erwartet).
Somit ergäbe sich:
Code: Alles auswählen
Sub FarbAenderung_3()
oSelect=ThisComponent.CurrentSelection
oColumn=oselect.Columns
oRow=oSelect.Rows
For n= 0 To oColumn.getCount-1
For m = 0 To oRow.getCount-1
oCell=oselect.getCellByPosition (n, m)
Select Case oCell.String
Case ""
oCell.CellBackColor = -1
Case "J"
oCell.CellBackColor = RGB(0,102, 204)
Case "H"
oCell.CellBackColor = RGB(0,102, 204)
Case "K"
oCell.CellBackColor = RGB(250,255, 102)
Case "B"
oCell.CellBackColor = RGB(0,174, 0)
Case "W"
oCell.CellBackColor = RGB(255,153, 102)
Case "U"
oCell.CellBackColor = RGB(255,51, 51)
End Select
next
next
End Sub
Gruß
Stephan
ausgehend von:
[code]sub FarbAenderung 'Füllt die Zellen mit Farbe
oDoc = thisComponent 'das Dokument
oSheet = oDoc.sheets(0) 'erstes Tabellenblatt
For ze = 4 to 454 'Zeilenzähler
For sp = 2 to 33 'Spaltenzähler
oCell = oSheet.getCellByPosition(sp,ze)
if oCell.string = "" then oCell.CellBackColor = RGB(255,255, 255) 'keine Farbe
if oCell.string = "J" then oCell.CellBackColor = RGB(0,102, 204) 'Jahresurlaub blau
if oCell.string = "H" then oCell.CellBackColor = RGB(0,102, 204) 'halber Urlaubstag blau
if oCell.string = "K" then oCell.CellBackColor = RGB(250,255, 102) 'Krank gelb
if oCell.string = "B" then oCell.CellBackColor = RGB(0,174, 0) 'Berufsschule grün
if oCell.string = "W" then oCell.CellBackColor = RGB(255,153, 102) 'Weiterbildung orange
if oCell.string = "U" then oCell.CellBackColor = RGB(255,51, 51) 'Fehlen unentschuldigt rot
next
next
end sub[/code]
was bei mir etwa 46 Sekunden läuft, ist:
[code]Sub FarbAenderung_2()
oDoc = thisComponent 'das Dokument
oSheet = oDoc.sheets(0) 'erstes Tabellenblatt
For ze = 4 to 454 'Zeilenzähler
For sp = 2 to 33 'Spaltenzähler
oCell = oSheet.getCellByPosition(sp,ze)
Select Case oCell.String
Case ""
oCell.CellBackColor = -1
Case "J"
oCell.CellBackColor = RGB(0,102, 204)
Case "H"
oCell.CellBackColor = RGB(0,102, 204)
Case "K"
oCell.CellBackColor = RGB(250,255, 102)
Case "B"
oCell.CellBackColor = RGB(0,174, 0)
Case "W"
oCell.CellBackColor = RGB(255,153, 102)
Case "U"
oCell.CellBackColor = RGB(255,51, 51)
End Select
next
next
End Sub[/code]
mit etwa 40 Sekunden nicht wesentlich schneller (ich hätte mehr erwartet).
Somit ergäbe sich:
[code]Sub FarbAenderung_3()
oSelect=ThisComponent.CurrentSelection
oColumn=oselect.Columns
oRow=oSelect.Rows
For n= 0 To oColumn.getCount-1
For m = 0 To oRow.getCount-1
oCell=oselect.getCellByPosition (n, m)
Select Case oCell.String
Case ""
oCell.CellBackColor = -1
Case "J"
oCell.CellBackColor = RGB(0,102, 204)
Case "H"
oCell.CellBackColor = RGB(0,102, 204)
Case "K"
oCell.CellBackColor = RGB(250,255, 102)
Case "B"
oCell.CellBackColor = RGB(0,174, 0)
Case "W"
oCell.CellBackColor = RGB(255,153, 102)
Case "U"
oCell.CellBackColor = RGB(255,51, 51)
End Select
next
next
End Sub[/code]
Gruß
Stephan