Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
replace _to_excel_range with CellRange, upgrade openpyxl min ver to 2…
….5.0
  • Loading branch information
tdamsma committed Jul 15, 2019
commit 22739b4e962bba1638cb6e9d19458c5541d07b12
2 changes: 1 addition & 1 deletion ci/deps/azure-35-compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- jinja2=2.8
- numexpr=2.6.2
- numpy=1.13.3
- openpyxl=2.4.8
- openpyxl=2.5.0
- pytables=3.4.2
- python-dateutil=2.6.1
- python=3.5.3
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/azure-36-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- lxml
- matplotlib=2.2.2
- numpy=1.14.*
- openpyxl=2.4.8
- openpyxl=2.5.0
- python-dateutil
- python-blosc
- python=3.6.*
Expand Down
2 changes: 1 addition & 1 deletion doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ gcsfs 0.2.2 Google Cloud Storage access
html5lib HTML parser for read_html (see :ref:`note <optional_html>`)
lxml 3.8.0 HTML parser for read_html (see :ref:`note <optional_html>`)
matplotlib 2.2.2 Visualization
openpyxl 2.4.8 Reading / writing for xlsx files
openpyxl 2.5.0 Reading / writing for xlsx files
pandas-gbq 0.8.0 Google Big Query access
psycopg2 PostgreSQL engine for sqlalchemy
pyarrow 0.9.0 Parquet and feather reading / writing
Expand Down
2 changes: 1 addition & 1 deletion pandas/compat/_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"matplotlib": "2.2.2",
"numexpr": "2.6.2",
"odfpy": "1.3.0",
"openpyxl": "2.4.8",
"openpyxl": "2.5.0",
"pandas_gbq": "0.8.0",
"pyarrow": "0.9.0",
"pytables": "3.4.2",
Expand Down
23 changes: 10 additions & 13 deletions pandas/io/excel/_openpyxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,6 @@ def _convert_to_protection(cls, protection_dict):

return Protection(**protection_dict)

@classmethod
def _to_excel_range(cls, startrow, startcol, endrow, endcol):
"""Convert (zero based) numeric coordinates to excel range."""
from openpyxl.utils.cell import get_column_letter

return "%s%d:%s%d" % (
get_column_letter(startcol + 1),
startrow + 1,
get_column_letter(endcol + 1),
endrow + 1,
)

def write_cells(
self, cells, sheet_name=None, startrow=0, startcol=0, freeze_panes=None
):
Expand Down Expand Up @@ -480,8 +468,17 @@ def format_table(
# Format the written cells as table

from openpyxl.worksheet.table import Table, TableStyleInfo
from openpyxl.worksheet.cell_range import CellRange

ref = str(
CellRange(
min_row=table_range[0] + 1,
min_col=table_range[1] + 1,
max_row=table_range[2] + 1,
max_col=table_range[3] + 1,
)
)

ref = self._to_excel_range(*table_range)
tab = Table(displayName=table_name, ref=ref, headerRowCount=1 if header else 0)

# Add a default style with striped rows
Expand Down