Skip to content

Commit

Permalink
Merge pull request #47 from aarimond/feature/show_gridlines
Browse files Browse the repository at this point in the history
Added show_gridlines property to Worksheet
  • Loading branch information
kevmo314 authored Jun 22, 2016
2 parents aaf3234 + cc69457 commit a45dbaf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pyexcelerate/Worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, name, workbook, data=None, force_name=False):
self._merges = [] # list of Range objects
self._attributes = {}
self._panes = Panes.Panes()
self._show_grid_lines = True
if data is not None:
for x, row in enumerate(data, 1):
for y, cell in enumerate(row, 1):
Expand Down Expand Up @@ -79,7 +80,15 @@ def num_rows(self):
@property
def num_columns(self):
return max(1, self._columns)


@property
def show_grid_lines(self):
return self._show_grid_lines

@show_grid_lines.setter
def show_grid_lines(self, show_grid_lines):
self._show_grid_lines = show_grid_lines

def cell(self, name):
# convenience method
return self.range(name, name)
Expand Down
2 changes: 1 addition & 1 deletion pyexcelerate/templates/xl/worksheets/sheet.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<worksheet mc:Ignorable="x14ac" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
<sheetViews>
<sheetView workbookViewId="0">
<sheetView{% if not worksheet.show_grid_lines %} showGridLines="0"{% endif %} workbookViewId="0">
{% if worksheet.panes %}{{ worksheet.panes.get_xml() }}{% endif %}
<selection activeCell="A1" sqref="A1" />
</sheetView>
Expand Down
12 changes: 12 additions & 0 deletions pyexcelerate/tests/test_Workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,15 @@ def test_number_precision():
# ws = wb.new_sheet("Test")
# print(ws[1:3])
# ws[1:3][1].style.fill.background = Color(255, 0, 0)

def test_show_grid_lines():
wb = Workbook()
ws = wb.new_sheet('without_grid_lines')
ws[1][1].value = 'some data'
ws.show_grid_lines = False
ws = wb.new_sheet('with_grid_lines')
ws[1][1].value = 'some other data'
ws.show_grid_lines = True
ws = wb.new_sheet('default_with_grid_lines')
ws[1][1].value = 'even more data'
wb.save(get_output_path("grid_lines.xlsx"))

0 comments on commit a45dbaf

Please sign in to comment.