Programmierung unter AOO/LO (StarBasic, Python, Java, ...)
Moderator: Moderatoren
-
Stephan
- ********
- Beiträge: 12368
- Registriert: Mi, 30.06.2004 19:36
- Wohnort: nahe Berlin
Beitrag
von Stephan »
Ich verstehe das genaue Ziel nicht, also wo die Texte hin sollen.
Folgendes Makro schreibt sie in Spalte A einer Calc-Tabelle:
Code: Alles auswählen
Sub Main
txt = ""
For i = 1 to 999
tmp = String(4-LEN(i),"0") & i
txt = txt & "<a href=""img/Fotos/Bild"
txt = txt & tmp
txt = txt & ".jpg"" data-lightbox=""Obst""><img src=""img/Fotos/Bild"
txt = txt & tmp
txt = txt & "_thumbnail.jpg""></a>"
ThisComponent.Sheets(0).getCellRangeByName("A"&i).String = txt
txt = ""
Next i
End Sub
Gruß
Stephan
-
Dateianhänge
-
- texte0001-0999.ods
- (9.32 KiB) 56-mal heruntergeladen
-
Karolus
- ********
- Beiträge: 7535
- Registriert: Mo, 02.01.2006 19:48
Beitrag
von Karolus »
Hallo
Ich schieb hier mal zum Vergleichen nach wie das in Python ginge:
Code: Alles auswählen
def nummerierung():
template =( '<a href="img/Fotos/Bild{0:04d}.jpg" '
'data-lightbox="Obst"><img src="img/Fotos/Bild'
'{0:04d}_thumbnail.jpg"></a>'.format )
doc = XSCRIPTCONTEXT.getDocument()
sheet = doc.Sheets.getByIndex(0)
out = [(template(x),) for x in range(1,1256)]
crange = sheet.getCellRangeByPosition(0,0,0,len(out)-1)
crange.DataArray =tuple( out )
Karolus
LO7.4.7.2 debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)