From cef9fb375732e8bffcff944db5e4cde04610d13f Mon Sep 17 00:00:00 2001 From: Mudassir Chapra <37051110+muddi900@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:04:41 +0000 Subject: [PATCH] Added a column headers property and getters [Issue #677] --- gspread/worksheet.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gspread/worksheet.py b/gspread/worksheet.py index 31ba6a678..ad344a823 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -199,6 +199,17 @@ def __init__( # kept for backward compatibility - publicly available # do not use if possible. self._spreadsheet = spreadsheet + self._column_headers = [] + + @property + def column_headers(self) -> List[str]: + if not self._column_headers: + self._column_headers = self.row_values(1) + return self._column_headers + + @column_headers.setter + def column_headers(self, value: List[str]) -> None: + self._column_headers = value def __repr__(self) -> str: return "<{} {} id:{}>".format(