Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inconsistent result for formulas in string #282

@jacky9813

Description

@jacky9813

I'm trying to generate spreadsheets in different formats that contains formulas.

However, different formats have produced different result.

For example:

import pyexcel

sheet = [['=HYPERLINK("https://www.google.com", "Google")']]

pyexcel.save_as(array=sheet, dest_file_name="test.xlsx")
pyexcel.save_as(array=sheet, dest_file_name="test.ods")
pyexcel.save_as(array=sheet, dest_file_name="test.xls")

The output files can be splitted into two groups:

  • Treat formula as string (with ' added in front): ods and xls
  • Treat formula as formula: xlsx

It's quite close to #8, but that seems focusing on loading data from xlsx file. AFAIK, data_only for the openpyxl.workbook.Workbook class is a read-only property.


Is there any flag for pyexcel.save_as and pyexcel.save_book_as function that can correctly write formula based on developer's requirement?

For example, auto_detect_formula=True will write strings starting with = as formulas, while auto_detect_formula=False will treat all all strings as strings.


Here's the environment I'm currently using, if it helps:

OS: Fedora 39 amd64
Python Version: 3.9.18 (compiled from source)
Installed Packages:

Package       Version
------------- -------
chardet       5.2.0
et-xmlfile    1.1.0
lml           0.1.0
lxml          5.1.0
openpyxl      3.1.2
pip           23.0.1
pyexcel       0.7.0
pyexcel-ezodf 0.3.4
pyexcel-io    0.6.6
pyexcel-ods3  0.6.1
pyexcel-xls   0.7.0
pyexcel-xlsx  0.6.0
setuptools    58.1.0
texttable     1.7.0
xlrd          2.0.1
xlwt          1.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions