{ "info": { "author": "Miloslav Pojman", "author_email": "miloslav.pojman@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Topic :: Office/Business :: Financial :: Spreadsheet", "Topic :: Office/Business :: Office Suites" ], "description": "========================================================\nPyOO - Pythonic interface to Apache OpenOffice API (UNO)\n========================================================\n\nPyOO allows you to control a running OpenOffice_ or LibreOffice_\nprogram for reading and writing spreadsheet documents.\nThe library can be used for generating documents in various\nformats -- including Microsoft Excel 97 (.xls),\nMicrosoft Excel 2007 (.xlsx) and PDF.\n\nThe main advantage of the PyOO library is that it can use almost any\nfunctionality implemented in OpenOffice / LibreOffice applications.\nOn the other hand it needs a running process of a office suite\napplication which is significant overhead.\n\nPyOO uses UNO_ interface via Python-UNO_ bridge. UNO is a\nstandard interface to a running OpenOffice or LibreOffice\napplication. Python-UNO provides this interface in Python scripts.\nDirect usage of UNO API via Python-UNO can be quite complicated\nand even simple tasks require a lot of code. Also many UNO calls\nare slow and should be avoided when possible.\n\nPyOO wraps a robust Python-UNO bridge to simple and Pythonic\ninterface. Under the hood it implements miscellaneous\noptimizations which can prevent unnecessary expensive UNO\ncalls.\n\nAvailable features:\n\n * Opening and creation of spreadsheet documents\n * Saving documents to all formats available in OpenOffice\n * Charts and diagrams\n * Sheet access and manipulation\n * Formulas\n * Cell merging\n * Number, text, date, and time values\n * Cell and text formating\n * Number formating\n * Locales\n\nIf some important feature missing then the UNO API is always available.\n\n\n.. _OpenOffice: http://www.openoffice.org/\n.. _LibreOffice: http://www.libreoffice.org/\n.. _UNO: http://www.openoffice.org/api/docs/common/ref/com/sun/star/module-ix.html\n.. _Python-UNO: http://www.openoffice.org/udk/python/python-bridge.html\n\n\nPrerequisites\n-------------\n\nPyOO runs on both Python 2 (2.7+) and Python 3 (3.3+) but latest LibreOffice\nreleases are likely to support Python 3 only.\n\nThe only dependency is the Python-UNO library (imported as a module ``uno``).\nUnfortunately Python-UNO cannot be installed using pip.\nDo NOT install package named ``uno`` available on PyPI - it's not related to LibreOffice.\n\nDebian / Ubuntu\n...............\n\nOn Debian based systems Python-UNO can by installed as ``python3-uno`` package.\n\nObviously you will also need OpenOffice or LibreOffice Calc.\nOn Debian systems it is available as ``libreoffice-calc`` package. ::\n\n $ sudo apt-get install libreoffice-calc python3-uno\n\nmacOS\n.....\n\nInstall LibreOffice, for example using cask_: ::\n\n $ brew cask install libreoffice\n\nThen use Python binary bundled with the installed application: ::\n\n $ export PATH=/Applications/LibreOffice.app/Contents/Resources:$PATH\n\n.. _cask: https://caskroom.github.io/\n\n\nInstallation\n------------\n\nPyOO library can be installed from PYPI using pip_.::\n\n $ pip install pyoo\n\nIf you downloaded the code you can install it using the ``setup.py`` script: ::\n\n $ python setup.py install\n\nAlternatively you can copy the ``pyoo.py`` file somewhere to your ``PYTHONPATH``.\n\n.. _pip: https://pypi.python.org/pypi/pip\n\n\nUsage\n-----\n\nStarting OpenOffice / LibreOffice\n.................................\n\nPyOO requires a running OpenOffice or LibreOffice instance which\nit can connect to. On Debian you can start LibreOffice from\na command line using a command similar to: ::\n\n $ soffice --accept=\"socket,host=localhost,port=2002;urp;\" --norestore --nologo --nodefault # --headless\n\nThe LibreOffice will be listening for localhost connection\non port 2002. Alternatively a named pipe can be used: ::\n\n $ soffice --accept=\"pipe,name=hello;urp;\" --norestore --nologo --nodefault # --headless\n\nIf the ``--headless`` option is used then no user interface is\nvisible even when a document is opened.\n\nFor more information run: ::\n\n $ soffice --help\n\nIt is recommended to start directly the ``soffice`` binary.\nThere can be various scripts (called for example ``libreoffice``)\nwhich will run the ``soffice`` binary but you may not get the\ncorrect PID of the running program.\n\n\nAccessing documents\n...................\n\nPyOO acts as a bridge to a OpenOffice.org program so a connection\nto the running program has to be created first: ::\n\n >>> import pyoo\n >>> desktop = pyoo.Desktop('localhost', 2002)\n\nHost name and port number used in the example ``('localhost', 2002)``\nare default values so they can be omitted.\n\nConnection to a named pipe is also possible: ::\n\n >>> pyoo.Desktop(pipe='hello')\n\nNew spreadsheet document can be created using ``Desktop.create_spreadsheet()``\nmethod or opened using ``Desktop.open_spreadsheet()``: ::\n\n >>> doc = desktop.create_spreadsheet()\n >>> # doc = desktop.open_spreadsheet(\"/path/to/spreadsheet.ods\")\n\nIf the office application is not running in the headless\nmode then a new window with Calc program should open now.\n\n\nSheets\n......\n\nSpreadsheet document is represented by a ``SpreadsheetDocument`` class which\nimplements basic manipulation with document. All data are in sheets\nwhich can can be accessed and manipulated via ``SpreadsheetDocument.sheets``\nproperty: ::\n\n >>> # Access sheet by index or name:\n >>> doc.sheets[0]\n \n >>> doc.sheets['Sheet1']\n \n\n >>> # Create a new sheet after the first one:\n >>> doc.sheets.create('My Sheet', index=1)\n \n\n >>> # Copy the created sheet after the second one:\n >>> doc.sheets.copy('My Sheet', 'Copied Sheet', 2)\n \n\n >>> # Delete sheet by index or name:\n >>> del doc.sheets[1]\n >>> del doc.sheets['Copied sheet']\n\n >>> # Create multiple sheets with same name/prefix\n >>> get_sheet_name = pyoo.NameGenerator()\n >>> doc.sheets.create(get_sheet_name('My sheet'))\n \n >>> doc.sheets.create(get_sheet_name('My sheet'))\n \n\nCells can be accessed using index notation from a sheet: ::\n\n >>> # Get sheet:\n >>> sheet = doc.sheets[0]\n\n >>> # Get cell address and set cell values:\n >>> str(sheet[0,0].address)\n '$A$1'\n >>> sheet[0,0].value = 1\n >>> str(sheet[0,1].address)\n '$B$1'\n >>> sheet[0,1].value = 2\n\n >>> # Set cell formula and get value:\n >>> sheet[0,2].formula = '=$A$1+$B$1'\n >>> sheet[0,2].value\n 3.0\n\nAll the changes should be visible in the opened document.\n\nEvery operation with a cell takes some time so setting all values separately\nis very ineffective. For this reason operations with whole cell ranges\nare implemented: ::\n\n >>> # Tabular (two dimensional) cell range:\n >>> sheet[1:3,0:2].values = [[3, 4], [5, 6]]\n\n >>> # Row (one dimensional) cell range:\n >>> sheet[3, 0:2].formulas = ['=$A$1+$A$2+$A$3', '=$B$1+$B$2+$B$3']\n >>> sheet[3, 0:2].values\n (9.0, 12.0)\n\n >>> # Column (one dimensional) cell range:\n >>> sheet[1:4,2].formulas = ['=$A$2+$B$2', '=$A$3+$B3', '=$A$4+$B$4']\n >>> sheet[1:4,2].values\n (7.0, 11.0, 21.0)\n\n\nFormating\n.........\n\nMiscellaneous attributes can be set to cells, cell ranges and sheets\n(they all inherit a ``CellRange`` class). Also note that cell ranges\nsupport many indexing options: ::\n\n >>> # Get cell range with all data\n >>> cells = sheet[:4,:3]\n\n >>> # Font and text properties:\n >>> cells.font_size = 20\n >>> cells[3, :].font_weight = pyoo.FONT_WEIGHT_BOLD\n >>> cells[:, 2].text_align = pyoo.TEXT_ALIGN_LEFT\n >>> cells[-1,-1].underline = pyoo.UNDERLINE_DOUBLE\n\n >>> # Colors:\n >>> cells[:3,:2].text_color = 0xFF0000 # 0xRRGGBB\n >>> cells[:-1,:-1].background_color = 0x0000FF # 0xRRGGBB\n\n >>> # Borders\n >>> cells[:,:].border_width = 100\n >>> cells[:,:].border_color = 0xFFFF00\n >>> cells[-4:-1,-3:-1].inner_border_width = 50\n\nNumber format can be also set but it is locale dependent: ::\n\n >>> locale = doc.get_locale('en', 'us')\n >>> sheet.number_format = locale.format(pyoo.FORMAT_PERCENT_INT)\n\n\nCharts\n......\n\nCharts can be created: ::\n\n >>> chart = sheet.charts.create('My Chart', sheet[5:10, 0:5], sheet[:4,:3])\n\nThe first argument is a chart name, the second argument specifies\nchart position and the third one contains address of source data\n(it can be also a list or tuple). If optional ``row_header`` or\n``col_header`` keyword arguments are set to ``True`` then labels\nwill be read from first row or column.\n\nExisting charts can be accessed either by an index or a name: ::\n\n >>> sheet.charts[0].name\n u'My Chart'\n >>> sheet.charts['My Chart'].name\n u'My Chart'\n\n\nChart instances are generally only a container for diagrams which specify\nhow are data rendered. Diagram can be replaced by another type while chart\nstays same. ::\n\n >>> chart.diagram.__class__\n \n >>> diagram = chart.change_type(pyoo.LineDiagram)\n >>> diagram.__class__\n \n\nDiagram instance can be used for accessing and setting of\nmiscellanous properties. ::\n\n >>> # Set axis label\n >>> diagram.y_axis.title = \"Primary axis\"\n\n >>> # Axis can use a logarithmic scale\n >>> diagram.y_axis.logarithmic = True\n\n >>> # Secondary axis can be shown.\n >>> diagram.secondary_y_axis.visible = True\n\n >>> # All axes have same attributes.\n >>> diagram.secondary_y_axis.title = \"Secondary axis\"\n\n >>> # Change color of one of series (lines, bars,...)\n >>> diagram.series[0].fill_color = 0x000000\n\n >>> # And bind it to secondary axis\n >>> diagram.series[0].axis = pyoo.AXIS_SECONDARY\n\n\nSaving documents\n................\n\nSpreadsheet documents can be saved using save method: ::\n\n >>> doc.save('example.xlsx', pyoo.FILTER_EXCEL_2007)\n >>> # doc.save()\n\nAnd finally do not forget to close the document: ::\n\n >>> doc.close()\n\n\nTesting\n-------\n\nAutomated integration tests cover most of the code.\n\nThe test suite assumes that OpenOffice or LibreOffice is running and\nit is listening on localhost port 2002.\n\nAll tests are in the ``test.py`` file: ::\n\n $ python test.py\n\n\nLicense\n-------\n\nThis library is released under the MIT license. See the ``LICENSE`` file.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mila/pyoo", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyoo", "package_url": "https://pypi.org/project/pyoo/", "platform": "", "project_url": "https://pypi.org/project/pyoo/", "project_urls": { "Homepage": "https://github.com/mila/pyoo" }, "release_url": "https://pypi.org/project/pyoo/1.4/", "requires_dist": null, "requires_python": "", "summary": "Pythonic interface to Apache OpenOffice API (UNO)", "version": "1.4" }, "last_serial": 5710775, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "766cfd70443bf38b5c2b73576258634d", "sha256": "238239104861a4c661ba1c937e2d14f60636bf12d5e884d7543be741714780a3" }, "downloads": -1, "filename": "pyoo-1.0.tar.gz", "has_sig": false, "md5_digest": "766cfd70443bf38b5c2b73576258634d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25283, "upload_time": "2014-07-15T07:16:59", "url": "https://files.pythonhosted.org/packages/a3/11/e2008a9654afbdfcf9ad9eacce804cfc496a1346d2a1dde59686dbbf6cd0/pyoo-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "4857452b0f2f3ea377d209d51b01371f", "sha256": "daae940e53732d6ddc106e0f07b6d9ad0fe774f8617016b63669ab2baf41db23" }, "downloads": -1, "filename": "pyoo-1.1.tar.gz", "has_sig": false, "md5_digest": "4857452b0f2f3ea377d209d51b01371f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25735, "upload_time": "2016-06-02T14:26:56", "url": "https://files.pythonhosted.org/packages/f0/55/7a1e2564d0db0c1fbc38fb99186caa1a242e7cfb0dd4a2e682a07f02ae71/pyoo-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "0d16ffb23d7345a34e5ef740960ed5df", "sha256": "6cee18ed5cad831c2b62adb3e655e45116705e193af0d6108fc793e581e91e2b" }, "downloads": -1, "filename": "pyoo-1.2.tar.gz", "has_sig": false, "md5_digest": "0d16ffb23d7345a34e5ef740960ed5df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25978, "upload_time": "2017-02-03T12:00:08", "url": "https://files.pythonhosted.org/packages/08/a1/b19333091860c3079efb708df6dc55a4bee59d2756462dd1ea5d8a099087/pyoo-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "20beab8e48f94f74f93bf29bb830edb3", "sha256": "05523e7dd66f54860ff13b4cce1d0cdc692c1780b5f393c9c2e4826ebfca3753" }, "downloads": -1, "filename": "pyoo-1.3.tar.gz", "has_sig": false, "md5_digest": "20beab8e48f94f74f93bf29bb830edb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27278, "upload_time": "2017-12-05T21:06:06", "url": "https://files.pythonhosted.org/packages/9f/b6/ae9c387f95e14a4ec6bc8f95929efa343d15304bfa9bbc59661a07f7a427/pyoo-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "a37a53402374eca930af1431f31b1d3a", "sha256": "761a3c85cb6c0ee16e36e72280bd5773bac2c2037dd9892d128107a14efef4bc" }, "downloads": -1, "filename": "pyoo-1.4-py2-none-any.whl", "has_sig": false, "md5_digest": "a37a53402374eca930af1431f31b1d3a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 19117, "upload_time": "2019-08-21T17:16:55", "url": "https://files.pythonhosted.org/packages/ad/ee/da8fac6764111e52b4411f0fe93d78992bac18292fb844c85ba23ed6d47e/pyoo-1.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8b3264a8cbb2025e7d693f0583b2232", "sha256": "3e9fb17a616edfdccd122dbaa0e75e86c754f7641470141a5019efcc2d11b2af" }, "downloads": -1, "filename": "pyoo-1.4.tar.gz", "has_sig": false, "md5_digest": "f8b3264a8cbb2025e7d693f0583b2232", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31307, "upload_time": "2019-08-21T17:16:56", "url": "https://files.pythonhosted.org/packages/1c/8d/bad1060f2fe8ec3e8f3bcf7013c615c910893e6e97a5e23a89cad7a3676e/pyoo-1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a37a53402374eca930af1431f31b1d3a", "sha256": "761a3c85cb6c0ee16e36e72280bd5773bac2c2037dd9892d128107a14efef4bc" }, "downloads": -1, "filename": "pyoo-1.4-py2-none-any.whl", "has_sig": false, "md5_digest": "a37a53402374eca930af1431f31b1d3a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 19117, "upload_time": "2019-08-21T17:16:55", "url": "https://files.pythonhosted.org/packages/ad/ee/da8fac6764111e52b4411f0fe93d78992bac18292fb844c85ba23ed6d47e/pyoo-1.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8b3264a8cbb2025e7d693f0583b2232", "sha256": "3e9fb17a616edfdccd122dbaa0e75e86c754f7641470141a5019efcc2d11b2af" }, "downloads": -1, "filename": "pyoo-1.4.tar.gz", "has_sig": false, "md5_digest": "f8b3264a8cbb2025e7d693f0583b2232", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31307, "upload_time": "2019-08-21T17:16:56", "url": "https://files.pythonhosted.org/packages/1c/8d/bad1060f2fe8ec3e8f3bcf7013c615c910893e6e97a5e23a89cad7a3676e/pyoo-1.4.tar.gz" } ] }