diff --git a/dev/docs/source/_images/hide_row_col_headers.png b/dev/docs/source/_images/hide_row_col_headers.png new file mode 100644 index 000000000..52c8b5700 Binary files /dev/null and b/dev/docs/source/_images/hide_row_col_headers.png differ diff --git a/dev/docs/source/page_setup.rst b/dev/docs/source/page_setup.rst index 286fb6926..e8b49590e 100644 --- a/dev/docs/source/page_setup.rst +++ b/dev/docs/source/page_setup.rst @@ -3,9 +3,9 @@ The Worksheet Class (Page Setup) ================================ -Page set-up methods affect the way that a worksheet looks when it is printed. -They control features such as paper size, orientation, page headers and -margins. +Page set-up methods affect the way that a worksheet looks to the user or when +it is printed. They control features such as paper size, orientation, page +headers and margins and gridlines. These methods are really just standard :ref:`worksheet ` methods. They are documented separately for the sake of clarity. @@ -540,6 +540,22 @@ headers:: worksheet.print_row_col_headers() + +worksheet.hide_row_col_headers() +-------------------------------- + +.. py:function:: hide_row_col_headers() + + Set the option to hide the row and column headers in a worksheet. + +This method is similar to the ``print_row_col_headers()`` except that it hides +the row and column headers on the worksheet:: + + worksheet.hide_row_col_headers() + +.. image:: _images/hide_row_col_headers.png + + worksheet.print_area() ---------------------- diff --git a/xlsxwriter/test/worksheet/test_write_sheet_view.py b/xlsxwriter/test/worksheet/test_write_sheet_view.py index 7c2dede6d..7cae699e3 100644 --- a/xlsxwriter/test/worksheet/test_write_sheet_view.py +++ b/xlsxwriter/test/worksheet/test_write_sheet_view.py @@ -89,3 +89,15 @@ def test_write_sheet_view_hide_gridlines_2(self): got = self.fh.getvalue() self.assertEqual(got, exp) + + def test_write_sheet_view_hide_row_col_headers(self): + """Test the _write_sheet_views() method""" + + self.worksheet.select() + self.worksheet.hide_row_col_headers() + self.worksheet._write_sheet_view() + + exp = """""" + got = self.fh.getvalue() + + self.assertEqual(got, exp) diff --git a/xlsxwriter/worksheet.py b/xlsxwriter/worksheet.py index 18016127a..24d5397f0 100644 --- a/xlsxwriter/worksheet.py +++ b/xlsxwriter/worksheet.py @@ -201,11 +201,12 @@ def __init__(self): self.orientation = 1 self.print_options_changed = False - self.hcenter = 0 - self.vcenter = 0 - self.print_gridlines = 0 - self.screen_gridlines = 1 - self.print_headers = 0 + self.hcenter = False + self.vcenter = False + self.print_gridlines = False + self.screen_gridlines = True + self.print_headers = False + self.row_col_headers = False self.header_footer_changed = False self.header = '' @@ -3494,9 +3495,22 @@ def print_row_col_headers(self): Nothing. """ - self.print_headers = 1 + self.print_headers = True self.print_options_changed = True + def hide_row_col_headers(self): + """ + Set the option to hide the row and column headers on the worksheet. + + Args: + None. + + Returns: + Nothing. + + """ + self.row_col_headers = True + @convert_range_args def print_area(self, first_row, first_col, last_row, last_col): """ @@ -5042,10 +5056,14 @@ def _write_sheet_view(self): # Write the element. attributes = [] - # Hide screen gridlines if required + # Hide screen gridlines if required. if not self.screen_gridlines: attributes.append(('showGridLines', 0)) + # Hide screen row/column headers. + if self.row_col_headers: + attributes.append(('showRowColHeaders', 0)) + # Hide zeroes in cells. if not self.show_zeros: attributes.append(('showZeros', 0))