{"id":19797397,"url":"https://github.com/pyexcel/pyexcel-xls","last_synced_at":"2025-04-12T18:38:38.403Z","repository":{"id":23518069,"uuid":"26884246","full_name":"pyexcel/pyexcel-xls","owner":"pyexcel","description":"A wrapper library to read, manipulate and write data in xls using xlrd and xlwt","archived":false,"fork":false,"pushed_at":"2025-03-08T14:27:20.000Z","size":449,"stargazers_count":46,"open_issues_count":0,"forks_count":21,"subscribers_count":8,"default_branch":"dev","last_synced_at":"2025-04-03T22:07:38.008Z","etag":null,"topics":["python","xls"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyexcel.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"chfw","patreon":"chfw"}},"created_at":"2014-11-19T22:16:25.000Z","updated_at":"2025-03-07T09:00:27.000Z","dependencies_parsed_at":"2024-11-12T07:29:55.889Z","dependency_job_id":"f47b00d1-6f7c-412b-9cd7-6662184c03a2","html_url":"https://github.com/pyexcel/pyexcel-xls","commit_stats":{"total_commits":311,"total_committers":6,"mean_commits":"51.833333333333336","dds":0.08681672025723475,"last_synced_commit":"d8953c8ff7dc9a4a3465f2cfc182acafa49f6ea2"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel%2Fpyexcel-xls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel%2Fpyexcel-xls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel%2Fpyexcel-xls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel%2Fpyexcel-xls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyexcel","download_url":"https://codeload.github.com/pyexcel/pyexcel-xls/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248615981,"owners_count":21133984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","xls"],"created_at":"2024-11-12T07:25:08.897Z","updated_at":"2025-04-12T18:38:38.377Z","avatar_url":"https://github.com/pyexcel.png","language":"Python","readme":"================================================================================\npyexcel-xls - Let you focus on data, instead of xls format\n================================================================================\n\n.. image:: https://raw.githubusercontent.com/pyexcel/pyexcel.github.io/master/images/patreon.png\n   :target: https://www.patreon.com/chfw\n\n.. image:: https://raw.githubusercontent.com/pyexcel/pyexcel-mobans/master/images/awesome-badge.svg\n   :target: https://awesome-python.com/#specific-formats-processing\n\n.. image:: https://codecov.io/gh/pyexcel/pyexcel-xls/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/pyexcel/pyexcel-xls\n\n.. image:: https://badge.fury.io/py/pyexcel-xls.svg\n   :target: https://pypi.org/project/pyexcel-xls\n\n.. image:: https://anaconda.org/conda-forge/pyexcel-xls/badges/version.svg\n   :target: https://anaconda.org/conda-forge/pyexcel-xls\n\n\n.. image:: https://pepy.tech/badge/pyexcel-xls/month\n   :target: https://pepy.tech/project/pyexcel-xls\n\n.. image:: https://anaconda.org/conda-forge/pyexcel-xls/badges/downloads.svg\n   :target: https://anaconda.org/conda-forge/pyexcel-xls\n\n.. image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg\n   :target: https://gitter.im/pyexcel/Lobby\n\n.. image:: https://img.shields.io/static/v1?label=continuous%20templating\u0026message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0\u0026color=blue\u0026style=flat-square\n    :target: https://moban.readthedocs.io/en/latest/#at-scale-continous-templating-for-open-source-projects\n\n.. image:: https://img.shields.io/static/v1?label=coding%20style\u0026message=black\u0026color=black\u0026style=flat-square\n    :target: https://github.com/psf/black\n\n**pyexcel-xls** is a tiny wrapper library to read, manipulate and\nwrite data in xls format and it can read xlsx and xlsm fromat.\nYou are likely to use it with `pyexcel \u003chttps://github.com/pyexcel/pyexcel\u003e`_.\n\nOct 2021 - Update:\n===================\n\n1. v0.7.0 removed the pin on xlrd \u003c 2. If you have xlrd \u003e= 2, this\nlibrary will NOT read 'xlsx' format and you need to install pyexcel-xlsx. Othwise,\nthis library can use xlrd \u003c 2 to read xlsx format for you. So 'xlsx' support\nin this library will vary depending on the installed version of xlrd.\n\n2. v0.7.0 can write datetime.timedelta. but when the value is read out,\nyou will get datetime.datetime. so you as the developer decides what to do with it.\n\nPast news\n===========\n\n`detect_merged_cells` allows you to spread the same value among\nall merged cells. But be aware that this may slow down its reading\nperformance.\n\n`skip_hidden_row_and_column` allows you to skip hidden rows\nand columns and is defaulted to **True**. It may slow down its reading\nperformance. And it is only valid for 'xls' files. For 'xlsx' files,\nplease use pyexcel-xlsx.\n\nWarning\n================================================================================\n\n**xls file cannot contain more than 65,000 rows**. You are risking the reputation\nof yourself/your company/\n`your country \u003chttps://www.bbc.co.uk/news/technology-54423988\u003e`_ if you keep\nusing xls and are not aware of its row limit.\n\n\nSupport the project\n================================================================================\n\nIf your company has embedded pyexcel and its components into a revenue generating\nproduct, please support me on github, or `patreon \u003chttps://www.patreon.com/bePatron?u=5537627\u003e`_\nmaintain the project and develop it further.\n\nWith your financial support, I will be able to invest a little bit more time in coding,\ndocumentation and writing interesting posts.\n\n\nKnown constraints\n==================\n\nFonts, colors and charts are not supported.\n\nNor to read password protected xls, xlsx and ods files.\n\nInstallation\n================================================================================\n\n\nYou can install pyexcel-xls via pip:\n\n.. code-block:: bash\n\n    $ pip install pyexcel-xls\n\n\nor clone it and install it:\n\n.. code-block:: bash\n\n    $ git clone https://github.com/pyexcel/pyexcel-xls.git\n    $ cd pyexcel-xls\n    $ python setup.py install\n\nUsage\n================================================================================\n\nAs a standalone library\n--------------------------------------------------------------------------------\n\n.. testcode::\n   :hide:\n\n    \u003e\u003e\u003e import os\n    \u003e\u003e\u003e import sys\n    \u003e\u003e\u003e if sys.version_info[0] \u003c 3:\n    ...     from StringIO import StringIO\n    ... else:\n    ...     from io import BytesIO as StringIO\n    \u003e\u003e\u003e PY2 = sys.version_info[0] == 2\n    \u003e\u003e\u003e if PY2 and sys.version_info[1] \u003c 7:\n    ...      from ordereddict import OrderedDict\n    ... else:\n    ...     from collections import OrderedDict\n\n\nWrite to an xls file\n********************************************************************************\n\n\n\nHere's the sample code to write a dictionary to an xls file:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from pyexcel_xls import save_data\n    \u003e\u003e\u003e data = OrderedDict() # from collections import OrderedDict\n    \u003e\u003e\u003e data.update({\"Sheet 1\": [[1, 2, 3], [4, 5, 6]]})\n    \u003e\u003e\u003e data.update({\"Sheet 2\": [[\"row 1\", \"row 2\", \"row 3\"]]})\n    \u003e\u003e\u003e save_data(\"your_file.xls\", data)\n\n\nRead from an xls file\n********************************************************************************\n\nHere's the sample code:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from pyexcel_xls import get_data\n    \u003e\u003e\u003e data = get_data(\"your_file.xls\")\n    \u003e\u003e\u003e import json\n    \u003e\u003e\u003e print(json.dumps(data))\n    {\"Sheet 1\": [[1, 2, 3], [4, 5, 6]], \"Sheet 2\": [[\"row 1\", \"row 2\", \"row 3\"]]}\n\n\nWrite an xls to memory\n********************************************************************************\n\nHere's the sample code to write a dictionary to an xls file:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from pyexcel_xls import save_data\n    \u003e\u003e\u003e data = OrderedDict()\n    \u003e\u003e\u003e data.update({\"Sheet 1\": [[1, 2, 3], [4, 5, 6]]})\n    \u003e\u003e\u003e data.update({\"Sheet 2\": [[7, 8, 9], [10, 11, 12]]})\n    \u003e\u003e\u003e io = StringIO()\n    \u003e\u003e\u003e save_data(io, data)\n    \u003e\u003e\u003e # do something with the io\n    \u003e\u003e\u003e # In reality, you might give it to your http response\n    \u003e\u003e\u003e # object for downloading\n\n\n\n\nRead from an xls from memory\n********************************************************************************\n\nContinue from previous example:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e # This is just an illustration\n    \u003e\u003e\u003e # In reality, you might deal with xls file upload\n    \u003e\u003e\u003e # where you will read from requests.FILES['YOUR_XLS_FILE']\n    \u003e\u003e\u003e data = get_data(io)\n    \u003e\u003e\u003e print(json.dumps(data))\n    {\"Sheet 1\": [[1, 2, 3], [4, 5, 6]], \"Sheet 2\": [[7, 8, 9], [10, 11, 12]]}\n\n\nPagination feature\n********************************************************************************\n\n\n\nLet's assume the following file is a huge xls file:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e huge_data = [\n   ...     [1, 21, 31],\n   ...     [2, 22, 32],\n   ...     [3, 23, 33],\n   ...     [4, 24, 34],\n   ...     [5, 25, 35],\n   ...     [6, 26, 36]\n   ... ]\n   \u003e\u003e\u003e sheetx = {\n   ...     \"huge\": huge_data\n   ... }\n   \u003e\u003e\u003e save_data(\"huge_file.xls\", sheetx)\n\nAnd let's pretend to read partial data:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e partial_data = get_data(\"huge_file.xls\", start_row=2, row_limit=3)\n   \u003e\u003e\u003e print(json.dumps(partial_data))\n   {\"huge\": [[3, 23, 33], [4, 24, 34], [5, 25, 35]]}\n\nAnd you could as well do the same for columns:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e partial_data = get_data(\"huge_file.xls\", start_column=1, column_limit=2)\n   \u003e\u003e\u003e print(json.dumps(partial_data))\n   {\"huge\": [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]}\n\nObvious, you could do both at the same time:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e partial_data = get_data(\"huge_file.xls\",\n   ...     start_row=2, row_limit=3,\n   ...     start_column=1, column_limit=2)\n   \u003e\u003e\u003e print(json.dumps(partial_data))\n   {\"huge\": [[23, 33], [24, 34], [25, 35]]}\n\n.. testcode::\n   :hide:\n\n   \u003e\u003e\u003e os.unlink(\"huge_file.xls\")\n\n\nAs a pyexcel plugin\n--------------------------------------------------------------------------------\n\nNo longer, explicit import is needed since pyexcel version 0.2.2. Instead,\nthis library is auto-loaded. So if you want to read data in xls format,\ninstalling it is enough.\n\n\nReading from an xls file\n********************************************************************************\n\nHere is the sample code:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import pyexcel as pe\n    \u003e\u003e\u003e sheet = pe.get_book(file_name=\"your_file.xls\")\n    \u003e\u003e\u003e sheet\n    Sheet 1:\n    +---+---+---+\n    | 1 | 2 | 3 |\n    +---+---+---+\n    | 4 | 5 | 6 |\n    +---+---+---+\n    Sheet 2:\n    +-------+-------+-------+\n    | row 1 | row 2 | row 3 |\n    +-------+-------+-------+\n\n\nWriting to an xls file\n********************************************************************************\n\nHere is the sample code:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e sheet.save_as(\"another_file.xls\")\n\n\nReading from a IO instance\n********************************************************************************\n\nYou got to wrap the binary content with stream to get xls working:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e # This is just an illustration\n    \u003e\u003e\u003e # In reality, you might deal with xls file upload\n    \u003e\u003e\u003e # where you will read from requests.FILES['YOUR_XLS_FILE']\n    \u003e\u003e\u003e xlsfile = \"another_file.xls\"\n    \u003e\u003e\u003e with open(xlsfile, \"rb\") as f:\n    ...     content = f.read()\n    ...     r = pe.get_book(file_type=\"xls\", file_content=content)\n    ...     print(r)\n    ...\n    Sheet 1:\n    +---+---+---+\n    | 1 | 2 | 3 |\n    +---+---+---+\n    | 4 | 5 | 6 |\n    +---+---+---+\n    Sheet 2:\n    +-------+-------+-------+\n    | row 1 | row 2 | row 3 |\n    +-------+-------+-------+\n\n\nWriting to a StringIO instance\n********************************************************************************\n\nYou need to pass a StringIO instance to Writer:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e data = [\n    ...     [1, 2, 3],\n    ...     [4, 5, 6]\n    ... ]\n    \u003e\u003e\u003e io = StringIO()\n    \u003e\u003e\u003e sheet = pe.Sheet(data)\n    \u003e\u003e\u003e io = sheet.save_to_memory(\"xls\", io)\n    \u003e\u003e\u003e # then do something with io\n    \u003e\u003e\u003e # In reality, you might give it to your http response\n    \u003e\u003e\u003e # object for downloading\n\n\nLicense\n================================================================================\n\nNew BSD License\n\nDeveloper guide\n==================\n\nDevelopment steps for code changes\n\n#. git clone https://github.com/pyexcel/pyexcel-xls.git\n#. cd pyexcel-xls\n\nUpgrade your setup tools and pip. They are needed for development and testing only:\n\n#. pip install --upgrade setuptools pip\n\nThen install relevant development requirements:\n\n#. pip install -r rnd_requirements.txt # if such a file exists\n#. pip install -r requirements.txt\n#. pip install -r tests/requirements.txt\n\nOnce you have finished your changes, please provide test case(s), relevant documentation\nand update changelog.yml\n\n.. note::\n\n    As to rnd_requirements.txt, usually, it is created when a dependent\n    library is not released. Once the dependency is installed\n    (will be released), the future\n    version of the dependency in the requirements.txt will be valid.\n\n\nHow to test your contribution\n--------------------------------------------------------------------------------\n\nAlthough `nose` and `doctest` are both used in code testing, it is advisable\nthat unit tests are put in tests. `doctest` is incorporated only to make sure\nthe code examples in documentation remain valid across different development\nreleases.\n\nOn Linux/Unix systems, please launch your tests like this::\n\n    $ make\n\nOn Windows, please issue this command::\n\n    \u003e test.bat\n\n\nBefore you commit\n------------------------------\n\nPlease run::\n\n    $ make format\n\nso as to beautify your code otherwise your build may fail your unit test.\n\n\nKnown Issues\n=============\n\n* If a zero was typed in a DATE formatted field in xls, you will get \"01/01/1900\".\n* If a zero was typed in a TIME formatted field in xls, you will get \"00:00:00\".\n\n.. testcode::\n   :hide:\n\n   \u003e\u003e\u003e import os\n   \u003e\u003e\u003e os.unlink(\"your_file.xls\")\n   \u003e\u003e\u003e os.unlink(\"another_file.xls\")\n","funding_links":["https://github.com/sponsors/chfw","https://patreon.com/chfw","https://www.patreon.com/chfw","https://www.patreon.com/bePatron?u=5537627"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyexcel%2Fpyexcel-xls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyexcel%2Fpyexcel-xls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyexcel%2Fpyexcel-xls/lists"}