From 4dca2b55f94fb3343d6fb7491767a49939e8e78e 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 6a6783b8..0a752fb7 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -197,6 +197,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(