Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM https://www.dropbox.COM/.../AIys-JZv9Q4QypkbGPHJ5FI...
- REM Subject :: LibreOffice Calc AND USING this AS per media shown further down at this link here
- REM https://www.facebook.COM/mark.harrington.14289/videos/1187026392576183
- REM
- REM I will be posting this , " code only " ON paste bin in a few minutes so that you can VIEW , download , study etc
- REM
- REM Alfred Adukobirre Adukobilla , Jacqui Nosy Gcingca AND may even interest yourself Blessing Emejulu , Brian Yearwood , Pallab Nandi , also many other people who may be interested TO see how this IS done
- REM
- REM PS READ the notes contained at Dropbox link mentioned above in First link
- REM Note NB **** This works only with Libre Calc IF you want TO expand this TO Microsoft Office THEN you will have TO change code TO VBA ***
- REM
- REM A good exorcise FOR you at ANY rate
- REM
- REM Learn , enjoy AND expand your skills
- REM
- REM Have a good evening all AND take care
- REM ***** BASIC *****
- REM *** MD Harrington kent London DA6 8NP
- REM ***** DATE TODAY IS 25:09/2024 TIME : 00:00 HRS
- SUB PrintArrayForC
- DIM oSheet AS Object
- DIM oRange AS Object
- DIM oCell AS Object
- ' Access the first sheet (Sheet1)
- oSheet = ThisComponent.Sheets(0)
- ' Access the merged cell range (B26:J27)
- oRange = oSheet.getCellRangeByName("B26:J27")
- ' Access the first cell in the merged range
- oCell = oRange.getCellByPosition(0, 0) ' The first cell of the merged range (B26)
- ' Update the value in the first cell of the merged range
- oCell.STRING = CreateCharArrayFromColumn()
- END SUB
- SUB ClearData
- DIM oSheet AS Object
- DIM oRange AS Object
- DIM oCell AS Object
- ' Access the first sheet (Sheet1)
- oSheet = ThisComponent.Sheets(0)
- ' Access the merged cell range (B26:J27)
- oRange = oSheet.getCellRangeByName("B26:J27")
- ' Access the first cell in the merged range
- oCell = oRange.getCellByPosition(0, 0) ' The first cell of the merged range (B26)
- ' Update the value in the first cell of the merged range
- oCell.STRING = ""
- END SUB
- FUNCTION CreateCharArrayFromColumn() AS STRING
- DIM oSheet AS Object
- DIM oCell AS Object
- DIM i AS INTEGER
- DIM startRow AS INTEGER
- DIM endRow AS INTEGER
- DIM resultString AS STRING
- DIM value AS STRING
- ' Access the first sheet (Sheet1)
- oSheet = ThisComponent.Sheets(0)
- ' Define the start and end rows (J7 to J16 means row 6 to row 15 in 0-indexed)
- startRow = 6 ' J7
- endRow = 15 ' J16
- ' Initialize the result string with the initial text
- resultString = "unsigned char m_array [10] = { "
- ' Loop through the cells in column J (index 9) from J7 to J16
- FOR i = startRow TO endRow
- ' Access the current cell in column J
- oCell = oSheet.getCellByPosition(9, i)
- ' Get the cell's value as a string (you can also use .getValue if they are numbers)
- value = oCell.getString()
- ' Append the value to the result string
- resultString = resultString & value
- ' Add a comma between values, but avoid it after the last one
- IF i < endRow THEN
- resultString = resultString & ", "
- END IF
- NEXT i
- ' Close the array declaration in the string
- resultString = resultString & " };"
- ' Return the final string
- CreateCharArrayFromColumn = resultString
- END FUNCTION
- REM Notes about other code
- REM These functions are built in
- REM =CONCAT("0x",DEC2HEX(H7,2)) this IS entered into column J
- REM =CONCAT("0b000",C7:G7) this IS entered into Column I
- REM =BIN2DEC(MID(I7,3,8)) this IS entered into Column H
- ' bare in mind that you have to understand what these functions do but this
- ' is how I work out truth tables to plug into code
- ' Ive produced this to show you how to use spreadsheets to your advantage using
- ' With automation in mind
- ' You can do much more than just this and its possiblities are endless
- ' auto email , networking , security , iot you name it
- ' That is all in your hands and how you implement knowledge
Advertisement
Advertisement