Ändere die Zeile: cliptext = stext zu:
Code: Alles auswählen
cliptext = replace( stext, " ", " " )
Code: Alles auswählen
cliptext = replace( stext, " ", " " )
Code: Alles auswählen
function cliptext()
oclip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oConverter = createUnoService("com.sun.star.script.Converter")
oData = oclip.getContents()
oTypes = oData.getTransferDataFlavors()
for e = 0 to ubound(oTypes)
if oTypes(e).MimeType = "text/plain;charset=utf-16" then
stext = oData.getTransferData( oTypes(e) )
stext = oConverter.convertToSimpleType( stext, 12 )
cliptext = replace( stext, " ", " " )
exit function
end if
next
end function
sub paste_lines_to_rows()
doc = thisComponent
sel = doc.getCurrentSelection()
sheet = sel.getSpreadsheet()
address = sel.getCellAddress()
c = address.Column : r = address.Row
liste = cliptext()
liste() = split( liste, chr(10))
endrow = ubound(liste())
'Anzahl Blöcke
'tmp() = split( liste(0), " " , 2)
'liste(0) = split( tmp(1), " ")
'Inkl. Blockanzahl
liste(0) = split(liste(0), " ")
endcol = ubound(liste(0))
for i = 1 to endrow
if len(liste(i)) then
'liste(i) = split( liste(i), " ", endcol +1 )
liste(i) = split( liste(i), " ")
else
liste(i) = split( space( endcol ), " ")
end if
next i
range = sheet.getCellrangeByPosition( c, r, c + endcol, r + endrow)
range.setFormulaArray( liste())
end sub
Code: Alles auswählen
4 Stat WSP
0.001 71.700
0.002 71.699
12.452 71.717
12.453 71.717
0.001 71.750
0.002 71.748
12.452 71.772
12.453 71.774
Code: Alles auswählen
function cliptext()
oclip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oConverter = createUnoService("com.sun.star.script.Converter")
oData = oclip.getContents()
oTypes = oData.getTransferDataFlavors()
for e = 0 to ubound(oTypes)
if oTypes(e).MimeType = "text/plain;charset=utf-16" then
stext = oData.getTransferData( oTypes(e) )
stext = oConverter.convertToSimpleType( stext, 12 )
cliptext = replace( stext, " ", " " )
exit function
end if
next
end function
sub paste_lines_to_rows()
doc = thisComponent
sel = doc.getCurrentSelection()
sheet = sel.getSpreadsheet()
address = sel.getCellAddress()
c = address.Column : r = address.Row
liste = cliptext()
liste() = split( liste, chr(10))
endrow = ubound(liste())
tmp() = split( liste(0), " " , 2)
liste(0) = split( tmp(1), " ")
endcol = ubound(liste(0))
for i = 1 to endrow
if len(liste(i)) then
liste(i) = split( trim(liste(i)), " ", endcol +1 )
else
liste(i) = split( space( endcol ), " ")
end if
next i
range = sheet.getCellrangeByPosition( c, r, c + endcol, r + endrow)
range.setFormulaArray( liste())
end sub
Karo...
if len(liste(i)) > 4 then 'in rot hinzufügen
liste(i) = left( liste(i) , len(liste(i)-1) ' in rot einfügen
liste(i) = split( trim(liste(i)), " ", endcol +1 )
else
....
funktioniert sowohl bei Selektion einer einzelnen Zelle als auch bei einer Bereichsselektion...
address = sel.getRangeAddress()
c = address.StartColumn : r = address.StartRow
..