von CAD » Do, 25.10.2018 09:00
mikeleb hat geschrieben: ↑Mi, 17.10.2018 22:21
Hallo,
eine mögliche Variante:
Code: Alles auswählen
Sub Main
Dim datum as long
odoc=thiscomponent
otab=odoc.currentcontroller.activesheet
ocur=otab.createcursor
ocur.gotoendofusedarea(false)
n=ocur.rangeaddress.startrow
obereich=otab.getcellrangebyposition(1,1,3,n)
adaten()=obereich.getdataarray
for i=0 to ubound(adaten)
wert=adaten(i)(0)
if wert<>"" then
stext=format(wert,"00\.00\.0000")
if isdate(stext) then
datum=cdate(stext)
adaten(i)(0)=datum
end if
end if
wert=adaten(i)(2)
if wert<>"" then
stext=format(wert,"00\.00\.0000")
if isdate(stext) then
datum=cdate(stext)
adaten(i)(0)=datum
end if
end if
next
obereich.setdataarray(adaten())
Dim Localformat as new com.sun.star.lang.Locale
numberformats = odoc.numberformats
numberformatstring = "TT.MM.JJ"
numberformatid = numberformats.queryKey(numberformatstring, Localformat, True)
if numberformatId = -1 then
numberformatId = numberformats.addNew(numberformatstring,Localformat)
end if
otab.columns(1).numberformat=numberformatid
otab.columns(3).numberformat=numberformatid
End Sub
Hallo, vielen herzlichen Dank, für die zweite Spalte funktioniert das einwandfrei, bei der vierten gibt er aber falsche Daten aus.
[quote=mikeleb post_id=278573 time=1539807706 user_id=43151]
Hallo,
eine mögliche Variante:
[code]Sub Main
Dim datum as long
odoc=thiscomponent
otab=odoc.currentcontroller.activesheet
ocur=otab.createcursor
ocur.gotoendofusedarea(false)
n=ocur.rangeaddress.startrow
obereich=otab.getcellrangebyposition(1,1,3,n)
adaten()=obereich.getdataarray
for i=0 to ubound(adaten)
wert=adaten(i)(0)
if wert<>"" then
stext=format(wert,"00\.00\.0000")
if isdate(stext) then
datum=cdate(stext)
adaten(i)(0)=datum
end if
end if
wert=adaten(i)(2)
if wert<>"" then
stext=format(wert,"00\.00\.0000")
if isdate(stext) then
datum=cdate(stext)
adaten(i)(0)=datum
end if
end if
next
obereich.setdataarray(adaten())
Dim Localformat as new com.sun.star.lang.Locale
numberformats = odoc.numberformats
numberformatstring = "TT.MM.JJ"
numberformatid = numberformats.queryKey(numberformatstring, Localformat, True)
if numberformatId = -1 then
numberformatId = numberformats.addNew(numberformatstring,Localformat)
end if
otab.columns(1).numberformat=numberformatid
otab.columns(3).numberformat=numberformatid
End Sub
[/code]
[/quote]
Hallo, vielen herzlichen Dank, für die zweite Spalte funktioniert das einwandfrei, bei der vierten gibt er aber falsche Daten aus.