I have very limited experience with Raspbian and LibreOffice, but I know and use Excel and xlwings all the time. I need to find a way to create a programme that does the same as one that I have created in xlwings. I would appreciate any help.
The code that I have in xlwings: Opens an Excel window; takes and validates 2 inputs and takes the time the first is entered; checks the excel file for how many rows there are; checks the last serial number; checks if the inputs pass or fail a criterion. It then adds 1 to the serial number and puts all the info into the file, which shows up in real time (This is essential). Code Below:
import xlwings as xw
file = 'test.xlsx'
wb = xw.Book(file)
sht = wb.sheets['Sheet1']
active_sheet = wb.sheets.active
sht.range('A1:A5').columns.autofit()
sht.range('A1').value = ['serial no.', 'date/time', 'gross', 'net', 'pass/fail']
while True:
try:
gross = float(input('Input Gross: '))
gross = '%.2f' % gross
except ValueError:
print('You need to enter a number with a decimal point\nExample 7.05')
continue
try:
net = float(input('Input Net: '))
net = '%.2f' % net
except ValueError:
print('You need to enter a number with a decimal point\nExample 6.58')
continue
date_time = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
num_rows = sht.api.UsedRange.Rows.Count
if num_rows == 1:
last_serial = 0
else:
cell = 'A' + str(num_rows)
last_serial = sht.range(cell).value
print(last_serial)
print(type(last_serial))
new_serial = int(last_serial) + 1
if float(gross) < 6.25 or float(gross) > 7.80:
print('Fail')
pass_fail = 'Fail'
else:
pass_fail = 'Pass'
next_row = 'A' + str(num_rows + 1)
sht.range(next_row).value = [new_serial, date_time, gross, net, pass_fail]
wb.save()
The code isn't perfect but it gives you and idea of what I'm looking for. Is it possible to do this in LibreOffice on a Raspberry Pi?