Advertisement
Guest User

Problem with error-bars

a guest
Feb 11th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.81 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. # Corresponding document is at: https://cloud.datenzone.de/seafile/f/0c4e2d9acfad452190f4/?dl=1
  4.  
  5. # start using: soffice --accept="socket,host=localhost,port=2002;urp;" --norestore --nologo --nodefault --headless
  6. import uno
  7. import os
  8.  
  9.  
  10. # get the uno component context from the PyUNO runtime
  11. localContext = uno.getComponentContext()
  12. # create the UnoUrlResolver
  13. resolver =  localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
  14. # connect to the running office
  15. ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
  16. smgr = ctx.ServiceManager
  17. # get the central desktop object
  18. desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
  19. url = uno.systemPathToFileUrl(os.path.abspath("errorbartest.ods"))
  20. document = desktop.loadComponentFromURL(url, '_blank', 0, ())
  21.  
  22. # Here it gets interesting
  23. sheets = document.getSheets()
  24. sheetNames = sheets.getElementNames()
  25. for i in sheetNames:
  26.     # There should be only one sheet
  27.     currentSheet = sheets.getByName(i)
  28.     charts = currentSheet.getCharts()
  29.     for c in charts:
  30.         # There should be only one chart
  31.         ranges = c.getRanges()
  32.         for r in ranges:
  33.             print("range: " + str(r))
  34.         o = c.getEmbeddedObject()
  35.         title = o.getTitle()
  36.         print("Title: " + str(title.String))
  37.         sequences = o.getDataSequences()
  38.         for seq in sequences:
  39.             values = seq.getValues()
  40.             print("role: " + str(values.Role) + ", data: " + str(seq.getValues().getTextualData()))
  41.  
  42. '''
  43. Current output:
  44. range: (com.sun.star.table.CellRangeAddress){ Sheet = (short)0x0, StartColumn = (long)0x0, StartRow = (long)0x0, EndColumn = (long)0x2, EndRow = (long)0x1 }
  45. Title: A test for error-bars
  46. role: categories, data: ('First', 'Second')
  47. role: values-y, data: ('30', '34')
  48. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement