Benutzer-Werkzeuge

Webseiten-Werkzeuge


tabellenkalkulation:der_pc-konfigurator

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
tabellenkalkulation:der_pc-konfigurator [2024/01/26 18:33] – angelegt torsten.roehltabellenkalkulation:der_pc-konfigurator [2024/01/26 18:38] (aktuell) torsten.roehl
Zeile 7: Zeile 7:
 </WRAP> </WRAP>
 In diesem Projekt wird ein PC-Konfigurator mit OpenOffice Calc entwickelt. In diesem Projekt wird ein PC-Konfigurator mit OpenOffice Calc entwickelt.
 +
 +|{{ :inf:angewandte:pc_kauf.png?450 |}}|
 +|Das Arbeitsblatt "PC-Konfigurator" in Aktion.|
 +===== Beispieltabelle und das dazugehörige Makro =====
 +==== Die Calc-Tabelle ====
 +
 +Ein Arbeitsblatt "cpu_board.ods" befindet sich im Downloadbereich, in dem einige Grundelemente bereits installiert sind. 
 +=== Basic-makro ===
 +
 +<Code Basic linenums:1 | Listing 1:Basic-Makro >
 +' Grunddatei fürs CPU-Projekt 
 + 
 +sub test 
 +MsgBox "Hallo Welt"
 +end sub
 + 
 +' cpu-Prozedur zum Erstellen des Konfigurators
 +' sub cpu 
 +'Ermittelt die Zeilennummer, in der sich der Cursor befindet.
 +r = getCurrentRow() 
 +'Die aktuelle Spaltennummer wird ausgelesen und der Variablen c zugewiesen.'
 +c = getCurrentCol()  
 + 
 +value = readCell( c+1,r )
 +writeCell(5,2,value) 
 +strCPU = readString(c,r) 
 +writeString(4,2,strCPU) 
 + 
 +end sub  
 + 
 +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 +' utility functions '
 +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''   
 +' getCurrentRow
 +' @returns the current cell position (zero based) 
 +Function getCurrentRow() as Integer 
 +oDesktop = createUnoService( "com.sun.star.frame.Desktop"
 +oController = oDesktop.CurrentFrame.Controller 
 +oSelection = oController.Selection 
 +aPos = oSelection.getRangeAddress 
 +getCurrentRow = aPos.StartRow 
 +End Function  
 + 
 + 
 +' getCurrentCol 
 +' @returns the current cell position (zero based)
 +Function getCurrentCol() as Integer
 +oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
 +oController = oDesktop.CurrentFrame.Controller
 +oSelection = oController.Selection 
 +aPos = oSelection.getRangeAddress
 +getCurrentCol = aPos.StartColumn 
 +End Function 
 + 
 +' writeCell writes a number to the table cell.
 +' @param the zero based xPos table position
 +' @param the zero based yPos table position
 +' @param value 
 +Function writeCell( xPos as Integer, yPos as Integer, value as Double)
 +Dim myDoc Dim mySheet Dim myCell myDoc   = thisComponent mySheet = myDoc.sheets( 0 ) 
 +myCell  = mySheet.getCellByPosition( xPos, yPos ) 
 +myCell.setValue( value )
 +End Function
 + 
 +' overloaded function for string operations
 +' @see writeCell 
 +Function writeString( xPos as Integer, yPos as Integer, value as String)
 +Dim myDoc Dim mySheet Dim myCell myDoc   = thisComponent 
 +mySheet = myDoc.sheets( 0 ) 
 +myCell  = mySheet.getCellByPosition( xPos, yPos )  
 +myCell.String = value  
 +End Function  
 + 
 +' overloaded function for string operations 
 +' @see readCell  Function readString( xPos as Integer, yPos as Integer) as String 
 +Dim myDoc 
 +Dim mySheet
 +Dim myCell
 +myDoc    = thisComponent 
 +mySheet  = myDoc.sheets( 0 ) 
 +myCell   = mySheet.getCellByPosition( xPos, yPos ) 
 +readString = myCell.String
 +End Function  
 + 
 + 
 +' readCell reads a number from the given cell position.
 +' @param the zero based xPos table position 
 +' @param the zero based yPos table position
 +' @return double (integer) value in the given position ' #todo# exception handling 
 +Function readCell( xPos as Integer, yPos as Integer) as Double 
 +Dim myDoc
 +Dim mySheet
 +myDoc    = thisComponent
 +mySheet  = myDoc.sheets( 0 )
 +readCell = mySheet.getCellByPosition( xPos, yPos ).getValue()
 +End Function   
 +</Code>
tabellenkalkulation/der_pc-konfigurator.1706293982.txt.gz · Zuletzt geändert: 2024/01/26 18:33 von torsten.roehl