tabellenkalkulation:der_pc-konfigurator
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
tabellenkalkulation:der_pc-konfigurator [2024/01/26 18:33] – angelegt torsten.roehl | tabellenkalkulation:der_pc-konfigurator [2024/01/26 18:38] (aktuell) – torsten.roehl | ||
---|---|---|---|
Zeile 7: | Zeile 7: | ||
</ | </ | ||
In diesem Projekt wird ein PC-Konfigurator mit OpenOffice Calc entwickelt. | In diesem Projekt wird ein PC-Konfigurator mit OpenOffice Calc entwickelt. | ||
+ | |||
+ | |{{ : | ||
+ | |Das Arbeitsblatt " | ||
+ | ===== Beispieltabelle und das dazugehörige Makro ===== | ||
+ | ==== Die Calc-Tabelle ==== | ||
+ | |||
+ | Ein Arbeitsblatt " | ||
+ | === Basic-makro === | ||
+ | |||
+ | <Code Basic linenums:1 | Listing 1: | ||
+ | ' Grunddatei fürs CPU-Projekt | ||
+ | |||
+ | sub test | ||
+ | MsgBox "Hallo Welt" | ||
+ | end sub | ||
+ | |||
+ | ' cpu-Prozedur zum Erstellen des Konfigurators | ||
+ | ' sub cpu | ||
+ | ' | ||
+ | r = getCurrentRow() | ||
+ | 'Die aktuelle Spaltennummer wird ausgelesen und der Variablen c zugewiesen.' | ||
+ | c = getCurrentCol() | ||
+ | |||
+ | value = readCell( c+1,r ) | ||
+ | writeCell(5, | ||
+ | strCPU = readString(c, | ||
+ | writeString(4, | ||
+ | |||
+ | end sub | ||
+ | |||
+ | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
+ | ' utility functions ' | ||
+ | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
+ | ' getCurrentRow | ||
+ | ' @returns the current cell position (zero based) | ||
+ | Function getCurrentRow() as Integer | ||
+ | oDesktop = createUnoService( " | ||
+ | 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( " | ||
+ | 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 | ||
+ | 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 | ||
+ | myCell.String = value | ||
+ | End Function | ||
+ | |||
+ | ' overloaded function for string operations | ||
+ | ' @see readCell | ||
+ | Dim myDoc | ||
+ | Dim mySheet | ||
+ | Dim myCell | ||
+ | myDoc = thisComponent | ||
+ | mySheet | ||
+ | myCell | ||
+ | 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 | ||
+ | readCell = mySheet.getCellByPosition( xPos, yPos ).getValue() | ||
+ | End Function | ||
+ | </ |
tabellenkalkulation/der_pc-konfigurator.1706293982.txt.gz · Zuletzt geändert: 2024/01/26 18:33 von torsten.roehl