import uno
from com.sun.star.awt import FontWeight
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
model = desktop.getCurrentComponent()
sheet = model.CurrentController.ActiveSheet
toplam = 0
for row in range(sheet.Rows.getCount()):
for col in range(sheet.Columns.getCount()):
cell = sheet.getCellByPosition(col, row)
cellColor = cell.getPropertyValue("CellBackColor")
# Sarı rengin RGB kodu
if cellColor == 16776960:
cellValue = cell.getValue()
if isinstance(cellValue, (int, float)):
toplam += cellValue
print("Sarı renkteki hücrelerin toplamı:", toplam)
Function RGBprobe(x , y, optional z)
Dim RGBarray(1 to 3)
oDoc = ThisComponent
oSheet = oDoc.Sheets(0)
'Decreasing coordinate values by 1 because BASIC starts numbering with 0.
If NOT IsMissing(z) Then oSheet = oDoc.Sheets(z-1)
oCell = oSheet.getCellByPosition(x-1,y-1)
CBkC = oCell.CellBackColor
RGBarray(1) = Red(CBkC) : RGBarray(2) = Green(CBkC) : RGBarray(3) = Blue(CBkC)
RGBprobe =RGBarray
End Function
Function RGBprobe(x , y, optional z)
oDoc = ThisComponent
oSheet = oDoc.Sheets(0)
'Decreasing coordinate values by 1 because BASIC starts numbering with 0.
If NOT IsMissing(z) Then oSheet = oDoc.Sheets(z-1)
oCell = oSheet.getCellByPosition(x-1,y-1)
CBkC = oCell.CellBackColor
RGBprobe =CBkC
End Function
Biraz daha net bilgi vereyim."CellBackColor" mış.
Kod:Function RGBprobe(x , y, optional z) Dim RGBarray(1 to 3) oDoc = ThisComponent oSheet = oDoc.Sheets(0) 'Decreasing coordinate values by 1 because BASIC starts numbering with 0. If NOT IsMissing(z) Then oSheet = oDoc.Sheets(z-1) oCell = oSheet.getCellByPosition(x-1,y-1) CBkC = oCell.CellBackColor RGBarray(1) = Red(CBkC) : RGBarray(2) = Green(CBkC) : RGBarray(3) = Blue(CBkC) RGBprobe =RGBarray End Function
Hatta RGB değerleriyle ayrı ayrı uğraşmamak için şöyle sadeleştirin:
Kod:Function RGBprobe(x , y, optional z) oDoc = ThisComponent oSheet = oDoc.Sheets(0) 'Decreasing coordinate values by 1 because BASIC starts numbering with 0. If NOT IsMissing(z) Then oSheet = oDoc.Sheets(z-1) oCell = oSheet.getCellByPosition(x-1,y-1) CBkC = oCell.CellBackColor RGBprobe =CBkC End Function
=RGBPROBE(COLUMN()-1;ROW())
böyle bir kod vermiş ama bir türlü doğru veriyi giremedim.Evet böyle kolayca yapılabilir ama sistemi tamamen değiştirip e-h koyacak sütun oluşturmak lazım. Bir daha düzenlemeye üşeniyorum. Mecbur kalırsam yaparım artık.Gökhan bu şekilde tasarlanınca çok karmaşık olur bence .
Sen libre office kullanıyorsun ben excelde basit bir şablon hazırladım.Bu şablona 1-2 hücre daha eklenebilir.
ödeme yapıldı ise yanındadaki hücreye E yazılınca (Evet ödeme yapıldı anlamında )bir sağdaki hücreye ödenenler hücresini bu değere eşitliyor.
(Belirli şarta göre hücreyi renklendirme excelde de var ancak hatırlayamadım )10 yıldan fazla excel kullanmadım
Bunun formül kısmını üstte çerçeve içine aldım zaten libre office de yaklaşık aynı komutları ve syntaxları kullanıyor sanırım.Diğer kısımları toplama çıkarma zaten. Birkaç örnek harcama girdim toplamları alması için
Ona bende sordum abi. Sürekli VB için kod üretiyor. Libreofise uymuyor.