peterservice-rnd/robotframework-excellib

Read Cell KW should not read formulas but the result of formulas.

Opened this issue · 3 comments

I am trying to Read Cell row col but this reads the Excel formulas designed for that cell instead of the result of the cell. Is there a way to add this feature or a workaround for this?

If this feature is added, I learned that it can be done by using data_only=True flag while loading workbook. Can I create a PR for this then? @dmizverev @Joyfolk @ailjushkin

Hi colourmein13

If this feature is added, I learned that it can be done by using data_only=True flag while loading workbook. Can I create a PR for this then? @dmizverev @Joyfolk @ailjushkin

Is this issue resolved? If not any workaround?

Here is the solution. Can you update your function in excellibrary and release a new version of this on?

Solution Bolded
def open_excel_document(self, filename: str, doc_id: str, data_only: str = False ) -> str:
"""Opens xlsx document file.\n
Args:\n
filename: document name.\n
doc_id: the identifier for the document that will be opened.\n
data_only: the identifier for the data only value. Default is False.\n
Returns:\n
Document identifier from the cache.\n
Example:\n
| Open Excel Document | filename=file.xlsx | doc_id=docid | data_only=False
| Close All Excel Documents |
"""
filename = str(filename)
doc_id = str(doc_id)
if doc_id in self._cache:
message = u"Document with such id {0} is opened."
raise SuchIdIsExistException(message.format(doc_id))
workbook = openpyxl.load_workbook(filename=filename, data_only=data_only)
self._cache[doc_id] = workbook
self._current_id = doc_id
return self._current_id

def open_excel_document(self, filename: str, doc_id: str, **data_only: str = False** ) -> str:
    """Opens xlsx document file.\n
    *Args:*\n
        _filename_: document name.\n
        _doc_id_: the identifier for the document that will be opened.\n
        **_data_only_: the identifier for the data only value. Default is False.\n**
    *Returns:*\n
        Document identifier from the cache.\n
    *Example:*\n
    | Open Excel Document | filename=file.xlsx | doc_id=docid | **data_only=False**
    | Close All Excel Documents |
    """
    filename = str(filename)
    doc_id = str(doc_id)
    if doc_id in self._cache:
        message = u"Document with such id {0} is opened."
        raise SuchIdIsExistException(message.format(doc_id))
    workbook = openpyxl.load_workbook(filename=filename, **data_only=data_only**)
    self._cache[doc_id] = workbook
    self._current_id = doc_id
    return self._current_id